hanneskod / libmergepdf

PHP library for merging multiple PDFs
390 stars 77 forks source link

Autoloader problem #15

Closed advicente closed 8 years ago

advicente commented 8 years ago

Hi, I'm using version 3.0.0 with composer autoloader and facing some problems related with FPDI classes.

Using the following code: use iio\libmergepdf\Merger;

$file = "file1.pdf";
$file2 = "file2.pdf";

$pdf = new Merger;
$pdf->addFromFile($file);
$pdf->addFromFile($file2);
header("Content-Type: application/pdf");
echo $pdf->merge();

Throws the expection: FPDI: 'include(fpdi_pdf_parser.php): failed to open stream: No such file or directory'.

The above expection seems to be solved if I change the line 120 of file setasign\fpdi\fpdi.php from if (!class_exists('fpdi_pdf_parser')) { to if (!class_exists('fpdi_pdf_parser', false)) {

But then it throws another exception: FPDI: 'include(pdf_parser.php): failed to open stream: No such file or directory'.

Please feel free to ask more details if needed, Thanks.

hanneskod commented 8 years ago

Hm, I'm not able to reproduce this. What do you get if you run

composer show

from the you project root?

advicente commented 8 years ago

Running composer show:

sem titulo

advicente commented 8 years ago

My problem had to do with my autoloader. I've included the following code in my composer.json and now it works.

"autoload": { "files": ["vendor/setasign/fpdi/pdf_parser.php"] }

Thanks.

hanneskod commented 7 years ago

Hi again and sorry for the late reply. Glad you found a solution, although you should not need the files directive in composer.json.

I am still not able to reproduce, and does not have an explanation. If you want to dig deeper into this please attach your exact composer.json and the script that produce your error and I can have another look. Otherwise I will leave this closed...

Happy new year!