* Add roll printing sample * Copied heavily from existing printing sample * Changed functionality from existing printing sample as follows: * Only display printers that support roll printing * In table, create a row for each unique width for each printer * Fix wording in README * Update readme to list a milestone for bug to get fixed * Update api-samples/printing/roll-printing/README.md Co-authored-by: Joe Medley <jmedley@google.com> * Update api-samples/printing/README.md Co-authored-by: Joe Medley <jmedley@google.com> * Convert a function call to a promise. * Clean up a few errors setting element IDs. Remove the main cancel button that is no longer used. Instead, the cancel button that gets created in the print job table is the one that should be used. * Consolidate the roll-printing sample with the regular sample There is now a checkbox on the main UI to select roll printers or all printers. For roll printing, this sample now demonstrates how to check if the printer is capable of roll printing, if the printer is capable of trimming the paper after printing, and how the media length can be a variable value. * Update api-samples/printing/README.md Co-authored-by: Oliver Dunk <oliver@oliverdunk.com> * Update api-samples/printing/printers.js Co-authored-by: Oliver Dunk <oliver@oliverdunk.com> * Simplify fuction to use find instead of filter Update README to link to roll printing info. * Use new page instead of popup * Update api-samples/printing/README.md Co-authored-by: Joe Medley <jmedley@google.com> --------- Co-authored-by: Joe Medley <jmedley@google.com> Co-authored-by: Oliver Dunk <oliver@oliverdunk.com>
1.2 KiB
chrome.printing
This sample demonstrates all four methods of the chrome.printing namespace.
Overview
The chrome.printing namespace only works on ChromeOS. The sample demonstrates how to get a list of available printers and display it to a user. A 'Print' button sends a sample PDF to the selected printer and makes a 'Cancel Printing' visible. This button is visible while the print job's status is "PENDING" or "IN_PROGRESS". Note that on some systems, the print job is passed to the printer so quickly that you may never see the 'Cancel Printing' button.
Calling submitJob() triggers a dialog box asking the user to confirm printing. Use the PrintingAPIExtensionsAllowlist policy to bypass confirmation.
If the Roll Printers checkbox is selected, only printers capable of roll printing will appear in the table. In this case, a separate test file is printed and the height of the media can be variable. See Roll printing for more information.
Implementation Notes
Before Chrome 120, submitJob() function throws an error when returning a promise.