Tutorial: Window.print

Window.print

Prints the window's web page. When silent is set to true, the API will pick the system's default printer if deviceName is empty and the default settings for printing.

Use the CSS style page-break-before: always; to force print to a new page.

Example

const win = fin.Window.getCurrentSync();

win.print({ silent: false, deviceName: 'system-printer-name' }).then(() => {
    console.log('print call has been sent to the system');
});

If a window has embedded views, those views will not print by default. To print a window's contents including embedded views, use the content option.

Example

const win = fin.Window.getCurrentSync();

// Print embedded views
win.print({ content: 'views' });

// Print screenshot of current window
win.print({ content: 'screenshot' })

When content is set to views, the embedded views in the platform window will be concatenated and printed as individual pages. If includeSelf is set to true, the platform window itself will be printed as the first page - be aware that this page will not include the embedded views - it will only include the contents of the platform window itself (e.g. tab stacks), with blank spaces where the view contents would be embedded.

Due to a known issue, view contents that are not visible at the time print is called will not appear when printing contents: views. This includes views that are obscured behind other active UI elements.

To print the views embedded in their page context, set content to screenshot.