6

I have an ipython notebook that I would like to print without having the page breaks cut through my figures.

Any suggestions? I tried the "awesome screenshot" extension for chromium, but it was buggy and ended up cutting out half of my page.

Any suggestions?

  • Try wkhtmltopdf, as suggested here. –  Jan 09 '13 at 00:16
  • @Mik, Seems promising! I'll give it a try (but holy hell do they need to come up with a better name!) =D – Louis Thibault Jan 09 '13 at 00:27
  • 1
    @Mik, This seems to print over multiple pages, which exactly the problem I'm trying to avoid. Am I missing something? – Louis Thibault Jan 09 '13 at 00:30
  • Yes you're right, but something like the gnome-photo plugin for shutter, as discussed here might be useful, but you would have to convert the image to pdf, as the answer below also mentions this relating to the chrome extension. –  Jan 09 '13 at 00:44

3 Answers3

2

I have managed to use gnome-web-photo in conjunction with imagemagick to produce a decent quality single, tall pdf of a webpage using a single command. You should already have imagemagick, but install gnome-web-photo with

sudo apt-get install gnome-web-photo

In this oneliner, convert is the program used from the imagemagick package:

gnome-web-photo --mode=photo http://www.askubuntu.com --file ask.png && cat ask.png | convert - ask.pdf 

The tall web page is downloaded by gnome-web-photo to file, and can't be piped directly to convert without saving it as an image file first. So one way for convert to receive that file though the pipe is to concatenate it and then use convert - so that the png file is received by convert via stdin (denoted as -) and then converted to pdf.

However, for the second part of the command you could use && convert ask.png ask.pdf instead of && cat ask.png | convert - ask.pdf, but both take about the same time.

You can use the --print option with gnome-web-photo to print a webpage to file (i.e. pdf), but it didn't produce a suitable single page result, so the oneliner above is about the best that can be done.

2

PDF has a defined media size, so you're going to have to do some workarounds:

  1. Set up a custom page size in your printer. I have one, TenLetter, which is 215.9 × 2794 mm, or a sheet the length of 10 US letter pages end to end. It doesn't split unless the whole content is longer than ten pages. It's a pain to view (zoom is your friend) or to print, but it doesn't break any images.

  2. Manually import the static HTML page into a wordprocessor, and do manual page breaks before the images you don't want split.

Automatic pagination is a hard problem, and most browsers aren't that great at implementing printing support. CSS Print Profile is one of those great ideas that almost works for everyone …

scruss
  • 1,259
1

I recently had the same need, and did it in two steps:

1) I used the Chrome Screen Capture Extension (https://chrome.google.com/webstore/detail/screen-capture-by-google/cpngackimfmofbokmjmljamhdncknpmg?hl=en) to capture the page in a png

2) I printed the PNG to a PDF

Troy Ready
  • 134
  • 2
  • 1
    this isn't quite doing the trick. The resulting PDF is an 8.5/11" page and it's impossible to zoom in close enough to see anything other than a blur... – Louis Thibault Jan 09 '13 at 00:47