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
although I have set it to invoice.
Also, I get redirected to the following page
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?
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');