Search code examples
phpcodeigniterpdffpdffpdi

FPDF setSourceFile source file issue


Hello all I am new to codeigniter

I am using fpdf & fpdfi for create and append pdf files.

I have some silly issue as below

when I am sending file path as

$pdfPath="./public/site/userdocuments/sagar/RetData/1.pdf";
$pdf -> setSourceFile($pdfPath);

then it works but when I am trying to make pdf files dynamic as follows

$filename="1.pdf";
$pdfPath="./public/site/userdocuments/sagar/RetData/".$filename;
$pdf -> setSourceFile($pdfPath);

then it throws error as below

InvalidArgumentException: Cannot open http://10.0.11.114:8888/start.spaceParse/public/site/userdocuments/sagar/RetData/1.pdf in /Applications/MAMP/htdocs/start.spaceParse/application/libraries/pdfResources/pdf_parser.php on line 192

I had already researched on it and its related to file not found issue. I cant understand whats the problem with it.

any help appreciated ..

Thanks in advance

Sorry for bad English..


Solution

  • I tried the explode function. Try changing your code to something like this:

    $filename="1.pdf";
    $newString= explode(".",$filename);
    $pdfPath="./public/site/userdocuments/sagar/RetData/".newString[0].".pdf";