?
This commit is contained in:
parent
45d7b10db7
commit
4ddbab45ea
@ -49,20 +49,11 @@ module.exports = {
|
|||||||
// Handle error if the printing process fails
|
// Handle error if the printing process fails
|
||||||
printer.on('error', (err) => {
|
printer.on('error', (err) => {
|
||||||
console.error('Failed to start printing process:', err);
|
console.error('Failed to start printing process:', err);
|
||||||
res.status(500).send('Failed to start printing process');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Pipe the PDF data to the printer
|
// Pipe the PDF data to the printer
|
||||||
printer.stdin.write(pdfData);
|
printer.stdin.write(pdfData);
|
||||||
|
printer.stdin.end();
|
||||||
// Handle the process exit event
|
|
||||||
printer.on('close', (code) => {
|
|
||||||
if (code === 0) {
|
|
||||||
res.send('PDF sent to printer successfully.');
|
|
||||||
} else {
|
|
||||||
res.status(500).send('Failed to print PDF');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add content (image, text) to the PDF
|
// Add content (image, text) to the PDF
|
||||||
|
Loading…
Reference in New Issue
Block a user