daniele_nifty
daniele_nifty

Reputation: 1

Can't import PDF with mpdf

everyone.

I started using mpdf on my website recently. Creating new pdfs is working fine, but i can't import existing ones. I get this error whenever i try to execute the import:

mPDF error: Cannot open ../folder1/folder2/folder3/folder4/folder5/thisisthepdf.pdf !

(that is not the real path)

I included the mpdf in the php. The folder and the files are on chmod 777 and the pdfs are all version 1.4

This is the way i am trying to import.

$mpdf=new mPDF();
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile('../folder1/folder2/folder3/folder4/folder5/thisisthepdf.pdf');
$tplId = $mpdf->ImportPage($pagecount);
$mpdf->UseTemplate($tplId);
$mpdf->WriteHTML('Hallo World');
$mpdf->Output();

I tried various ways to import i found on stackoverflow and other sites, but nothing worked. Not even the code from the official mpdf manual i am using (the one above) is working. Trying to solve this issue for quite a while now, but i am out of ideas. I Hope someone can help me. Thanks in advance!

Upvotes: 0

Views: 1790

Answers (1)

Jan Slabon
Jan Slabon

Reputation: 5058

This error message is raised because of a failing call of a simple fopen(). Which means that the PHP script simply cannot access the file.

So ensure that the path is valid by e.g. passing it to realpath(), as it seems to be a relative path. If this evaluates to false the path is simply wrong. Otherwise it is a permission issue.

Upvotes: 1

Related Questions