Add README.md

Add windows support
This commit is contained in:
René Preuß
2024-01-21 16:07:29 +01:00
parent 2a92c22bec
commit e60f6ec846
4 changed files with 95 additions and 348 deletions

23
print.js Normal file
View 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();
}