nini9140 / jzebra

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

Not able to print using print64() after passing the string #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello There,
we have a base 64 type string with us, when we use the same sting to pass to 
the document.jZebra.append64() method, but while printing the string it is 
printing the ASCII values like heart shape, smiley shape and etc.

The base64 string which we are passing is of one of the sample image and we 
want to pass it directly to the printer so that it can print the image.   

What steps will reproduce the problem?
1. Find the attached .txt file and use the same string to pass to 
document.jZebra.append64() method
2.
3.

What is the expected output? What do you see instead?
shipment label image 
I have attached another .pdf file which is expected as printout 

What version of the product are you using? On what operating system?
We are using the ASP.net 3.5 application on Windows OS 

Please provide any additional information below.
Try to produce the image from the given base64 string 
or please suggest, if we are doing anything wrong 

Original issue reported on code.google.com by ashwin.k...@clariontechnologies.co.in on 16 Mar 2012 at 9:25

Attachments:

GoogleCodeExporter commented 9 years ago
Ashwin,

I reviewed the source code, and it is looking for the HTML "data:image/" tag.

Can you supply your data in the HTML format and see if it works?

Here is an example:

<img
src="data:image/gif;base64,R0lGODlhUAAPAKIAAAsLav///88PD9WqsYmApmZmZtZfYmdakyH5B
AQUAP8ALAAAAABQAA8AAAPb
WLrc/jDKSVe4OOvNu/9gqARDSRBHegyGMahqO4R0bQcjIQ8E4BMCQc930JluyGRmdAAcdiigMLVr
ApTYWy5FKM1IQe+Mp+L4rphz+qIOBAUYeCY4p2tGrJZeH9y79mZsawFoaIRxF3JyiYxuHiMGb5KT
kpFvZj4ZbYeCiXaOiKBwnxh4fnt9e3ktgZyHhrChinONs3cFAShFF2JhvCZlG5uchYNun5eedRxM
AF15XEFRXgZWWdciuM8GCmdSQ84lLQfY5R14wDB5Lyon4ubwS7jx9NcV9/j5+g4JADs=
" alt="British Blog Directory" width="80" height="15" />

Although this isn't a bug, I'm leaving it open as an Enhancement.  jZebra 
probably needs a note about this in the comments section of sample.html and 
also the Wiki.

-Tres

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

GoogleCodeExporter commented 9 years ago
Hello Tres

Thanks for your reply

