nini9140 / jzebra

Automatically exported from code.google.com/p/jzebra
0 stars 0 forks source link

EPL2 Print problem #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I Have a LP2844 label printer.
What I like to do is printing a barcode direct on the printer.

I have used zebra tools to test:

N
B1,5,0,3,3,7,40,B,"23423412"
P1

This is working.
Only I can't get it work with jezebra.

Is there a PHP example availible 

Original issue reported on code.google.com by T.Tal...@gmail.com on 1 Mar 2012 at 9:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
You should be using something like follows:

<script>
document.jzebra.append('N\n');
document.jzebra.append('B1,5,0,3,3,7,40,B,"23423412\n"');
document.jzebra.append('P1\n');
document.jzebra.print();
</script>

If this doesn't work, try replacing "\n" with "\r\n" or simply "\r", which 
represents a new line and a carriage return in JavaScript, which should match 
your printer's programmers manual.

Please make sure your page works fine without PHP before introducing PHP into 
the the code.  A very basic PHP example is here: 
http://code.google.com/p/jzebra/wiki/TutorialWebApplet#php_Printing

Note:  This is not a bug but rather a help question.  Questions should go to 
the mailing list jzebra-users@googlegroups.com (link here: 
http://groups.google.com/group/jzebra-users).

Sending data from PHP to JavaScript is possible through various means.  For 
example, you could use php echo to insert JavaScript into your page.

A more elegant solution would be to use AJAX to exchange data between PHP and 
JavaScript.  JSON may also be able to help.

Some more elegant solutions are storing the print commands in a database and 
sending them to the client through ASP/PHP. 

PHP and ASP are server side languages, where JavaScript runs client side, so 
you will need to understand data exchange between the two for proper 
implementation.  The bug tracker unfortunately is not a place for this 
discussion.

-Tres

Original comment by tres.fin...@gmail.com on 1 Mar 2012 at 1:58

GoogleCodeExporter commented 9 years ago
Correction: (newline character was in the wrong place on B1 line)

<script>
document.jzebra.append('N\n');
document.jzebra.append('B1,5,0,3,3,7,40,B,"23423412"\n');
document.jzebra.append('P1\n');
document.jzebra.print();
</script>

Original comment by tres.fin...@gmail.com on 1 Mar 2012 at 1:59

GoogleCodeExporter commented 9 years ago
Well i have php code that creates a 1.txt file with the following content in it:

=====================================
A250,10,0,3,1,1,N,"EAN13 BARCODE"
B250,70,0,E30,3,7,100,B,"012345678912"

P1
N
=====================================

When using the printFileEPL routine it prints a perfect label.

=====================================
    function printFileEPL() {
            var applet = document.jZebra;
            if (applet != null) {
           // Using jZebra's "appendFile()" function, a file containg your raw EPL/ZPL
           // can be sent directly to the printer
           // Example:
           //  applet.appendFile("http://justtesting.biz/html/jzebra/epl2label.txt"); // ...etc
           applet.appendFile(window.location.href + "/../1.txt");
           applet.print();
        }

        monitorPrinting();
    }
=======================================

Only I can not get it work directly using PHP. I don't want a BUTTON on my page 
what calls the javascript code and i think it is not the best way to create 
first a .txt file and than print it.

Please advice

Original comment by T.Tal...@gmail.com on 1 Mar 2012 at 7:16

GoogleCodeExporter commented 9 years ago
Questions should go to the mailing list jzebra-users@googlegroups.com (link 
here: http://groups.google.com/group/jzebra-users).

You will need to use JavaScript and PHP using one of the aforementioned AJAX or 
JSON approaches.

Basically:

1.  PHP function echos commands to browser, JSON encoded then die()
2.  jQuery function does $.ajax({type: 'POST', url: test.php, success: 
function(data){}...});
3. Success function does JSON decode 
4. JavaScript uses document.jzebra.applet.append(decoded data)
5. JavaScript does document.jzebra.print();

This is all AJAX development questions, not jZebra.  You will have much more 
help from other web developers on the mailing list.  This bug list is for the 
Java Applet "jZebra".  This list is only monitored regularly by me, and I'm a 
Java developer, not a web developer.

-Tres

Original comment by tres.fin...@gmail.com on 1 Mar 2012 at 7:47

GoogleCodeExporter commented 9 years ago
Dear Tres,

I post the question in the google group.
Thank you for your answers and thank you for the great Jzebra code!

Best regards

Original comment by T.Tal...@gmail.com on 1 Mar 2012 at 8:01