A New Way to Control Printing Output

An experimental API for printing has landed in Firefox 18. The API’s creation was driven by the needs of pdf.js and was designed by Robert O’Callahan and Julian Viereck and implemented by Julian and I.


  • How do you print a pdf with hundreds of pages?
  • How do you get high quality output?


mozPrintCallback – A new callback for canvas that is executed during the printing process. This callback can access the printing canvas context and perform any calls that are normally done to a 2D canvas context. When the callback is finished with rendering it must call printState.done() to tell the printing code to advance. The benefits of this approach are: 1) we don’t have to try and render every page before print, 2) the output gets rasterized later in the printing process where it should be. (This is not available for all platforms yet).



As I mentioned above, this is still experimental and currently only available in the Nightly (FF18) version of Firefox. However, we plan to propose it as a standard since we think it has many interesting use cases outside of pdf.js. We’d love to hear your thoughts. Is this useful? Is there anything you’d change or add? Please share your feedback here via comments or in the mailing list.

4 responses

  1. e–p wrote on :

    (sorry for my English)
    I’m in the same mood as Gerben.
    Everything that improve print quality is a good thing.
    It’s really a bad thing to learn that :
    – @font-face is still not supported for print with non-locally installed fonts (http://etienne.pouvreau.free.fr/public/font-face-print-preview-2/) ;
    – too few CSS Paged Media properties are implemented.
    But thank you for this step !

    1. bdahl wrote on :

      This was actually just fixed in the Nightly version of Firefox. See bug https://bugzilla.mozilla.org/show_bug.cgi?id=468568

  2. Gerben wrote on :

    It’s a shame print has been overlooked for so long. I think a lot of business applications could benefit from some more control over printing.

    But I think the most wanted feature would be to disable the page header and footer that all browsers seem to include. It would be nice to just print out an invoice right from you webbased system, without having to change the header and footer text, or having to install some extension that does this for you. Most systems work around this by exporting to PDF, and having the client download; open; and print this PDF.

    Also having some more of the CSS Paged Media Module implemented would be nice, but I think the above case would solve 90% of all print related issues.

    1. Julian Viereck wrote on :

      Hi Gerben,

      > But I think the most wanted feature would be to disable the page header and footer that all browsers seem to include.

      there is work going on to hide the page headers. See this bug [1].



      [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=115199