v147 · JavaScript API · Isolated Web Apps
Compatibility Lab
Probes navigator.printing (Isolated Web Apps only), window.print(), and the fallback capability chain. Runs a live detection of IWA context and print API availability, and provides the feature-detection waterfall from Web Printing API down to window.print().
API probes
Print API capability matrix
| API | Context | Printer selection | Job config | Status events |
|---|---|---|---|---|
| navigator.printing (Web Printing) | IWA only | ✓ programmatic | ✓ full IPP config | ✓ event-driven |
| window.print() | Any origin | ✗ user dialog | ✗ no API control | ✗ none |
| CSS @media print | Any origin | ✗ user dialog | ✗ CSS only | ✗ none |
| beforeprint / afterprint events | Any origin | ✗ user dialog | ✗ no API control | ✓ basic lifecycle |
Live API detection
Print API availability probe
Click "Run probe" to check Web Printing API availability…
Feature-detection waterfall
/* Web Printing API — feature detection waterfall */
async function getPrintCapabilities() {
/* Tier 1: Web Printing API (IWA only — Chrome 147+) */
if ('printing' in navigator) {
const printers = await navigator.printing.getPrinters();
if (printers.length > 0) {
const attrs = await printers[0].getAttributes();
return {
api: 'web-printing',
printers: printers.length,
defaultPrinterAttributes: attrs,
};
}
}
/* Tier 2: window.print() with print lifecycle events */
if (typeof window.print === 'function') {
return {
api: 'window.print',
printers: 'unknown — user dialog',
beforeprint: typeof window.onbeforeprint !== 'undefined',
afterprint: typeof window.onafterprint !== 'undefined',
};
}
/* No print support */
return { api: 'none' };
}
/* Web Printing API — full job submission (IWA) */
async function printDocument(content) {
if (!('printing' in navigator)) {
window.print(); // fallback
return;
}
const printers = await navigator.printing.getPrinters();
const printer = printers[0];
const attrs = await printer.getAttributes();
// IPP job configuration
await printer.printJob('my-job', content, {
copies: 1,
orientation: 'portrait',
mediaSize: attrs['media-supported']?.[0] ?? 'iso-a4',
colorMode: 'monochrome',
duplex: 'one-sided',
});
}
/* CSS print media approach — always available */
window.addEventListener('beforeprint', () => {
document.body.classList.add('printing');
});
window.addEventListener('afterprint', () => {
document.body.classList.remove('printing');
});
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