Convert HTML to PDF with page margins and hyperlinks

htmlpdfpreviewprintingsafari

Unfortunately, it would appear that Safari doesn't support CSS2 page margins from CSS2 recommendation circa 1998, whereas all other major browsers now do.

However, when printing out an HTML page, it would seem like it is only Safari (or at least some versions of it on some systems) that preserves the hyperlinks into the PDF document, whereas all other browsers (SeaMonkey, Firefox, Google Chrome) only preserve the decoration.

Is there any way to print a rather complex HTML document into PDF without losing the hyperlinks, but ensuring narrow margins?

There's a related question, but it's simply after the hyperlinks, without any regards to the page margins — Print HTML to PDF while retaining hyperlinks.

Best Answer

Try using wkpdf:

sudo gem install wkpdf;wkpdf -s file.html -m 10 file.pdf

It retains links and you can specify margin sizes with -m.