Approach to generate generate pdf file from html page?

I studied wkhtmltopdf, tcpdf mechanism to generate pdf files. wkhtmltopdf where you directly pass a .html file and it gives you the pdf where in tcpdf you need to code entire pdf.

my case is I'm having a pdf form template Which I've converted into html so user can fill that form and after i fill that template with user entered values then I'll give an option to user to download the html (user filled) file as PDF document, so template will have user entered data next to that labels.

so first

PDF template >> convert to .HTML page >> process with php echoing >> convert it back with user input to a PDF file.

I'm confused here which approach I should use.

  1. Install wkhtmltopdf on server and use it to pass .html page

problem: Everytime I need to save .html page on server and pass again it to wkhtmltopdf.

  1. using TCPDF I need to write lots of code to create pdf exactly same as template PDF docs I'm having and then using php echoing those user enterted values.

Which approach should i use If I'm expecting 1000+ users will be saving page as pdf at same time, approach which will be more easier and scalable in future.


First of all - I think you should go with the HTML form to PDF approach, so that's either wkhtmltopdf or a tool that already does this for you like PDFmyFORM.

In case you're expecting to go to 1000 saves concurrently then you definitely want to roll your own solution instead of going with an external service though.

There are patches in the wkhtmltopdf issue list that suggest caching (see this one) and you may also want to think about whether all these forms have to be generated as PDF again. You could use APC cache to somehow cache PDFs based on the same values being filled in. That could save you a bunch of time.

Other solutions you may want to look into are for example PhantomJS, which is a headless webkit browser too, but then based on JS - so that may reduce your server load alltogether...

Need Your Help

I cannot get a image to the bottom of my bootstrap DIV

html css twitter-bootstrap

I cannot get my image to the bottom of my DIV (that is boostrap DIV what is probably causing the problem)

State Machine and Intents

android android-layout

My android app needs to run through a sequence of events as in a state machine