New Web Print Api lands in Firefox 18
Mozilla has just implemented a new web printing api in recent Firefox 18 Nightly builds that aims to improve the print quality in the web browser. It has primarily been added for the web browser's built-in pdf reader pdf.js, but has been implemented to work with all print outs of the browser.
The browser executes a new callback - mozPrintCallback - during the printing process. It can access the printing canvas context and perform "any calls that are normally done to a 2D canvas context". Once done with the rendering the printing proceeds as usual.
Mozilla sees two core benefits over the previous way of printing in the Firefox web browser:
- The browser does not have to render every page before the printing starts
- The output gets rasterized later in the printing process
A newly create wiki page over at Mozilla offers additional information about the current WebPrintApi implementation which is mostly interesting to web developers:
- Points (pt) are used as metrics for printing, use of px is forbidden
- Custom page printing is supported
- Only one page size per PrintDocument. The size is defined in the PrintDocument constructor.
- PrintRenderingContext is similar to CanvasRenderingContext2d.
The page lists several open questions that Mozilla has not decided upon yet. This includes whether the api should support different color spaces than RGB, whether a progress view should be displayed while the pages are drawn, or how (0,0) is defined.
The printing API is an experimental feature right now, which may or may not make its way into a stable Firefox version. I can't really remember when I printed out the last documents, must have been ages ago. What are your takes on the new printing api that aims to improve quality of the output and the printing process? (via Techdows)Advertisement
If it won’t broke anything, â€” let it be, and we’ll see if it delivers quality in comparison. I use printing pretty often â€” but printing to PDF.