|
@@ -1,5 +1,5 @@
|
|
|
import UUID from 'uuid/v4'
|
|
|
-import { printDirect, getPrinters, getDefaultPrinterName, getJob, getSupportedJobCommands, getSupportedPrintFormats } from 'printer'
|
|
|
+import { printDirect, getPrinters, getDefaultPrinterName, getJob, getSupportedPrintFormats } from 'printer'
|
|
|
|
|
|
const REQUEST_PRINTER_NAME = 'request_printer_name'
|
|
|
const SHOW_PRINT_STATUS = 'show_print_status'
|
|
@@ -104,6 +104,22 @@ const doPrint = (socket, request) => {
|
|
|
}
|
|
|
|
|
|
let format = getFormat(mimeTypeRegex[0])
|
|
|
+
|
|
|
+ const supportedFormats = getSupportedPrintFormats(request.printer)
|
|
|
+
|
|
|
+ if (!supportedFormats.includes(format)) {
|
|
|
+ socket.emit(SHOW_PRINT_STATUS, {
|
|
|
+ status: 'error',
|
|
|
+ printer: request.printer,
|
|
|
+ cause: {
|
|
|
+ id: 'unsupported_format',
|
|
|
+ error: null
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
let buffer = Buffer.from(data, 'base64')
|
|
|
|
|
|
printDirect({
|