Print sticker / barcode label directly from browser to printer (zebra)

We have to follow the situation, for one of our clients we are looking for a solution. He created a PHP script that generates a label with some information and barcodes on it, so the workflow is described like this: the user puts some data (some is fetched from the database and some is not)

When the user clicks on a print label, a window opens and a label is generated. So now the code (I think javascript can do the job) should do the job. The client wants that when the user presses the OK button (or print the label), the caption will be printed and the window will close without any interception from the user.

Possible solution: http://dymodevelopers.wordpress.com/2010/06/02/dymo-label-framework-javascript-library-samples-print-a-label/

So, in fact:

  • The script should select the correct printer (not the default)
  • Script must select the correct format (landscape / portrait and label sizes)
  • Should be printed without user intervention.
  • The window should be closed automatically after printing the label.

Thanks for the help;)

+3


source to share


4 answers


I do exactly this, but due to the limitations of web content, cannot control the Windows print interface without using a java app or an ActiveX based active app that I had to install by web browsers to print to dymo printers.

I am now applying using firefox, which means I have my own firefox installer package that sets margins to zero, disables headers and footers, selects the correct printer, paper and landscape, etc. (I only made my own kit because I had 100 + pc to set it up if its only a few 60 seconds to change work to do it manually). The advantage of using firefox is that FF allows you to select and set a different printer for the system as the default printer. So in my case ff is set for dymo, system printer is set up as kyocera so nothing gets lost / installed etc. Outside firefox.

As for generating the barcode, I just generate the basic jpg code on the fly, displaying the jpg in a new popup and using a little javascript to automatically pop up the print window, so all the user has to do is click OK. It cannot be done without user input!



Unfortunately, there is no easy way to close the window in such a way that the print spooler / system drivers don't bounce back to web browsers (they are separately isolated from each other for obvious reasons!), So the best thing you can do is Implement sync after xxx seconds.

In short, although there is no easy way to do this without user input and without any compromise. Now if cash and time is not an issue for you, I have the right way to make it fully automated, etc., but its a lot of work

+2


source


We just use FTP (used to use Windows, now we use the built in Cold Fusion, but everyone will do it) and you send the zebra printer to define your barcode to the machine this way ... whatever you can open such a channel and send the code on the printer will work. So if you want to do it with javascript see how fireftp works ... then use this ... or you can send the information in ZPLII encoding ... which says how to print.



+1


source


Since the link you posted is talking about driver requirements, I'm assuming you have sufficient control over the native software? If that's the case and you can use Firefox, then an add-on called JS Print Setup might work.

Basically it gives web pages the ability to print directly to a printer on the user's computer without a print dialog. In the meantime, there is no need to know about it. ”

I am guessing it will print the label thin if the right size is provided, but I have not tested this. I checked it when the printer was not connected and it sent it to the printer queue so it definitely tells the system to print the file.

Here's some sample code from the documentation: (It looks like it allows you to set fields as well and that's it.)

<script>
// set portrait orientation
jsPrintSetup.setOption('orientation', jsPrintSetup.kPortraitOrientation);

// set top margins in millimeters
jsPrintSetup.setOption('marginTop', 15);
jsPrintSetup.setOption('marginBottom', 15);
jsPrintSetup.setOption('marginLeft', 20);
jsPrintSetup.setOption('marginRight', 10);

// set page header
jsPrintSetup.setOption('headerStrLeft', 'My custom header');
jsPrintSetup.setOption('headerStrCenter', '');
jsPrintSetup.setOption('headerStrRight', '&PT');

// set empty page footer
jsPrintSetup.setOption('footerStrLeft', '');
jsPrintSetup.setOption('footerStrCenter', '');
jsPrintSetup.setOption('footerStrRight', '');

// clears user preferences always silent print value
// to enable using 'printSilent' option
jsPrintSetup.clearSilentPrint();

// Suppress print dialog (for this context only)
jsPrintSetup.setOption('printSilent', 1);

// Do Print 
// When print is submitted it is executed asynchronous and
// script flow continues after print independently of completetion of print process! 
jsPrintSetup.print();

// next commands
</script>

      

The add-on can be found here on the Mozilla Companion Site:

https://addons.mozilla.org/en-US/firefox/addon/js-print-setup/

0


source


Never used it myself, but Seagull Scientific ' BarTender seems like a good solution for direct barcode printing. It includes built-in drivers for working with databases such as Oracle, MS SQL and the .NET platform, and offers a Commander for printing from PHP web applications. A tutorial for printing via PHP applications is here http://cases.azoft.com/bartender-print-server/

-1


source







All Articles