unix-print
Advanced tools
Comparing version 1.3.0-beta.1 to 1.3.0
{ | ||
"name": "unix-print", | ||
"version": "1.3.0-beta.1", | ||
"version": "1.3.0", | ||
"description": "Utility for Unix-like operating systems to print PDF files from Node.js and Electron", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -17,3 +17,4 @@ # Unix-print | ||
- [API](#api) | ||
- [`print(pdf, printer, options) => Promise<void>`](#printpdf-printer-options--promisevoid) | ||
- [`print(pdf, printer, options) => Promise<{stdout, stderr}>`](#printpdf-printer-options--promisevoid) | ||
- [`isPrintComplete(printResponse) => Promise<boolean>`](#isprintcompleteprintresponse--promiseboolean) | ||
- [`getPrinters() => Promise<Printer[]>`](#getprinters--promiseprinter) | ||
@@ -65,3 +66,3 @@ - [`getDefaultPrinter() => Promise<Printer | null>`](#getdefaultprinter--promiseprinter--null) | ||
`Promise<void>`. | ||
`Promise<{stdout: string | null, stderr: string | null}>`. | ||
@@ -99,2 +100,33 @@ To print a file to the default printer: | ||
### `isPrintComplete(printResponse) => Promise<boolean>` | ||
**Arguments** | ||
| Argument | Type | Optional | Description | | ||
| ------------- | :---------------------------------------: | -------- | ------------------------------ | | ||
| printResponse | <code>{stdout: string | null}</code> | Required | Promise returned from [`print`](#printpdf-printer-options--promisevoid). | | ||
**Returns** | ||
`Promise<boolean>`: False if the job is on the queue or `stdout` is null, true otherwise. | ||
**Examples** | ||
```javascript | ||
import { isComplete } from 'unix-print'; | ||
const fileToPrint = 'assets/file.pdf'; | ||
const printJob = print(fileToPrint); | ||
async function waitForPrintCompletion(printJob) { | ||
while (!await isPrintComplete(printJob)) { | ||
// Wait a bit before checking again (to avoid constant checks) | ||
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for 1 second | ||
} | ||
console.log('Job complete'); | ||
} | ||
await waitForPrintCompletion(printJob); | ||
``` | ||
### `getPrinters() => Promise<Printer[]>` | ||
@@ -101,0 +133,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
14305
0
160