Marko Vasic
Marko Vasic

Reputation: 301

Create PDF file using PHP

I need to create a PDF or Word file filled with contents from my database. Then the customer need to download that file. All this should happend when customer click on link.

Anyone have any idea?

Upvotes: 10

Views: 40546

Answers (6)

Michal
Michal

Reputation: 3368

wkthmltopdf is really THE ONLY solution that worked for me that could produce what I call acceptable results. Still, some minor modifications to the CSS had to be made, however, it worked really well when it comes to rendering the content. All the other packages are really only suitable if you have a rather simply document with one basic table etc. No chance to get them to produce fair results on complex docs with design elements, css, multiple overlapping images etc. If complex documents are in game - do not spend the time (like I did) - go straight to wkhtmltopdf.

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

Upvotes: 1

Radek Suski
Radek Suski

Reputation: 1392

You can use for example: html2pdf. It's heavy library but seems to have very advanced functionality.

dompdf is a light library but it lacks a bit unicode support.

If you have access to the server maybe it would be better to install the PECL PDF library. But I never used so cannot tell you if it's good

Upvotes: 2

TPete
TPete

Reputation: 2069

Got 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

Upvotes: 1

allen213
allen213

Reputation: 2277

Try TCPDF

http://www.tcpdf.org/

But google could have told you that

Upvotes: 5

F21
F21

Reputation: 33383

I have used TCPDF with much success to generate PDF files programatically using PHP.

And to generate word documents: http://www.phpdocx.com/ (this is a paid solution).

Upvotes: 10

hohner
hohner

Reputation: 11588

dompdf is your best bet

Upvotes: 3

Related Questions