Create PDF file using PHP

I need to create a PDF or Word file populated with content from my database. The client then needs to download this file. All of this has to happen when a customer clicks on a link.

Anyone have an idea?

+3


source to share


6 answers


I have used TCPDF with great success to create PDFs programmatically using PHP.



And for creating text documents: http://www.phpdocx.com/ (this is a paid solution).

+6


source


Try TCPDF

http://www.tcpdf.org/



But Google could tell you that

+3


source


dompdf is your best choice

+1


source


You can use for example: html2pdf . It is a heavy library but seems to have very advanced features.

dompdf is a light library but lacks unicode support.

If you have access to the server, it might be better to install the PECL PDF library . But I have never used, so I cannot tell if this is good

+1


source


Received one more: FPDF

Hello World:

<?php
 require('fpdf.php');

 $pdf = new FPDF();
 $pdf->AddPage();
 $pdf->SetFont('Arial','B',16);
 $pdf->Cell(40,10,'Hello World!');
 $pdf->Output();
?>

      

Taken from: FPDF Tutorial 1

0


source


wkthmltopdf is really the only solution that worked for me, which could give what I call acceptable results. However, there were some minor changes to the CSS that had to be made, however, it worked very well when it came to providing content. All the other packages are really only suitable if you have a fairly simple document with one base table, etc. There is no way to get them to get fair results on complex documents with design elements, css, multiple overlapping images, etc. If complex documents are in the game - don't waste time (as I did) - go straight to wkhtmltopdf.

Take a look at my own question and solution in this post HTML2PDF to PHP - convert utilities and scripts - examples and demos

0


source







All Articles