I’m looking at generating PDFs to output various types of document sizes, A3, A4, A5 using PHP.
Currently I have a div that has various divs within this area that are positioned absolutely.
What I’m looking to do though is to have this div a fixed height a width, but when I save the contents, it can be used for A4, A3 and A5 print sizes.
What’s the best way of achieving this?
Thanks
EDIT:
I am also trying to add a full width background image for each type?
Also, does the div need to be a specific height/width in order to create each document?
I’d like to have an ‘area’ where I can view the HTML of document. So, if I select A3, it will then save the PDF as A3, with the background image full width and all the positioned divs in the correct places.
use MPDF
mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number of enhancements.
I wrote mPDF to output PDF files ‘on-the-fly’ from my website, handling different languages. It is slower than the original scripts e.g. HTML2FPDF and produces larger files when using Unicode fonts, but support for CSS styles etc. has been much enhanced – see the features.
Please see the examples, and feel free to download it. There is quite an extensive online documentation manual for mPDF.
Here is the list of arguments you can pass to default constructor.