qz print 1.8 | TSC, TTP 244 | Prints block of numbers

62 views
Skip to first unread message

mike....@incompassmedical.com

unread,
Sep 23, 2014, 12:53:02 PM9/23/14
to jzebra...@googlegroups.com
I have setup qz print for the TSC printer TTP 244 Plus I can connect and send print jobs to it but all I get is a label with a block of hex numbers and a column of text on the left. Image attached.

This is the javascript I am using to send the print job

function getLabels() {
    $.ajax({
        url: "{{ app.request.uriForPath('/surgeries') }}",
        dataType: "json",
        success: function(data) {
            var labelZPL = '';
            var listClass = 'list-group-item list-group-item-';
            var listMessage = '';
            $.each(data, function(index,elem){
                labelZPL += '^CF0,40\n';
                labelZPL += '^FO20,15^FDCaseCheck^FS\n';
                labelZPL += '^CFA,15\n';
                labelZPL += '^FO20,60^FDFri, Sep 19, 2 pm^FS\n';
                labelZPL += '^FO20,80^FDSurgeon: Dr. '+elem.surgeon.given_name+' '+elem.surgeon.family_name+'^FS\n';
                labelZPL += '^FO20,100^FDKnee^FS\n';
                labelZPL += '^FO20,120^FDSystem Y^FS\n';
                labelZPL += '^FO20,150^GB120,10,45,1,3^FS\n';
                labelZPL += '^CF0,40\n';
                labelZPL += '^FO40,150^FR^FDHOLD!^FS\n';
                labelZPL += '^BY3,2,140\n';
                labelZPL += '^FO320,20^BC^FD1234567890^FS\n';

                result = printZPL("Casechek1",labelZPL);
                if( result === true ) {
                    listClass += 'success';
                    listMessage = 'printed ' + elem.surgery.id;
                } else {
                    listClass += 'danger';
                    listMessage = result;
                }

                $("#surgeries").append(
                    $('<li>').attr('class', listClass).append(listMessage)
                );
            });
            
        }
    });
}

and these are my modified functions in qzindustries.js

/**
 * Returns whether or not the applet is not ready to print.
 */
function notReady() {
    if( !qz.getPrinter() ) {
        return 'Printer is Not Ready, please refresh the page and try again.';
    } else {
        return false;
    }
}

/**
 * Returns is the applet is not loaded properly
 */
function isLoaded() {
    if (!qz) {
        return 'Error: Print plugin is NOT loaded!';
    } else {
        try {
            if (!qz.isActive()) {
                return'Error: Print plugin is loaded but NOT active!';
            }
        } catch (err) {
            return 'Error: Print plugin is NOT loaded properly!';
        }
    }
    return false;
}

/**
 * Prototype function for printing raw ZPL commands
 */
function printZPL(printerName, data) {
    var errorMessage = isLoaded();
    if( !errorMessage ) {
        qz.findPrinter(printerName);
        window['qzDoneFinding'] = function() {
            // Check Printer is ready
            errorMessage = notReady();
            if( !errorMessage ) {
                qz.append('^XA\n');
                qz.append(data);
                qz.append('^XZ\n');
                qz.print();
                return true;
            } else {
                return errorMessage;
            }
        };
    } else {
        return errorMessage;
    }
}

image.jpg

Tres Finocchiaro

unread,
Sep 23, 2014, 1:28:52 PM9/23/14
to jZebra users
Well, for multiple labels, you should not call qz.print() in succession, but rather wait for qzDonePrinting to be fired first.  Most people use the spooling feature for this so that print() only needs to be called once. (setDocumentsPerSpool(...), setEndOfDocument(...);, etc)

But I don't think that is your issue.  Your label seems to contain invalid code (such as JavaScript?) suggesting you are appending the wrong data.

I would recommend alert(data) in your printZPL function, but get it working for a single label first before doing multiple labels as you will create a race condition in you current logic.
-Tres

--
--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra

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

Reply all
Reply to author
Forward
0 new messages