10

Can anybody advise on the best PDF generator class/library to use with PHP? Preferably one which is maintained.

I am aware that this is a duplicate of the following question, however, the accepted answer is over 3 years old and I want to know whether the answer has changed since this time.

Which one is the best PDF-API for PHP?

Thank you

Community
  • 1
  • 1
Ben Carey
  • 16,540
  • 19
  • 87
  • 169
  • [dompdf](http://code.google.com/p/dompdf/) is by far the _easiest_ I've tried, but maybe not the most flexible. Depends what you're trying to do.. – Ben Sep 10 '12 at 11:00
  • Thank you for your advice, but this class seems somewhat underdeveloped at the moment. I think I will stick with the tcpdf class :-) – Ben Carey Sep 10 '12 at 11:30

4 Answers4

9

Try TCPDF, have good features http://www.tcpdf.org/examples.php

Also simple HTML to PDF Converter API in (PHP, C#, ASP.net C#, ASP VB.net, JAVA,...)

from "PDF CROWD" http://pdfcrowd.com/html-to-pdf-api/

very simple to use, but I think this API may need to purchase even they provide a free test account..

Mohamed Navas
  • 592
  • 7
  • 16
  • Thank you very much, I am currently looking at the tcpdf one. Do you know whether it does HTML to PDF? – Ben Carey Sep 10 '12 at 11:17
  • Sorry for the delayed reply... see the examples "6" in tcpdf.org [http://www.tcpdf.org/examples/example_006.pdf], It support HTML, If you use html file - I think you have to read the file to one variable [$html_file_content = fopen('myfile.html', 'r');] and then convert to PDF. – Mohamed Navas Sep 15 '12 at 17:54
  • Thank you very much, did see that but wanted to make sure it worked well as they cannot always be trusted :-) – Ben Carey Sep 17 '12 at 07:32
  • There is problem with image reading. You have to specify the absolute path not relative. – Mohamed Navas Sep 17 '12 at 07:41
  • I always specify absolute not relative anyway :-) – Ben Carey Sep 17 '12 at 09:22
2

Have you tried http://www.PDFnow.com?

Provides a powerful template engine, and is pretty easy to use.

Supports complex layouts, layouts for multiple pages, invoices spreading separate pages, pagenumbers, headers, footers, etc. Definitively much better than fpdf.

You can simply integrate it into your PHP code by:

generatePdf(<templateName>, <ParameterArray>);

very straightforward.

Peter Es
  • 51
  • 4
0

Have a look on http://wkhtmltopdf.org/ Convert HTML to PDF using WebKit engine. It can be used from PHP easily. For example, there is a bundle for Symfony2: http://knpbundles.com/KnpLabs/KnpSnappyBundle

WayFarer
  • 1,040
  • 11
  • 19
0

Best One is TCPDF

http://www.tcpdf.org/

Never Use DOMPDF

Mad Angle
  • 2,347
  • 1
  • 15
  • 33
  • @chhameed for customization TCPDF is the best one. Besides the the there is a very good documentation available for the TCPDF but not for the DOMPDF – Mad Angle Oct 19 '16 at 06:21