PDF or Portable Document Format is a popular file type that is often used for online documents. It’s great for distributing downloadable written content, and is frequently used by governments and businesses alike. Because it’s a format that’s familiar to all, many applications allow the user to convert other document types to the PDF format. PHP is one programming language that has a built-in ability to convert to PDF. PHP scripts can be used to transform file types such as HTML into PDF files.
Try dompdf, it looks like what you need:
dompdf is an HTML to PDF converter. At its heart, dompdf is (mostly) CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.
Also, one of the answers for This Stack Overflow question suggests wkhtmltopdf:
Simple shell utility to convert html to pdf using the webkit rendering engine, and qt.
So your PHP code could call it. However, has some problems:
- It needs a patched Qt for some features
- It needs the X.org stack in the server-side
Or you could combine html2ps (HTML to PostScript) and ps2pdf (PostScript to PDF).
0