mirror of
https://github.com/anikeen-com/print-utils.git
synced 2026-03-13 13:46:07 +00:00
Add README.md
Add windows support
This commit is contained in:
23
print.js
Normal file
23
print.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { platform } from 'os';
|
||||
import * as windowsMethods from 'pdf-to-printer';
|
||||
import * as linuxMethods from 'unix-print';
|
||||
|
||||
let methods;
|
||||
|
||||
if (platform() === 'win32') {
|
||||
methods = windowsMethods.default;
|
||||
} else {
|
||||
methods = linuxMethods.default;
|
||||
}
|
||||
|
||||
export const print = async (file, printer) => {
|
||||
if (platform() === 'win32') {
|
||||
return await methods.print(file, {printer});
|
||||
}
|
||||
|
||||
return await methods.print(file, printer);
|
||||
}
|
||||
|
||||
export const getPrinters = async () => {
|
||||
return await methods.getPrinters();
|
||||
}
|
||||
Reference in New Issue
Block a user