← Back to Pdfgenerator Support
Hi, I follow the example from the documentation page:
$pdfGenerator = new PdfGenerator(); //Set absolute path of the Twig layout $pdfGenerator->layout = plugins_path().'/initbiz/pdfGenerator/pdflayouts/example/default.htm'; //Set filename for downloaded file $pdfGenerator->filename = "invoice"; //Set data which will be sent to the layout $pdfGenerator->data = ['viewData' => 'Value of viewData']; $pdfGenerator->generatePdf(); return $pdfGenerator->downloadPdf();
and the PDF is created in the correct directory. However, the filename is something like
generated_W4yPGQH1rDIrk2Q.pdf
although I have set it to invoice.
Also, I get redirected to the following page /initbiz/pdfgenerator/download/invoice/W4yPGQH1rDIrk2Q With the exception being The file "/Applications/MAMP/htdocs/XXX/pdfs/invoice_W4yPGQH1rDIrk2Q.pdf" does not exist
I will look into the code and change the filename there manually but can you tell me what I did wrong/is this a bug?
Kind regards
Last updated
I have found the reason:
The filename is not set via $pdfGenerator->filename
(as said in documentation), you set it via the constructor.
So in my case it should be
$pdfGenerator = new PdfGenerator('invoice');
Please update your documentation.
Great plugin, though!
Hi,
Thank you for using our plugin and sorry for the problem you have encountered.
The documentation is updated :)
Regards,
Tomasz Strojny
1-3 of 3