Remo's Guide -- PDF Gen -- generate_pdf returns stdClass not mpdf object
Permalink
I've installed the PDF block from Remo's book -- which is an excellent guide.
When I attempt to create a PDF of a page by calling the generate_pdf program in tools, it uses the Loader to load the mpdf class library.
Something apparently is instantiated with the new mpdf call. But, it apparently is a stdClass rather than an mpdf object, so no method calls are recognized. I've looked through the mpdf class but not found any obvious clues that a stdClass is being returned in case the environment isn't set up properly.
I would assume that the Loader call isn't set properly, but I'm not sure how to test this.
Here's the code:
When I attempt to create a PDF of a page by calling the generate_pdf program in tools, it uses the Loader to load the mpdf class library.
Something apparently is instantiated with the new mpdf call. But, it apparently is a stdClass rather than an mpdf object, so no method calls are recognized. I've looked through the mpdf class but not found any obvious clues that a stdClass is being returned in case the environment isn't set up properly.
I would assume that the Loader call isn't set properly, but I'm not sure how to test this.
Here's the code:
Loader::library ('mpdf54/mpdf'); $mdpf = new mPDF ('utf-8', 'letter') ; $mpdf->showImageErrors = true; $mpdf->SetCreator ('PDF by concrete5') ; // undefined method on stdClass $mpdf->useOnlyCoreFonts = true; $mpdf->SetBasePath ($url); $mpdf->WriteHTML ($header . $content) ; $mpdf->Output() ;
Thanks, Mike.
found your issue,
it should be
$mdpf
it should be
$mpdf
Still learning PHP and its behavior when everything isn't quite right. This is a good lesson.
I appreciate your taking the time to review the code to find the simple misspelling. Dyslexia strikes again.
All the best.
I appreciate your taking the time to review the code to find the simple misspelling. Dyslexia strikes again.
All the best.
Yea no problem, when I run into an issue like that I step through the code using print_r() or var_dump() on the variables.
Thanks, Mike.
The problem is either with your code or the library.
Mike