Printing options in PDFTron HTML5 WebViewer

981 views
Skip to first unread message

Support

unread,
Dec 17, 2012, 5:37:12 PM12/17/12
to pdfnet-w...@googlegroups.com
Q: I couldn't find anything referring to printing. Is it possible to print from inside the WebViewer, or is printing done (and controlled) by the browser?
 
------------
A:

The WebViewer includes some print options, but due to browser dependency the 'print' story is not as straightforward compared to printing via our native SDKs (http://www.pdftron.com/pdfnet/mobile) which work directly with the underlying OS.

 

The WebViewer includes built-in print support in Silverlight and Flash WebViewer client. At the moment 'HTML5 WebViewer' does not include built-in print option because current browsers are not very good at printing. We are looking forward to proper print support in modern browsers, but in the meantime downloading PDF, XPS, or printing via images seems to be good compromise for most users.

 

As mentioned above most web browsers are not very good at printing. For example, they have the annoying habit of including URLs and dates across the footer of a page. The pages are frequently not paginated well, fonts/sizes are wrong etc. So what does a web app that needs high quality print output do? Here is what Google Docs does when you click their "Print" button:

 

+ Converts the file to PDF.

+ Load the newly converted PDF in Acrobat (or another PDF viewer plugin)

+ Triggers the Acrobat print dialog

 

So they download PDF to the client then use a  client program to print the file. Now because WebViewer's XOD is just XPS (http://en.wikipedia.org/wiki/Open_XML_Paper_Specification), and because XPS is the native Windows Print Spool Format there is no need for any server side conversion and the XOD file can be directly viewed and printed on any Windows machine without any software installs! Of course, if required you can also download the original PDF (or use PDFNet's XPS to PDF transform function).

 

Another way to print from HTML5 WebViewer is by using 'Document.LoadCanvasAsync()'  (http://www.pdftron.com/pdfnet/webviewer/demo/html5/doc/symbols/CoreControls.Document.html#LoadCanvasAsync) to render an image for given page. The resulting image can then be printed - similar to print button on news web sites http://stackoverflow.com/questions/4716756/printing-just-canvas-element-on-a-page.

 

In case you decide to use a mobile development framework (such as Titanium Studio or Phonegap) to build applications for mobile devices using JavaScript/HTML5 and CSS3, instead of device specific languages such as Objective-C/Java, the situation is much better compared to when running the viewer in the browser.

 

In this case you could use platform specific print methods and you could even use PDFNet native functions (e.g. pdftron.PDF.Print.StarPrintJob etc - http://www.pdftron.com/pdfnet/samplecode.html#PDFPrint). This is possible because these frameworks allow JavaScript to be integrated with native components.

 

Reply all
Reply to author
Forward
0 new messages