print combine plain text, html, image

579 views
Skip to first unread message

mk.anwa...@gmail.com

unread,
Jun 15, 2016, 10:21:42 PM6/15/16
to qz-print
Hi,
it is possible to combine plain text, html and image in qz.print()?

function queueNumberC(num){
var config = getUpdatedConfig();
var printData = [
'DEVELOPMENT UNIT\n',
{ type: 'image', data: 'assets/img/moh.png' },
'\n\n',
'Your Number:',
'\n',
{ type: 'html', format: 'plain', data: '<h2>'+num+'</h2>' },
'\n\n',
'Please take a seat. You will serve later.',
'\n\n'
];

qz.print(config, printData).catch(displayError);
}

Tres Finocchiaro

unread,
Jun 15, 2016, 10:30:31 PM6/15/16
to mk.anwa...@gmail.com, qz-print
We have a few users whom have claimed this worked back on 1.9, so it should still work in theory, yes.  Some notes... 
  • The HTML data should start and end with valid HTML tags
  • The plain text is often driver dependent and requires the printer to be configured for a raw driver whereas the image and html would require the device driver.  There are exceptions to this (ZDesigner on Windows) so mileage may vary.
If you have a particular device you're testing with, let us know and we'll try to reproduce.

Best regards,

--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mk.anwa...@gmail.com

unread,
Jun 15, 2016, 10:44:40 PM6/15/16
to qz-print, mk.anwa...@gmail.com
On Thursday, June 16, 2016 at 10:30:31 AM UTC+8, Tres Finocchiaro wrote:
> We have a few users whom have claimed this worked back on 1.9, so it should still work in theory, yes.  Some notes... 
> The HTML data should start and end with valid HTML tagsThe plain text is often driver dependent and requires the printer to be configured for a raw driver whereas the image and html would require the device driver.  There are exceptions to this (ZDesigner on Windows) so mileage may vary.
>
> If you have a particular device you're testing with, let us know and we'll try to reproduce.
>
>
> Best regards,
>
>
>
>
> - Tres.Fin...@gmail.com
>
>
> On Wed, Jun 15, 2016 at 10:21 PM, <mk.anwa...@gmail.com> wrote:
> Hi,
>
> it is possible to combine plain text, html and image in qz.print()?
>
>
>
>     function queueNumberC(num){
>
>         var config = getUpdatedConfig();
>
>         var printData = [
>
>                 'DEVELOPMENT UNIT\n',
>
>                 { type: 'image', data: 'assets/img/moh.png' },
>
>                 '\n\n',
>
>                 'Your Number:',
>
>                 '\n',
>
>                 { type: 'html', format: 'plain', data: '<h2>'+num+'</h2>' },
>
>                 '\n\n',
>
>                 'Please take a seat. You will serve later.',
>
>                 '\n\n'
>
>         ];
>
>
>
>         qz.print(config, printData).catch(displayError);
>
>    }
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "qz-print" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Currently I test using Bixolon SRP-350II and I set directy using Host. The result when I print as follow:

DEVELOPMENT UNIT
http://localhost/qr/assets/img/moh.png

Your Number:
<h2>2207</h2>

Tres Finocchiaro

unread,
Jun 15, 2016, 10:48:38 PM6/15/16
to mk.anwa...@gmail.com, qz-print
  http://localhost/qr/assets/img/moh.png
  Your Number:
  <h2>2207</h2>
  Please take a seat. You will serve later.

That takes the same size paper as our Epsons, so we can try it out.

Another thing I forgot to mention is that if the device driver is set to auto-cut it can cause some grief as well in the mixed scenarios.

We'll take a swing at it and report back.

Tres Finocchiaro

unread,
Jun 15, 2016, 10:49:14 PM6/15/16
to mk.anwa...@gmail.com, qz-print
Which OS by the way?

mk.anwa...@gmail.com

unread,
Jun 15, 2016, 10:52:24 PM6/15/16
to qz-print, mk.anwa...@gmail.com
I'm using Windows 7

Lite Finocchiaro

unread,
Jun 23, 2016, 10:35:24 PM6/23/16
to mk.anwa...@gmail.com, qz-print
Below is my code, which prints html, then an image, then ESCP.

Note: The ESCP block of code is set to 'altPrinting:true' because I use Linux and CUPS to test my code. This allows me to send the raw data to an otherwise pixel-based queue. Windows will ignore this value as it only applies to CUPS, but if you are serving across multiple operating systems, it can be very helpful. 

Note2: I also modified my Epson-TM-BA-Thermal queue NOT to cut the paper, as this would result in a cut after the HTML print job and another cut after the IMAGE print job.

Note3: You may have to use two print queues to achieve your results, as not all drivers have both RAW and Pixel-based (PostScript/PPD/PCL) in one driver (CUPS usually requires a different driver for each task, for example). Windows drivers tend have support for both types of print jobs in the same driver, however.

This has been modified from the sample.html file that normally ships with QZ-Tray 2.0.0. As always, if you have any questions, feel free to reach out to us, and we'll do our best to answer them!

Code:

function printESCP() {
        var config = qz.configs.create("Epson-TM-BA-Thermal");
        var data = [{
        type: 'html',
        format: 'plain', // or 'plain' if the data is raw HTML
        data: ' <html><header><title>This is the title</title></header><body>Hello world</body></html>'
        }];
        qz.print(config, data)

       .then(function() {
            var config = qz.configs.create("Epson-TM-BA-Thermal");
            var data = [{
                type: 'image',
                data: 'assets/img/image_sample.png'
            }];
            return qz.print(config, data);
        })
   

        .then(function() {       
            var config = qz.configs.create("Epson-TM-BA-Thermal",{altPrinting:true});
            var printData = [
                '\x1B' + '\x40', // init
                '\x1B' + '\x61' + '\x31', // center align
                'Canastota, NY  13032' + '\x0A',
                '\x0A', // line break
                'www.qzindustries.com' + '\x0A', // text and line break
                '\x0A', // line break
                '\x0A', // line break
                'November 21, 2015 3:09 PM' + '\x0A',
                '\x0A', // line break
                '\x0A', // line break        
                '\x0A',
                'Transaction # 123456 Register: 3' + '\x0A',        
                '\x0A',        
                '\x0A',        
                '\x0A',
                '\x1B' + '\x61' + '\x30', // left align
                'Baklava (Qty 4)                     9.00' + '\x1B' + '\x74' + '\x13' + '\xAA', //print special character symbol after numeric value
                '\x0A',
                'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' + '\x0A',        
                '\x1B' + '\x45' + '\x0D', // bold on
                'Here\'s some bold text!',
                '\x1B' + '\x45' + '\x0A', // bold off
                '\x0A' + '\x0A',
                '\x1B' + '\x61' + '\x32', // right align
                '\x1B' + '\x21' + '\x30', // em mode on
                'DRINK ME',
                '\x1B' + '\x21' + '\x0A' + '\x1B' + '\x45' + '\x0A', // em mode off
                '\x0A' + '\x0A',
                '\x1B' + '\x61' + '\x30', // left align
                '------------------------------------------' + '\x0A',
                '\x1B' + '\x4D' + '\x31', // small text
                'EAT ME' + '\x0A',
                '\x1B' + '\x4D' + '\x30', // normal text
                '------------------------------------------' + '\x0A',
                'normal text',
                '\x1B' + '\x61' + '\x30', // left align
                '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A',
                '\x1B' + '\x69', // cut paper

            ];
            return qz.print(config, printData);
       
        });
       
}


Kind regards,

Lite Finocchiaro
Reply all
Reply to author
Forward
0 new messages