Skip to main content

print

Trigger the browser print dialog for the whole page or a single element.

Import: @rtorcato/browser-common/print

๐Ÿ“– MDN: Window.print()

Browser supportโ€‹

APIChromeEdgeFirefoxSafariiOS SafariBaseline
Window.printโœ… 1+ [1]โœ… 12+โœ… 1+โœ… 1.1+โœ… 1+Widely available
  1. Chrome: Starting with Chrome 46, this method is blocked inside an <iframe> unless its sandbox attribute has the value allow-modals.

โœ… supported ยท โ— partial ยท โŒ not supported ยท [n] see note. Generated from MDN browser-compat-data and web-features. caniuse: Window.print

Exampleโ€‹

import { isPrintAvailable, printPage, printElementById } from '@rtorcato/browser-common/print'

if (isPrintAvailable()) {
printPage()
printElementById('receipt')
}

Exportsโ€‹

  • printPage() โ€” triggers the browser's print dialog
  • printElementById(elementId) โ€” opens a new window with the element's content and prints it
  • isPrintAvailable() โ€” feature check

See the API reference for full signatures.