Generate PDF file with Zend Framework 2 [closed]

2019-05-05 19:02发布

问题:

I'm started to learn ZF2 right now and notice that there's no "Zend_Pdf" or similar on zend framework 2...

How can I create pdf on this version of the framework?

Anyone knows a good tutorial?

回答1:

Zend Framework 2 has moved many of the old Zend Framework libraries out of the main core and created modules instead. Zend_Pdf is one of the libraries that was moved to a module. You can find them all in the Zend Framework repository on GitHub.

You need the ZendPdf package, just follow the instructions on the page. Documentation is not ready yet simply because it's not a core module. Documentation will probably follow as soon as all bugs are worked out with the core stuff.

Also see the Zend Framework package repository.



回答2:

If you need to generate a PDF in ZF2 environment, there is a brief tutorial how to do that with PD4ML. The approach does not require to program a PDF layout (like createPdfDocument(), startParagraph(), addImage() etc). It just converts an existent rendered view (HTML + CSS + SVG + images) to PDF or optionally to RTF.



回答3:

If you need a module that allow easy to thumbnail, snapshot or PDF generation from a url or a html you can take a look to MvlabsSnappy based on Snappy PHP (5.3+) wrapper for the wkhtmltopdf & wkhtmltoimage conversion utility.