when I am using like  applet.append64("<img 
src='data:image/gif;base64,R0lGODdheAUgA+cAAAAAAAEBAQI....0LCAA7'  /> ");
applet.append("\n");
applet.print();

It is giving me a blank page and Exception as "Bad Base64 input character '<' 
in array position 0"

Also I tried to put it like 

applet.appendHTML("<html><img src='data:image/gif;base64,R0lGODdheAUgA+.... 
AA7'  /> </html>");
 applet.append("\n");
applet.print();

for this, it gives me a JavaScript error like "Object doesn't support this 
property or method"

Can you please guide on this 

Thanks you very much
Ashwin

Original comment by ashwin.k...@clariontechnologies.co.in on 16 Mar 2012 at 3:00

GoogleCodeExporter commented 9 years ago
Sorry, try it like this:

applet.appendImage("data:image/gif;base64,R0lGODdheAUgA+cAAAAAAAEBAQI....0LCAA7"
);

-Tres

Original comment by tres.fin...@gmail.com on 16 Mar 2012 at 3:46

GoogleCodeExporter commented 9 years ago
I would suggest using the appendImage function.

If you want to try the appendHTML() that may work too but it's untested with 
embedded images.  If you use appendHTML(), make sure you are using the latest 
version.

-Tres

Original comment by tres.fin...@gmail.com on 16 Mar 2012 at 3:51

GoogleCodeExporter commented 9 years ago
Hi Tres,

Thanks for your replies, I tried using 
applet.appendImage("data:image/gif;base64,R0lGODdheAUgA+cAAAAAAAEBAQI....0LCAA7"
); 

it works, it doesn't give any kind of error, but it prints a blank page, with 
no image or no text.

so after that I tried it like
applet.appendHTML("data:image/gif;base64,R0lGODdheAUg .....0LCAA7");, but the 
same thing, no any text or image, a blank page is coming out of a printer.

I am using 1.3.5 version of jZebra

Please tell me where I am doing wrong?

Original comment by ashwin.k...@clariontechnologies.co.in on 20 Mar 2012 at 9:17

GoogleCodeExporter commented 9 years ago
Ashwin,

Sorry, somehow I lost track of this bug.  Is this still broken?

-Tres

Original comment by tres.fin...@gmail.com on 23 May 2012 at 12:53

GoogleCodeExporter commented 9 years ago
GIF may not be supported natively in Java.  Try PNG or JPG.  Furthermore, if 
your shipping label supports ZPL, consider getting a ZPL capable printer.

I'm closing this due to lack of activity and due to the fact that the image 
appending feature was added in response to this bug but has not been reported 
broken by anyone else.  Please reopen if this was closed in error.

-Tres

Original comment by tres.fin...@gmail.com on 2 Jul 2012 at 2:35

GoogleCodeExporter commented 9 years ago
Hello,
I tried with new version i.e. 1.4.3, but I am still facing the same issue.
It is printing a ASCII charters only

Can you please help me out. 

For more ref. please find the attached base64 string file 

Original comment by ashwin.k...@clariontechnologies.co.in on 17 Jul 2012 at 2:51

Attachments:

GoogleCodeExporter commented 9 years ago
What type of printer?  Is the image the only thing being printed?  Can you give 
me a code snippet (more than just the image apppend)?

-Tres

Original comment by tres.fin...@gmail.com on 17 Jul 2012 at 3:54

GoogleCodeExporter commented 9 years ago
Hi 
Thanks for the reply
Its "hp LaserJet 3030", not an image Printer.

Yes, its an image, of which the base64 char string which we are trying to 
print. 

Here is the code which I am trying...

function print64() {
         var applet = document.jZebra;
         if (applet != null) {
            // Use jZebra's `"append64"` function. This will automatically convert provided
            // base64 encoded text into ascii/bytes, etc.
           // applet.append64("QTU5MCwxNjAwLDIsMywxLDEsTiwialplYnJhIHNhbXBsZS5odG1sIgpBNTkwLDE1NzAsMiwzLDEsMSxOLCJUZXN0aW5nIHRoZSBwcmludDY0KCkgZnVuY3Rpb24iClAxCg==");
            applet.append64("0x0D0A4E0D0A4F4431300D0A713831320D0A51313337302C......0D0A50310D0A4E0D0A");
           // applet.appendPDF(getPath() + "TestPDF.pdf");
            // Send characters/raw commands to printer
            applet.print();
         }

         // *Note:  monitorPrinting() still works but is too complicated and
         // outdated.  Instead create a JavaScript  function called 
         // "jzebraDonePrinting()" and handle your next steps there.
         monitorPrinting();
      }

we are just replacing your base64 string with our base64 string from the code 
sample you have given in sample.html page. 

Original comment by ashwin.k...@clariontechnologies.co.in on 18 Jul 2012 at 6:11

GoogleCodeExporter commented 9 years ago
Thanks.  Can you attach the entire base64 string and print commands in an html 
file?

Original comment by tres.fin...@gmail.com on 18 Jul 2012 at 3:21

GoogleCodeExporter commented 9 years ago
Please find the attached Test.html file 

Original comment by ashwin.k...@clariontechnologies.co.in on 19 Jul 2012 at 5:51

Attachments:

GoogleCodeExporter commented 9 years ago
@ashwin:  Who has supplied this base64 data to you?

First I noticed, you are using append64().  append64() should only be used for 
raw printing (Eltron, Zebra, Epson, Citizen, Line Printer, etc).

Instead you should use appendImage(), which works with LaserJets and PDF 
writers (I'm testing with CUPS PDF writer, but any windows PDF writer should 
work just the same).

Unfortunately, I cannot get your base64 data to decode to an image.

Attached is a sample "Test2.html" of how it should be done.  Notice "var 
ashwin" and "var tres".  "tres" prints a small turtle GIF at the top left of 
the PDF.  "ashwin" always says the file is corrupt.

If this base64 file was supplied by a 3rd party, can they provide any 
documentation on what it's contents are?  I tried GIF, PNG, JPG, and none of 
them would decode.

-Tres

Original comment by tres.fin...@gmail.com on 19 Jul 2012 at 2:21

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by tres.fin...@gmail.com on 19 Jul 2012 at 2:22

Attachments: