This commit is contained in:
Skylar Grant 2024-09-09 13:41:14 -04:00
parent b0d163f07e
commit 12fd3ed9f3

View File

@ -27,7 +27,7 @@ module.exports = {
// Create a new PDF document // Create a new PDF document
const doc = new PDFDocument({ const doc = new PDFDocument({
size: [204, 1000], size: [204, 400],
margin: 5 margin: 5
}); });
@ -69,15 +69,7 @@ module.exports = {
// Handle the process exit event // Handle the process exit event
printer.on('close', (code) => { printer.on('close', (code) => {
if (code === 0) { if (code === 0) {
// Delete the file after printing to clean up res.send('PDF sent to printer successfully.');
fs.unlink(pdfFilePath, (err) => {
if (err) {
console.error('Error deleting file:', err);
res.status(500).json({ message: 'Failed to clean up after printing', error: err.message });
return;
}
res.send('PDF sent to printer successfully.');
});
} else { } else {
res.status(500).json({ message: 'Failed to print PDF' }); res.status(500).json({ message: 'Failed to print PDF' });
} }