myokyawhtun / PDFMerger

PDFMerger compatible for PHP 5, PHP 7, and PHP 8
238 stars 272 forks source link

Error writing a file on disk during ->merge('file', 'fname.pdf') #15

Closed Kadmillos closed 7 years ago

Kadmillos commented 8 years ago

When using 'file' method during $pdf->merge(), the function expects an output from $fpdi->Output() that will never come during output 'file' from fpdf class I added a new case to act properly during 'file' merging mode.

myokyawhtun commented 8 years ago

can you check file/folder permission where you're saving?

Kadmillos commented 8 years ago

file permissions are ok. when you merge on a file, the file is written without errors, but the program's flow gives you an error. That's because the switch during the fdpf->Output does not give anything in return if you save the pdf as a file; so the pdfmerge thinks it's an error and an exception is raised

Kadmillos commented 8 years ago

My pull request is a quick fix. the better solution should be to check if the fpdf instance gives something on the $fpdf->Error but from what i see through i thought you didn't want to rely on that