This commit is contained in:
parent
06792727ef
commit
9bda14b401
|
@ -172,14 +172,13 @@ class PrintServer {
|
||||||
fs.mkdirSync(tmpPath)
|
fs.mkdirSync(tmpPath)
|
||||||
const tmpFilePath = path.join(tmpPath, `${Math.random().toString(36).substring(7)}.pdf`);
|
const tmpFilePath = path.join(tmpPath, `${Math.random().toString(36).substring(7)}.pdf`);
|
||||||
await fs.writeFile(tmpFilePath, pdfData, 'binary');
|
await fs.writeFile(tmpFilePath, pdfData, 'binary');
|
||||||
const printCommand = `p -d "${printer}" "${tmpFilePath}"`;
|
|
||||||
|
|
||||||
// Print PDF
|
// Print PDF
|
||||||
try {
|
try {
|
||||||
await pExec(printCommand);
|
await pExec(`lp -d "${printer}" "${tmpFilePath}"`);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
await fs.unlink(tmpFilePath);
|
await fs.unlink(tmpFilePath);
|
||||||
throw new Error(`Print error: '${printCommand}': ${err.message}`);
|
throw new Error(`Print error: ${err.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await conn.query(updateQuery, ['printed', null, jobId]);
|
await conn.query(updateQuery, ['printed', null, jobId]);
|
||||||
|
|
Loading…
Reference in New Issue