0

I want to convert HTML to PDF on the server to allow a client download.

I have a "print view" of my website (an alternative stylesheet). The client now wants to download the page as a PDF instead of print.

Can anyone recommend an opensource project (I can host) or a cheap API service that can grab a page and turn it into a PDF??

http://pdfcrowd.com/ looks like it does what I want, however my preference is fixed-cost and self-hosted but if that's not an option I don't mind spending.

Thanks.

Simon
  • 5,158
  • 8
  • 43
  • 65
  • Look [DOMpdf](http://code.google.com/p/dompdf/) – bahamut100 Jun 08 '11 at 09:48
  • 1
    Why is this question "off topic"? I needed to programmatically convert HTML to PDF on the server. I found the solution PDFCrowd. That seems completely "on topic" for SO. – Simon Dec 21 '12 at 09:11

3 Answers3

1

My company's developed an HTMl to PDF API called DocRaptor that uses Prince XML for PDF generation.

We've got better CSS interpretation than comparable APIs, and several plan levels, including a free plan.

HTMl to PDF with DocRaptor

illbzo1
  • 480
  • 3
  • 13
1

I've worked on a few projects that do this and let me give you some advice.

Most of these HTML to PDF converters handle very very limited HTML (often not CSS or limited CSS) so you need to construct your HTML specially for the PDF so it looks right. You can not just dump your site into the generator and expect magic :)

Look at this SO question for libraries.

Community
  • 1
  • 1
Ólafur Waage
  • 68,817
  • 22
  • 142
  • 198
  • Also, [List of HTML to PDF converters](http://stackoverflow.com/q/3178448/264628) (this is not limited to PHP libraries) – BrianS Jun 08 '11 at 17:22
0

I used http://pdfcrowd.com/ their API renders the HTML you send them using WebKit and they return an accurate PDF. It's not free or opensource but very good.

Simon
  • 5,158
  • 8
  • 43
  • 65