0

I've been searching for this feature over a long time, but I've found nothing I could use. I need an app, a service, a trick...whatever to help me transform html files that are produced in a local Apache server to pdf.

I've found one or two apps, but they have serious non-CSS support, so they are out of suggestion.

Has anyone achieved what I want to do?

EDIT

Actually, after long long searching, I've found the following solution:

  1. use pdfcrowd (I used the SAVE-TO-PDF-LINK)
  2. in order to make pdfcrowd fetch your local php-generated HTML pages, you have to adjust your Apache server settings (see here)
  3. make your local page be browsed by a public IP (I used some minor network engineering help, actually it was a port forwarding)
  4. that's it! you're done! as long as you access your application from the new public IP, the PHP->HTML->PDF will work fine!
Community
  • 1
  • 1
Panos Vakalopoulos
  • 515
  • 1
  • 8
  • 23
  • possible duplicate of [Convert HTML + CSS to PDF with PHP?](http://stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php) – Rangad Jun 01 '15 at 12:45
  • @Rangad yeap. it might be possible, although that post doesn't specify that the solution should apply to local installation, not using any online calls to web services. – Panos Vakalopoulos Jun 01 '15 at 12:57
  • Try using: [DOMPDF](https://github.com/dompdf/dompdf) – kenorb Jun 02 '15 at 00:01

2 Answers2

4

I have used wkhtmltopdf with some success. Works with the webkit so the support for CSS is decent.

eagle12
  • 1,658
  • 11
  • 14
-1

Try using TCPDF. Its CSS support is limited but is enough to create simple nice-looking documents. I have used it successfully in a few projects of mine.

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->AddPage();
$html = '<div style="text-align:center">The words "<span style="font-weight: bold">[mazel] [tov]</span>" mean "Congratulations!"</div>';
$pdf->writeHTML($html, true, false, true, false, '');

Check out the examples.

fracz
  • 20,536
  • 18
  • 103
  • 149