-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Printing mixed content in the correct order #392
Comments
@tresf and I wrote this sample a while ago (on 2.0), but the concept should be the same; ESCP (ESCPOS in this case) content will race ahead of HTML content if processed concurrently, as JavaFX has to process the HTML, then the Epson driver has to process the raster image, but the ESCP will go straight to the printer and get processed by the printer's firmware. Please note: I use "altPrinting: true" for ESCPOS, because on Linux, the TM_BA driver is usually only used for Pixel printing (HTML/Image/PDF). We tried sending mixed content to two different queues (one raw, one pixel), and the ESCPOS content arrived to the printer first every time. https://gist.github.com/lite1979/30cb2c6d5ea50fd8a59a6effe837e882 |
Could you elaborate a bit what is the important difference with my approach what makes that it doesn't work? I'm actually also chaining different 'then' blocks the same as in the provided example. I'm running it on a Windows environment so I guess the altPrinting thing doesn't apply to my situation? Thanks |
Correct sorry for the confusion Lite's example using Windows has a separate problem. Its spooler thinks it's smarter than you and in doing so, it processes faster jobs over slower jobs. The only way around this is to turn off the local spooling feature. I believe this will fix your problem. Note, with 2.1 we've added a new feature to rasterize the HTML and inject it into the ESC/POS commands. This would also solve the problem and is the reason the API has changed. We don't have the wiki updated yet, but this bug report #19 combined with the 2.1 sample.html will get you further if you'd like to try it out.
The API between 2.0 and 2.1 has changed, so it's important any bugs reports stick to one version and one version only -- especially the syntax. 2.0 has no such configuration option
No, this is not needed.
This suggests that it's stuck in |
Hi @tresf, I'm actually using a 2.1.0-RC5 build. I tried changing the printer drivers to this. The screenshot is in Dutch but the options are ofc the same as your English example ;) When I try printing afterwards unfortunately I get some unclear error :/ (it printed the logo and the QR code, nothing else) P.S. I get the following output in the logs
|
I also think rasterizing the HTML wouldn't work for me. const config = qz.configs.create('Labelprinter', {
scaleContent: false,
rasterize: false,
margins: {
right: 0.10,
left: 0.10
}
}) If I didn't set rasterize to false the printed HTML does get extremely blurry and unreadable. When I set it to rasterize: false it is ok. |
The config option
I'm not sure what that message means. Directly spooling should affect the speed and order of printing , not the reliability of the driver or output. We can install that driver and attempt to reproduce but it will be some time. |
Here's my working code snippet. This works for me on macOS and Windows (QZ Tray 2.1.0-RC5.6) The main caveat is that I don't know how to disable auto-cutting on macOS, so all of my macOS receipts have a slice between the HTML and the QR code. Another caveat, Windows centers the HTML content whereas macOS left-aligns it. I'm not sure why this happens. It's either a nuance with the driver or a bug with the 2.1 HTML printing. Setting up the custom page and HTML document size didn't seem to help but I've left the code commented just incase it comes in handy. In regards to the Citizen driver not allowing direct printing, that is not typical and should work just fine with most drivers. Below is a screenshot of my results. My testing was done using an Epson TM-T88VI. /////
///// RAW, altPrinting to overrides CUPS driver
/////
var cfg1 = qz.configs.create("Epson TM-T88VI", { altPrinting: true });
var data1 = [
'\n\n\n\n\n\n\n\n', // feed
'\x1B\x61\x31', // center align
{ type: 'raw', format: 'image', data: 'assets/img/image_sample_bw.png', options: { language: 'ESCPOS', dotDensity: 'double' } }
];
/////
///// HTML, disable altPrinting for macOS / Linux
/////
var cfg2 = qz.configs.create("Epson TM-T88VI", { margins: { left: 2.5 /* mm */}, /* size: { width: 80, height: 297 }, */ units: 'mm' } /*, { altPrinting: false }*/);
var data2 = [
{ type: 'pixel', format: 'html', flavor: 'plain', data: '<html><h1><i>HTML STUFF!</i></h1></html>' /*, pageWidth: 80 */ /* mm */ }
];
/////
///// RAW, altPrinting to overrides CUPS driver
/////
var cfg3 = cfg1;
var qr = '123456';
var dots = '\x05'; /**/ var size1 = String.fromCharCode(qr.length + 3); /**/ var size0 = '\x00';
var data3 = [
'\x1B\x61\x31', // center align
// <!-- BEGIN QR DATA -->
'\x1D\x28\x6B\x04\x00\x31\x41\x32\x00',
'\x1D\x28\x6B\x03\x00\x31\x43' + dots,
'\x1D\x28\x6B\x03\x00\x31\x45\x30',
'\x1D\x28\x6B' + size1 + size0 + '\x31\x50\x30' + qr,
'\x1D\x28\x6B\x03\x00\x31\x51\x30',
'\x1D\x28\x6B\x03\x00\x31\x52\x30',
// <!-- END QR DATA -->
'\n\n\n\n\n\n\n\n' // feed
];
qz.print([cfg1, cfg2, cfg3], [data1, data2, data3]).catch(err => console.error(err)); |
Hi @tresf, thanks for the update. Just for testing purposes I actually copy/pasted your code sample and just replaced the printer name with mine. Tried printing but that throws the following error.
Any idea? |
@lorro, that's weird. I was getting that error when I tried to clone my configs (the objects are mutable and I was attempting to use I assume you're using exactly matched versions of QZ Tray and qz-tray.js? |
Oh fuck, seems I'm still using the 2.0.8 browser plugin. Is there a way to pull version 2.1.0 through npm?
|
|
Ok I understand. So I just updated the file manually to see what happens now. qz.print([config, config, config], [
getReceiptLogo(this.localReceipt),
getReceiptHtml(this.localReceipt),
getReceiptQR(this.localReceipt)
]) But still the QR gets printed above the logo, so that issue remains :) |
Yeah, this driver goes haywire when I click that radio button. I'm not sure why it does this, but it's not a problem with QZ Tray as far as I can tell. It actually sends my print spooler into panic and pegs it at I was able to reproduce the At this point, I'm not sure the best recourse. The racing issue appears to be OS related and the only viable workaround that we have is incompatible with the driver you're using. You may find luck by forcing a better driver (such as the Epson TM-T88 series) driver but using a 3rd party driver can be harmful to the hardware. The last recommendation is to use the HTML->Raw feature which was proposed earlier. To get an understanding of the quality, you can use the |
One last item is to use a supported 3rd party driver such as Seagull Scientific. I'm not sure how well this works with raw prints. Note, we did reach out to Seagull Scientific several times in the past and they were unwilling to talk to us without a subscription, but we've had several clients switch to them for specific needs over the years. |
I'm afraid our printer model (CT-S310II) isn't supported by the Seagull drivers. |
I'm going to close this out as QZ Tray appears to be functioning fine. Please keep us posted as to your progress. |
Hi,
I'm encountering a new issue with the following. I want to print an order receipt with a logo, the order details in html and a QR code that contains the order number. In that order. The problem is the QR code get printed before everything else in the header, while I want it displayed in the footer.
I've got it set up like this
I've also tried this as setup as I read it was part of the API in version 2.1:
But that just prints the QR in the header and a bunch of unprocessed html :)
Do you guys have any idea what I could be doing wrong?
Thanks!
The text was updated successfully, but these errors were encountered: