If you want to add a link to pages on your website to create a PDF version of the page, here is one way to do it.
(If you have already set up a CSS stylesheet for media=”print” which works for mPDF, you can omit the first 2 steps.)
Write a stylesheet suitable for presenting your webpage in mPDF. Most webpages have a header and menu on the left or right
which you will not want to appear in the PDF document. You can use display: none to omit these elements. From mPDF >= 5.0
this will also work for inline elements. You may have something like this:
Save this file as e.g. mypdf.css
Then add this line to your webpages. This should be at the end of the document <head> section, to override any preceding style definitions:
NB The media=”mpdf” means that the stylesheet will be ignored by browsers, but can be selected for use by mPDF - see below.
Now create a file e.g. makepdf.php and add the following script. Note you will need to edit the lines in italics.
Now, the link from your webpages. This code can be inserted anywhere on the page. (The <![CDATA[ bit is to make the
page compatible with XHTML.) This code will work if your webpages are simple files e.g. myfile.html
or if they are selected using variables in the URI (i.e. HTTP GET method) e.g. myfile.php?cc=1&var=35
Use this to generate the code, if the webpages are selected using variables hidden from the URI e.g. HTTP POST method using a form: