How to convert Html files to Pdf?

8

1

The title say it all, I want a 100% accurate tool to convert a HTML page to a PDF document.

user31936

Posted 2010-03-22T14:26:46.687

Reputation:

Through which rendering engine? – SLaks – 2010-03-22T14:55:03.450

Don't we all... – Rowan – 2010-03-23T08:14:27.210

Answers

10

Check out wkhtmltopdf. It uses the Webkit layout engine (as used in Safari, Chrome, etc.).

Matt

Posted 2010-03-22T14:26:46.687

Reputation: 381

+1 good answer, wkhtml even waits until jscript code is done with the dom (nice for asciidoc-toc stuff) – akira – 2010-03-22T15:17:16.023

I've been using NitroPDF for a couple years. Just found wkhtmltopdf, it works better, is faster and runs on ubuntu. – Bob Weber – 2010-05-18T04:14:59.373

This didn't work for me on OS X. It would never finish 'rendering'. A very similar program did work, called wkpdf

– Ian – 2011-05-31T19:37:27.463

Been looking for something like this for a number of hours now - thank you! – R4D4 – 2013-02-15T00:11:17.730

6

Consider the fact that no two browsers can render that HTML completely identically for a moment, and then realize that you're never going to get it.

Hasaan Chop

Posted 2010-03-22T14:26:46.687

Reputation: 4 224

Well, if you interpret "100% accurate" to mean "exactly as rendered in a specific browser", then you can most definitely get that. – Michael Borgwardt – 2010-03-22T14:43:20.507

@Michael: Sure, but that information wasn't included in the question. – Rowan – 2010-03-23T08:15:54.600

4

  • Install a virtual printer driver that saves print output as PDF
  • Open HTML in browser
  • Printo to virtual printer

Michael Borgwardt

Posted 2010-03-22T14:26:46.687

Reputation: 3 047

nice workaround, I'll try it – None – 2010-03-22T14:36:40.910

Be aware that depending on the browser you're using, the settings in it, and the webpage, some parts of the printed PDF page won't be 100% what you see on screen. Obvious things to look for, if you have a dark/black background set with light/white text over it, default print settings in most browsers will change that to black text with white background. – GAThrawn – 2010-03-22T15:18:51.107

Yes, this won't be 100% accurate, results will vary from page to page. – Rowan – 2010-03-23T08:16:26.190

@MichaelBorgwardt: AFAIK, virtual printers do not fully support HTML links, right?

– dma_k – 2011-09-12T22:27:38.333

0

I use Primo PDF to convert HTML to PDF. it's just a PDF Printer.

File > Print > Choose primo PDF

alt text

It's useful one for me because I couldn't use the Internet everything. If I want to read some articles from Wiki, I've printed out with that printer and read at home.

Ye Lin Aung

Posted 2010-03-22T14:26:46.687

Reputation: 5 444

0

I've been looking for this too. My best solution at the moment is to use a combination of Firefox and PDFCreator. I've also tried the other main browsers, but they don't let you turn off their own headers and footers. If you want to be able to print grey/gray text as grey (rather than black) then be sure to enable the "Print Background (color and images)" option in the File | Page Setup | Format & Options dialog.

Unfortunately, none of the main browsers seem to support the CSS @page rule for specifying things like headers, footers, widows, orphans, page sizes, landscape/portrait, etc.

There is a tool called Prince that claims to be able to do all of that (and more), with good reviews, but I haven't used it because it's expensive. (There is a free version for personal use, but it adds its own logo onto the front page of the PDF document.)

Jason Brown

Posted 2010-03-22T14:26:46.687

Reputation: 101

0

wkpdf worked perfectly for me when wkhtmltopdf did not, on OS X. It's a Ruby Gem, which was very simple to use on a stock OS X install.

Ian

Posted 2010-03-22T14:26:46.687

Reputation: 387