JAVA and DPL-problems with sending image to printer

Joined
Jun 30, 2010
Messages
1
Reaction score
0
Hi all

I started to program Datamax printers in Java directly using DPL language. It all worked great-bar codes and tekst on labels but today i encountered a problem:

I can't send an image into the printer and print it.

The "downloading" phase I think is good: led shows that image is downloading and then led stops blinking...but when I try to print label with image the effect is strange. The problem maybe is in converting byte aray where the image is stored to String and puting it into DPL line and then convert again to byte array and send it direcly to printer.

I will put some code later but could You tell me-Is somebody have some experiance in this?

Below i put my code of loading and printing bmp file
but something is wrong-the printed bitmap is bad....what I'am doing wrong?

<code>
String printingImage="1Y11"
+ "000"
+ "0000"
+ "0000"
+ "v"; //name of image


//DPL commands to invoke with parameters
String STX = new Character((char) 2).toString();
String SOH = new Character((char) 1).toString();
String CR = new Character((char) 0x0d).toString();


//Loading bitmap to byte[]
File file2 = new File("c:/1/final.bmp");
FileInputStream fin2 = new FileInputStream(file2);
byte testbin2[] = new byte[(int) file2.length()];
fin2.read(testbin2);

String v = new String(testbin2); //bitmap to String

//DPL command
String loadAndPrintImage= SOH + "D" +CR
+ STX + "I" + "A" + "b" + "v" + CR + v + CR
+ STX + "L" +"D22" + CR + printingImage+CR + "E" + CR;

byte[] theByteArray = loadAndPrintImage.getBytes();

</code>
and then of course I use Java print service and sent that byte[] direct to printer:
<code>
.
.
.
Doc doc = new SimpleDoc(theByteArray, DocFlavor.BYTE_ARRAY.AUTOSENSE, null);
job.print(doc, pras);

</code>

With barcodes and labels with text it works fine but Images....can You help me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top