Prints the document set in the viewer.
element
iframe
element OR div
element passed by the user to add the temp printing data to it. Must not be null.
options
Document printing options (Page Size, orientation ...etc), can be null.
This methods print the document set in the viewer. Printing in JavaScript/HTML5 is performed by setting up HTML content containing the pages of
the document to be printed and then calling the JavaScript window.print
method. This method will show a print dialog filled with the options
specified by the user. Finally, the HTML content is sent to the printer (or exported as PDF if the browser has this support).
Below is a detail overview of the working of this method:
Check if printing is supported by the browser/device combination. If printing is not supported, an error is thrown.
If there is no document in the viewer or if it does not have any pages, then the method returns.
Operation event with DocumentViewerOperationEventArgs.Operation set to PrintPages and Data1 set to an instance of DocumentViewerPrintProgress to allow the user to abort the operation now. The value of PagesCompleted will be 0
The viewer will loop through each page to be printed in the document and fire the Operation event with DocumentViewerOperationEventArgs.Operation set to PrintPages, Data1 set to an instance DocumentViewerPrintProgress with PagesCompleted set to a value from 1 to the number of pages to print.
During the loop, the viewer will get the page content (image, SVG, PDF data) and optionally, the annotations and add or render them into element.
After all the content is collected, options are used to fill in and then show the standard browser print dialog.
When printing completes, Operation occurs with Data1 set to null and IsPostOperation set to true. If an error occurs during printing, then the value of Error will be set to the error object.
element must be an HTML iframe
that exist in the HTML of your page. If the code is running for mobile chrome
(Android or iOS), then it must point to a HTML div
element added to the page.
For an example, refer to the doPrint
function in the document viewer demo source code.
Printing is supported by all major browsers and devices. However, it be limited or even not supported with some combination. The Document toolkit code is continuously being updated to match the latest "evergreen" browsers. It is recommended to try the printing functionality from using the live Document Viewer demo at https://demo.leadtools.com/JavaScript/DocumentViewer/ to determine the latest level of support for printing using a particular browser and device combination.
Products |
Support |
Feedback: print Method (DocumentViewer) - Leadtools.Documents.UI |
Introduction |
Help Version 19.0.2017.5.24
|