I am looking for a PDF generator bundle that is easy to use and that does not require wkhtmltopdf
as my shared hosting server does not support this.
I have tried https://github.com/psliwa/PdfBundle
, but if I follow the documentation I simply get a response on the screen (no PDF generated). While there is a solution for this in this question, this solution seems overly complex.
I have also looked at ioalessio/IoTcpdfBundle
, which seems straight-forward enough to use, but does not have a composer install and my web server does not support vendor install.
I have also tried stedekay/SpraedPDFGeneratorBundle
, but this just plain errors complaining about not finding Java.
While whiteoctober/WhiteOctoberTCPDFBundle
might be able to work, this just creates a TCPDF object that one has to work with further and the documentation is not very encompassing.
Any suggestions (or advice on how to get any of the mentioned bundles working) will be greatly appreciated.
I use SpraedPDFGeneratorBundle and I install it from https://github.com/stedekay/SpraedPDFGeneratorBundle using Composer to activate it. I activated in the AppKernel new Spraed\PDFGeneratorBundle\SpraedPDFGeneratorBundle()
.
Finally I executed the command php composer.phar update
and in my controller I put this code:
$html = $this->renderView('MyappJournalBundle:Default:index1.html.twig');
$pdfGenerator = $this->get('spraed.pdf.generator');
return new Response($pdfGenerator->generatePDF($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="out.pdf"'
)
);
and it worked for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With