sample code for printing a barcode to a locally attached GK420D from a PHP / Laravelle application?

hi there,

I'm creating a web-based PHP app in Laravelle where I want to generate a barcode (could be either 1D or 2D) for a serial number and then print that to a GK420D.  The printer is actually locally attached to a Windows PC where this app is running in Chrome.

 

I've seen references to Browser Print as well as to this program:  GitHub - qzind/tray: Browser plugin for sending documents and raw commands to a printer or attached device.

I'm interested in any suggestions, sample code or guideline recommendations.  

 

Thanks in advance!

Peter

Manuel Caicedo-...
Hi Peter,Are you connecting

Hi Peter,

Are you connecting the printer through USB or Network to a client PC?

MC

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Peter Bohnert
Printer is connected via USB.

Printer is connected via USB.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Manuel Caicedo-...
Hi Peter,The solution for

Hi Peter,

The solution for this case is to use Browser Printer. Browser Print works on the front end, it does not matter if you work with PHP, Java, or .Net. Browser Print works with JavaScript. For more info, please, review the blog below.

Thanks,

MC

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Peter Bohnert
thank you Manuel!  Very much

thank you Manuel!  Very much appreciated.

Looking over the sample code, do I read this write that I don't need to worry about generating a barcode image but rather could use the ZPL code in the sample - something like:

var format_start = "! U1 setvar \"device.languages\" \"zpl\"\r\n ^XA^LL200^FO80,50^A0N36,36^FD";

var format_end = "^FS^XZ";

checkPrinterStatus( function (status) {

             if (status == "Ready to Print") {

                            selected_printer.send(format_start + $('#entered_name').val() + format_end, printComplete, printerError);

                  } else { printerError(text); }

and if true, then I assume that #entered_name variable  would be whatever serial number or data I wish to barcode.

Am I understanding that right?

Thanks again!

Peter

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Manuel Caicedo-...
Hi Peter,No, you do not need

Hi Peter,

No, you do not need to worry to use images for barcode anymore because you can send ZPL directly to the printer as the sample shows. We normally recommend use our ZPL commands to generate the barcode for best practices.

You are free to modify the sample code, it is just a simple guide for using, and for getting the flavor of the solution.

#entered_name is used as simple as to put a name for the sample label used for this sample code.

On top of the javascript library "format_start" and "format_end" define the ZPL label, #entered_name is a embedded variable to include on the fly to the label.

You can create as many variables you want and add these in running time with the power of JavaScript.

Thanks,

MC

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments