forked from Alexssmusica/printer-electron-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteste.js
More file actions
37 lines (32 loc) · 1.02 KB
/
Copy pathteste.js
File metadata and controls
37 lines (32 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { getPrinters, getDefaultPrinter, printDirect, getStatusPrinter } = require('./lib/');
// Testando listagem de impressoras
getPrinters().then((printers) => {
console.log('Impressoras disponíveis:', printers);
}).catch((error) => {
console.error('Erro ao listar impressoras:', error);
});
// Testando impressora padrão
getDefaultPrinter().then((printer) => {
console.log('Impressora padrão:', printer);
}).catch((error) => {
console.error('Erro ao obter impressora padrão:', error);
});
// Testando impressão
const options = {
printerName: 'HP508140D7C039(HP Laser MFP 131 133 135-138)',
data: 'Hello, world!',
dataType: 'RAW'
};
/***
printDirect(options).then((resp) => {
console.log(resp);
}).catch(console.error);
*/
// Testando status da impressora
getStatusPrinter({ printerName: 'HP508140D7C039(HP Laser MFP 131 133 135-138)' })
.then((printerInfo) => {
console.log('Status da impressora:', printerInfo);
})
.catch((error) => {
console.error('Erro ao obter status da impressora:', error);
});