{"id":8785,"date":"2012-09-19T17:22:20","date_gmt":"2012-09-19T17:22:20","guid":{"rendered":"http:\/\/blog.mozilla.org\/labs\/?p=8785"},"modified":"2012-10-10T18:57:20","modified_gmt":"2012-10-10T18:57:20","slug":"a-new-way-to-control-printing-output","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/labs\/2012\/09\/a-new-way-to-control-printing-output\/","title":{"rendered":"A New Way to Control Printing Output"},"content":{"rendered":"<p>An experimental API for printing has landed in Firefox 18. The API&#8217;s creation was driven by the needs of <a href=\"https:\/\/github.com\/mozilla\/pdf.js\">pdf.js<\/a> and was <a href=\"https:\/\/groups.google.com\/forum\/#!msg\/mozilla.dev.tech.layout\/-JV2whghEVg\/DzwLnwpy_YcJ\">designed by Robert O&#8217;Callahan and Julian Viereck<\/a> and <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=745025\">implemented by Julian and I<\/a>.<\/p>\n<h2>Problems<\/h2>\n<ul>\n<li>How do you print a pdf with hundreds of pages?<\/li>\n<li>How do you get high quality output?<\/li>\n<\/ul>\n<h2>Solution<\/h2>\n<p><em>mozPrintCallback<\/em> &#8211; 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 <em>printState.done()<\/em> to tell the printing code to advance. The benefits of this approach are: 1) we don&#8217;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).<\/p>\n<h2>Example<\/h2>\n<p><iframe loading=\"lazy\" style=\"width: 100%; height: 300px;\" src=\"http:\/\/jsfiddle.net\/FPNMM\/2\/embedded\/js,result\" frameborder=\"0\" width=\"320\" height=\"240\"><\/iframe><\/p>\n<h2>Feedback<\/h2>\n<p>As I mentioned above, this is still experimental and currently only available in the <a href=\"http:\/\/nightly.mozilla.org\/\">Nightly (FF18)<\/a> 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&#8217;d love to hear your thoughts. Is this useful? Is there anything you&#8217;d change or add? Please share your feedback here via comments or in the <a href=\"https:\/\/groups.google.com\/forum\/?fromgroups=#!topic\/mozilla.dev.pdf-js\/BpHHPLOwH8A\">mailing list<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;d love to get your feedback on an experimental API to control print output developed by Julian Viereck and Brendan Dahl from the Mozilla LabsPDF.js project.  <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/labs\/2012\/09\/a-new-way-to-control-printing-output\/\">Continue reading<\/a><\/p>\n","protected":false},"author":461,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19295],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/8785"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/users\/461"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/comments?post=8785"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/8785\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/media?parent=8785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/categories?post=8785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/tags?post=8785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}