mirror of
https://github.com/anikeen-com/print-utils.git
synced 2026-03-13 05:36:06 +00:00
23 lines
530 B
JavaScript
23 lines
530 B
JavaScript
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();
|
|
} |