openBrowserPrint Method

Summary

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

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

Parameters

parent

The parent element to which

printRoot is applied. Must be attached to the DOM.

printRoot

The root element for printing.

title

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

printStyles

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

Remarks

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.

History

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

Requirements

Target Platforms

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

Leadtools.Document.Viewer Assembly