0

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.

  • You do not want to use Adobe Acrobat ? – Ruskes Feb 25 '14 at 9:37
  • Give us a sample of your document if it is public. – Ruskes Feb 25 '14 at 9:40
  • @Buscar웃, would I have to pay for Adobe Acrobat? I'd like a free solution. I've tried adding a new paper size in Safari, with zero margins, but it seems to have no effect on the margins in Safari (it does in SeaMonkey). No, the document is not public. – cnst Feb 25 '14 at 14:56
  • Is it one time deal if not might be worth getting Acrobat. Also try they online services. – Ruskes Feb 25 '14 at 17:18
  • @Buscar웃, the whole point is that I want to be able to have a say of how stuff is formatted; I can already do better than the online services by simply printing directly from Safari, and ignoring the huge page margin at the bottom. – cnst Feb 25 '14 at 17:31
2

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.

  • It doesn't install; gem -v returns 1.3.6 (wkpdf requires >=1.3.3), sudo gem install wkpdf returns ERROR: http://rubygems.org/ does not appear to be a repository ERROR: could not find gem wkpdf locally or in a repository. – cnst Feb 25 '14 at 18:47
  • actually, it might be related to my wifi tethering provider proxy server blocking my stuff... :-) is there an easy way to specify a socks proxy or a different user-agent or port? :) – cnst Feb 25 '14 at 18:48
  • I'm accepting this because it works as far as the question is worded, although it'd be nice to have the ability to still print the header/footer stuff as the browser does. Thanks for your help; I looked at wkpdf prior to asking this question, but its homepage -- plessl.github.io/wkpdf/#usage -- did not indicate the ability to control the margins, hence was my question. – cnst Feb 25 '14 at 19:51
  • Hm, there's also WeasyPrint, which is not OS-X-specific, but it doesn't seem to work as good as wkpdf (they implement their own rendering, and seem to be missing some features, even though they also supposedly implement those that aren't supported by WebKit, e.g. specific to printing and paged media). – cnst Feb 26 '14 at 16:03
  • Sadly, this no longer seems to work on 10.9; my understanding is that, according to plessl.github.io/wkpdf, due to potential future issues the author has disabled installation through gem. :-( – cnst Mar 24 '15 at 0:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .