Mozilla Cairo Update – Printing

I’ve been working on getting printing hooked up in the cairo builds for the last couple weeks and finally got printing on Windows working pretty well. You go through the same awful print preview window and the same standard print dialog as you’d expect and everything just works like it should. I’ve been testing with PrimoPDF, a free Windows PDF-generating print driver similar to Acrobat. It works great and has saved quite a few trees (for a while pages were printing on anywhere between 50 and 1500 pages due to some bugs…) I need to do some additional testing with real printers, but I’m pretty happy with the progress.

The current work is more about getting printing working again than really improving the quality of the stuff we print. After spending some time printing different sites, it is clear to me that some time needs to be spent doing a better job of layout out content for printing. I’ve got 2 example PDF files that I printed here: the Deer Park Alpha 2 Start Page and yesterday’s Penny Arcade. Both look very close to 1.5 in terms of output, but as you’ll notice from the Penny Arcade one, we could use some work to improve printing to actually look like the website we’re printing. Any volunteers?

There will be some updates to the Thebes and Cairo bits on the trunk in the next few days, but they probably won’t include printing quite yet. A lot of this code needs to be reorganized and cleaned up before I can check it in and start on Linux and Mac printing.

[update: 11:58PM Eastern — Boris points out that the problem with Penny Arcade is related to their use of media=”screen” in the link tag for their stylesheet. We would probably do a much better job printing if they didn’t have that there. Thanks Boris! I’ll send some mail to those guys and tell them to fix their site…]

13 thoughts on “Mozilla Cairo Update – Printing

  1. Robert O'Callahan

    So how does this work? Using the existing Win32 backend with a printer HDC? What stuff doesn’t work? (opacity? translucent images?) And where are we going from here?

  2. Stuart Parmenter

    roc: it uses the thebes win32 surface with a printer HDC. I’ve got quite a few various cairo, thebes, and gfx/src/thebes patches here in order to get it to that point.

    Translucent images don’t work. I haven’t tested opacity yet.

    Whats next? For me, cleaning up the patches and getting them in to cairo and the tree. Then its on to Linux and Mac printing… I probably won’t spend a lot of time revisiting Windows printing for a while.

  3. Boris Zbarsky

    Stuart, the reason penny-arcade looks different is that their HTML says:

    Note the media attribute. So when printing, none of those styles are applied, as the page author clearly wanted.

  4. Stuart Parmenter

    Doug: It doesn’t really fix those kind of images. It may now be easier to fix that bug though. I’ll have to spend some time looking in to it to see what is required. We can probably pre-composite in software the image on the background and send that as the image instead of the real image.

  5. Anonymous

    Does this mean printing will finally printer-independant? Or must we wait for a Cairo PDF export for this? (When will this be implemented?)

  6. Stuart Parmenter

    Printing on Windows will probably remain somewhat printer dependent, although we will probably do our best to use software fallbacks to make things look as close as they can to the same across all printers.

    Using cairo for PDF printing on Windows is hard because of its use of Freetype for text. We might could do something there, but it isn’t something I’m planning to do anytime soon.

    We’ll use cairo’s PDF surfaces on Linux for sure and possibily on Mac, but it has similar font related issues to Windows. We’ll have to see what the right thing to do there is.

    Hope this helps.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s