How to create PDF from HTML?

HTML to PDF

  • Help me turn a photo essay, currently in HTML, into a PDF (without big ugly white space when photos break to the following page). This is very simple: a series of center-aligned photos (not enlargeable) interspersed with bits of center-aligned text, sort of like a film strip. It's long...probably will be a 20 page PDF. I want to convert to PDF as painlessly and cheaply as possible. When I create a PDF via Safari, it's got lots of white space, where a given photo won't cram into the page. What's my best bet here? I am on a Mac. And I'm willing to jigger the photo sizes if necessary. Tell me I don't need to buy Acrobat....

  • Answer:

    If you're looking to get the pagination right, the best option will usually be to convert via a wordprocessor. Once you've tweaked the layout and got it looking the way you want it, the resulting PDF should be pretty much a perfect rendering of the document. Monkeying about with CSS and then hoping the browser will produce something pleasing sounds like an exercise in frustration.

Quisp Lover at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

For HTML to PDF where I actually care about how the result looks, I usually open the HTML in LibreOffice Writer and jigger it about by hand before doing an "Export as PDF". It sounds a bit laborious but doesn't generally take too long. You might also consider printing to PDF from Firefox, using the https://addons.mozilla.org/en-us/firefox/addon/print-edit/ add-on to tidy things up.

pont

If you're using Firefox, you can also use the https://addons.mozilla.org/en-us/firefox/addon/nuke-anything-enhanced/ add-on to "edit" pages before printing by right-clicking and selectively removing divs and other objects on the page, which might help with the cleanup as well!

limeonaire

I'd write a http://alistapart.com/article/goingtoprint. Probably force the images to a consistent height, and wrap the image + caption in a div that's got a consistent height so that page breaks are predictable.

adamrice

http://plessl.github.io/wkpdf/ is a command line utility on the Mac that I've used quite successfully to create PDF documents. Try it out.

DreamerFi

I'm not sure what its relationship to wkpdf is, but there is also https://code.google.com/p/wkhtmltopdf/.

Dr Dracator

How are you creating the PDF via safari? You can often hit "print" on a webpage, and then instead of printing it to an actual printer, print it to PDF. Dunno if that's what you tried, but it must be by far the easiest, so I'd suggest tinkering with a few browsers and settings.

Buckt

What Buckt said. If you're on a Mac File > Print... > PDF Button > Save as PDF. In chrome you have to escape the crome window and "Use OS Dialog".

humboldt32

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.