Printers
Methods
Attempts to print the web page.
await window.deskifier.printers.print({ arguments })
Arguments
windowIdString (Optional)
The ID of the window to print. Defaults to the current window.silentBoolean (Optional)
Don't ask user for print settings. Default isfalse.printBackgroundBoolean (Optional)Prints the background color and image of the web page. Default is
false.deviceNameString (Optional)
Set the printer device name to use. Must be the system-defined name and not the 'friendly' name, e.g 'Brother_QL_820NWB' and not 'Brother QL-820NWB'.colorBoolean (Optional)Set whether the printed web page will be in color or grayscale. Default is
true.marginsObject (Optional)marginTypeStringCan be
default,none,printableArea, orcustom. Ifcustomis chosen, you will also need to specifytop,bottom,left, andright.topNumber
The top margin of the printed web page, in pixels.bottomNumber
The bottom margin of the printed web page, in pixels.leftNumber
The left margin of the printed web page, in pixels.rightNumber
The right margin of the printed web page, in pixels.
landscapeBoolean (Optional)
Whether the web page should be printed in landscape mode. Default isfalse.scaleFactorNumber (Optional)
The scale factor of the web page.pagesPerSheetNumber (Optional)
The number of pages to print per page sheet.collateBoolean (Optional)
Whether the web page should be collated.copiesNumber (Optional)
The number of copies of the web page to print.pageRangesArray of Objects (Optional)
The page range to print. On macOS, only one range is honored.fromNumber
Index of the first page to print (0-based).toNumber
Index of the last page to print (inclusive) (0-based).
duplexModeString (Optional)
Set the duplex mode of the printed web page. Can besimplex,shortEdge, orlongEdge.dpiObject (Optional)horizontalNumber
The horizontal dpi.verticalNumber
The vertical dpi.
headerString (Optional)
string to be printed as page header.footerString (Optional)
string to be printed as page footer.pageSizeString (Optional)
Specify page size of the printed document. Can beA0,A1,A2,A3,A4,A5,A6,Legal,Letter,Tabloidor an Object containingheightandwidth.
Returns
successBoolean
If the action was successful. If the user cancels the print, this will return false.messageString
Additional confirmation, or error details if action was unsuccessful.
Example
const result = await window.deskifier.printers.print({ windowId: 'main' });
console.log(result.success); // true
Print To PDF
Attempts to create a PDF from the web page.
await window.deskifier.printers.printToPdf({ arguments })
Arguments
windowIdStringThe ID of the window to print. Defaults to the current window.
filePathString (Required)
The path to save the PDF file to.landscapeBoolean (Optional)
Paper orientation.truefor landscape,falsefor portrait. Defaults to false.displayHeaderFooterBoolean (Optional)
Whether to display header and footer. Defaults to false.printBackgroundBoolean (Optional)
Whether to print background graphics. Defaults to false.scaleNumber (Optional)
Scale of the webpage rendering. Defaults to 1.pageSizeString (Optional)
Specify page size of the generated PDF. Can beA0,A1,A2,A3,A4,A5,A6,Legal,Letter,Tabloid,Ledger, or an Object containingheightandwidthin inches. Defaults toLetter.marginsObject (Optional)topNumber
Top margin in inches. Defaults to 1cm (~0.4 inches).bottomNumber
Bottom margin in inches. Defaults to 1cm (~0.4 inches).leftNumber
Left margin in inches. Defaults to 1cm (~0.4 inches).rightNumber
Right margin in inches. Defaults to 1cm (~0.4 inches).
pageRangesString (Optional)
Page ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.headerTemplateString (Optional)
HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:date(formatted print date),title(document title),url(document location),pageNumber(current page number) andtotalPages(total pages in the document). For example,<span class=title></span>would generate span containing the title.footerTemplateString (Optional)
HTML template for the print footer. Should use the same format as theheaderTemplate.preferCSSPageSizeBoolean (Optional)
Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.pathString
The file path of the saved PDF.
Properties
Get Printers
Returns all printers connected to the device.
await window.deskifier.printers.getAll()
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.printersArray of si.Printer