openBrowserPrint Method


Opens the browser's native print dialog with the provided print elements and styles.

DocumentViewer.prototype.openBrowserPrint = function( 
   parent: HTMLElement, 
   printRoot: HTMLElement, 
   title: string, 
   printStyles: HTMLElement[] 
): void; 



The parent element to which

printRoot is applied. Must be attached to the DOM.


The root element for printing.


A title to apply to the margins of the printed pages, if supported by the browser and device combination.


An array of HTMLStyleElement to append to the parent for printing.


OpenBrowserPrint is used in conjunction with Print to print document pages. By default, PrintDocumentOptions.AutoOpenBrowserPrint is true, meaning that OpenBrowserPrint is called internally when Print completes successfully. This setup ensures a painless single method call for most cases.

Sometimes a user may wish to modify the print data as it is being constructed. To do so, the user may respond to the DocumentViewer.Operation event (see Print for more information). However, if the user wishes to modify the DocumentPrintData for the print operation before the browser print dialog opens, PrintDocumentOptions.AutoOpenBrowserPrint can be set to false and OpenBrowserPrint can be called manually by the user when necessary.

When PrintDocumentOptions.AutoOpenBrowserPrint is true, these arguments are passed:

As seen above, only DocumentPrintData is needed to open the browser print dialog with all the information from the Print method, as the options are available with DocumentPrintData.Options. By modifying the DocumentPrintData, the user may remove pages from printing, change styles, add custom pages, rotate pages, etc.

OpenBrowserPrint attempts to normalize the process of opening the browser print dialog for the major HTML5 browsers. However, certain browser and device combinations will not work correctly. The printRoot element is appended to the parent element. Then, the title and styles are applied to the page and the browser print function is called.

If parent is an HTMLIFrameElement, the title and styles are applied to the IFrame’s document instead of the current page’s document. This can be a cleaner option, but does not work in all browsers. In mobile Chrome (Android or iOS), an HTMLIFrameElement may result in an error.


Added. Prior to version, Print automatically opened the browser's print dialog when completed.


Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Viewer Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.