Forum Moderators: coopster

Message Too Old, No Replies

Autogeneration of PDFs for PHP based site

         

galahad2

10:14 am on Jun 22, 2010 (gmt 0)

10+ Year Member



Hi

I have a site which is written up in PHP and has a page with various products for sale, pulled from a mySQL database.

What we need to be able to do is have a way of autogenerating a PDF version of the "product detail" page, so that certain items (product description, the main photos, technical details etc.) on the page are bundled into a PDF which is generated for the user and which they can then save, print etc. just as they would with any PDF.

It should be dynamic, in that if changes are made to the product, when the user next clicks the "Download as PDF" link for that product, the changes are incorporated.

I know it's possible to just manually make PDFs based on the product pages and put them up on the site, but this means a lot of extra maintenance (remaking PDFs whenever products change etc.)

Any idea if and how this can be achieved?

elkiwi

10:19 am on Jun 22, 2010 (gmt 0)

10+ Year Member



Yes you can use FPDF which is a free php class for making pdfs.

[fpdf.org...]

galahad2

10:42 am on Jun 22, 2010 (gmt 0)

10+ Year Member



Thanks, just had a look, can't see if it allows you to choose which parts of the page you want to add into the PDF though... worth a look however.

lammert

11:46 am on Jun 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are PHP libraries to generate PDF files. Some content management systems have them already built in, with vanilla PHP installations you have to download the library and install it. One well known PDF library for PHP is TCPDF.