8

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

Josh K
  • 12,990

7 Answers7

10

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

Matt
  • 381
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
  • 4,906
4
  • Install a virtual printer driver that saves print output as PDF
  • Open HTML in browser
  • Printo to virtual printer
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.

Gareth
  • 19,080
Ye Lin Aung
  • 5,700
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.)

0

if you use Ubunto.

today i using img2pdf:

sudo apt-get install -y cutycapt
sudo apt-get install -y img2pdf
cutycapt --url=https://stackoverflow.com/story/sl5net --out=story_sl5net.jpg --print-backgrounds=on && img2pdf story_sl5net.jpg -o story_sl5net.pdf

my problem is that no automatic page breaks are created when converting

for OCR i using https://wiki.ubuntuusers.de/Paperwork/

Maybe also very helpful way to do this:

https://github.com/Szpadel/chrome-headless-render-pdf

SL5net
  • 281
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
  • 387