How to render PDFs in Zend Framework

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to render PDFs in Zend Framework

dennis-fedco
I've heard that one can set up a rendering strategy in ZF2, where I prepare my data, send it to a PDF template, and something (rendering engine) renders PDF from my data.  

How?

I need to be able to create PDFs, while doing things:
* (essentially using blank PDF as a "template") - Ability to output text, HTML tables, and images into PDF form
* (essentially using existing PDFs as a template) - Ability to include (reuse) existing pre-made PDFs as part of PDF creation + ability to place more data on said pre-made PDFs

How would I begin to make this happen?   I am looking for some direction.  
Reply | Threaded
Open this post in threaded view
|

Re: How to render PDFs in Zend Framework

Matt Kynaston
Heya,

On 29 July 2014 23:38, dennis-fedco <[hidden email]> wrote:

>
> * (essentially using existing PDFs as a template) - Ability to include
> (reuse) existing pre-made PDFs as part of PDF creation + ability to place
> more data on said pre-made PDFs
>

If I understand correctly, you want to use one pdf as a "background" and
render another PDF on top of it? Really don't know if ZF2 does this. Back
when I last looked you either needed a paid-for pdflib (expensive) or do it
via apache fop[1] +  fop-pdf-images[2].

The latter's the approach we took, and I've not regrets. A simple Tomcat
servlet - just a minor hack or two from the sample in the apache-fop source
- takes the XSL-FO and returns the PDF. XSL-FO might look intimidating, but
in practice anyone who can hand-code HTML soon gets the hang of it. You
don't even need the XSL side of it - we use PHP templates to generate pure
FO to render.

Check it out and ping me if you need an example of the page-master that
includes the background PDF.

Matt

[1] http://xmlgraphics.apache.org/fop/
[2] http://xmlgraphics.apache.org/fop/fop-pdf-images.html
Reply | Threaded
Open this post in threaded view
|

Re: How to render PDFs in Zend Framework

Mike Willbanks
I'd also suggest using phantom.js and using it to render out your PDF's
given some HTML and a stylesheet.  I haven't really found a solution that
works better.

Regards,

Mike


On Tue, Jul 29, 2014 at 7:01 PM, Matt Kynaston <[hidden email]> wrote:

> Heya,
>
> On 29 July 2014 23:38, dennis-fedco <[hidden email]> wrote:
>
> >
> > * (essentially using existing PDFs as a template) - Ability to include
> > (reuse) existing pre-made PDFs as part of PDF creation + ability to place
> > more data on said pre-made PDFs
> >
>
> If I understand correctly, you want to use one pdf as a "background" and
> render another PDF on top of it? Really don't know if ZF2 does this. Back
> when I last looked you either needed a paid-for pdflib (expensive) or do it
> via apache fop[1] +  fop-pdf-images[2].
>
> The latter's the approach we took, and I've not regrets. A simple Tomcat
> servlet - just a minor hack or two from the sample in the apache-fop source
> - takes the XSL-FO and returns the PDF. XSL-FO might look intimidating, but
> in practice anyone who can hand-code HTML soon gets the hang of it. You
> don't even need the XSL side of it - we use PHP templates to generate pure
> FO to render.
>
> Check it out and ping me if you need an example of the page-master that
> includes the background PDF.
>
> Matt
>
> [1] http://xmlgraphics.apache.org/fop/
> [2] http://xmlgraphics.apache.org/fop/fop-pdf-images.html
>
Reply | Threaded
Open this post in threaded view
|

Re: How to render PDFs in Zend Framework

Frank Brückner
In reply to this post by dennis-fedco
Hi,
look at: https://github.com/raykolbe/DOMPDFModule


Kind regards,
Frank

Am 30.07.2014, 00:38 Uhr, schrieb dennis-fedco <[hidden email]>:

> I've heard that one can set up a rendering strategy in ZF2, where I  
> prepare
> my data, send it to a PDF template, and something (rendering engine)  
> renders
> PDF from my data.
>
> How?
>
> I need to be able to create PDFs, while doing things:
> * (essentially using blank PDF as a "template") - Ability to output text,
> HTML tables, and images into PDF form
> * (essentially using existing PDFs as a template) - Ability to include
> (reuse) existing pre-made PDFs as part of PDF creation + ability to place
> more data on said pre-made PDFs
>
> How would I begin to make this happen?   I am looking for some direction.
/mail/

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to render PDFs in Zend Framework

dennis-fedco
In reply to this post by Mike Willbanks
>you want to use one pdf as a "background"

Yes

>and render another PDF on top of it?

Not quite.  Render things like HTML table, text, and circles on top of it.  
Reply | Threaded
Open this post in threaded view
|

Re: How to render PDFs in Zend Framework

tomass
This post has NOT been accepted by the mailing list yet.
In reply to this post by dennis-fedco
Hi Dennis,
I tried ZendPdf https://github.com/zendframework/ZendPdf (documentation is in ZF1 manual), but if you need more control and format html with css and than generate pdf document I would recommend mPDF http://mpdf1.com/manual/index.php?tid=452
Reply | Threaded
Open this post in threaded view
|

Re: How to render PDFs in Zend Framework

akrabat
In reply to this post by dennis-fedco
Hi,

Use WKHtmlToPDF for rendering a PDF from HTML/CSS source.

Then shell out to the pdftk  command line too to merge the rendered PDF with the background PDF (use the “background” or “multi background” operation).

Regards,

Rob...

On 30 Jul 2014, at 14:52, dennis-fedco <[hidden email]> wrote:

>> you want to use one pdf as a "background"
>
> Yes
>
>> and render another PDF on top of it?
>
> Not quite.  Render things like HTML table, text, and circles on top of it.  
>
>

--
PHP content at http://akrabat.com
Daily Jotter for Mac OS X at http://dailyjotter.com


--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to render PDFs in Zend Framework

jeremiah
In reply to this post by dennis-fedco
Slavey's ZF2 book is really good, and as it happens, he had a nice recipe in it at the end of the demo app where he demonstrates using Zend PDF to generate a certificate by combining an existing PDF and overlaying data from the app.

Learn ZF2: Learning By Example by Slavey Karadzhov http://www.amazon.com/dp/1492372218/ref=cm_sw_r_udp_awd_feh7tb15FYMM7

Jeremiah

On Jul 30, 2014, at 6:52 AM, dennis-fedco <[hidden email]> wrote:

>> you want to use one pdf as a "background"
>
> Yes
>
>> and render another PDF on top of it?
>
> Not quite.  Render things like HTML table, text, and circles on top of it.  
>
>
>
>
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/How-to-render-PDFs-in-Zend-Framework-tp4662233p4662237.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]