andrey-ushakov / esc_pos_utils

Basic Flutter/Dart classes for ESC/POS printing
BSD 3-Clause "New" or "Revised" License
149 stars 333 forks source link

Replacing obsolete GS v 0 #6

Open niktses opened 4 years ago

niktses commented 4 years ago

Do you think replacing it with GS ( L is possible? I tried to understand how the command should become but i find it too complex. read these : https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=98#gs_lparen_cl_fn50 https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=99#gs_lparen_cl_fn112 https://stackoverflow.com/questions/13715950/writing-a-bitmap-to-epson-tm88iv-through-esc-p-commands-write-to-nvram

The images print really slowly because they are being divided in many parts and printed individually right now. This should print it in one piece.

niktses commented 4 years ago

ok even though i did figure it out

change cRasterImg and in my case this: header.addAll(_intLowHigh(widthBytes * heightPx + 11, 2)); header.addAll(_intLowHigh(48, 1)); header.addAll(_intLowHigh(112, 1)); header.addAll(_intLowHigh(48, 1)); header.addAll(_intLowHigh(1, 1)); header.addAll(_intLowHigh(1, 1)); header.addAll(_intLowHigh(49, 1)); header.addAll(_intLowHigh(widthPx, 2)); header.addAll(_intLowHigh(heightPx, 2));

that was not my problem after all because my printer supports the GS x 0 format. Added real problem here: https://github.com/andrey-ushakov/esc_pos_utils/issues/7

andrey-ushakov commented 4 years ago

First of all, thank you for all your contributions!

Could you please provide your code and the image file to test it on my printer? Have you tried to print using ESC * command (Ticket.image method)? What's the "GS x 0 format"?

niktses commented 4 years ago

I meant GS v 0. The image doesn't matter as long as it is not too big mine was 576 x 100 (png). The important thing is that the printer has to support "GS ( L". Then again some properties might be printer related. I got them from here. https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=99#gs_lparen_cl_fn112

andrey-ushakov commented 4 years ago

Hi @niktses ,

If your printer supports GS ( L command, could you please test the new printing method:

ticket.imageRaster(image, imageFn: PosImageFn.graphics);

Does the command ESC * work for you (Ticket.image method)?

I've tested the GS ( L command on 3 printers and none of them support it. However, the bytecode should be correct, Python esc/pos library generated the same bytecode.

niktses commented 4 years ago

made this changes and it works:

} else if (imageFn == PosImageFn.graphics) { // 'GS ( L' - FN_112 (Image data) final List header1 = List.from(cRasterImg.codeUnits); header1.addAll(_intLowHigh(widthBytes * heightPx + 11, 2)); // pL pH <-------------------- 11 header1.addAll([48, 112, 48]); // m=48, fn=112, a=48 header1.addAll([1, 1]); // bx=1, by=1 header1.addAll([49]); // c=49 header1.addAll(_intLowHigh(widthPx, 2)); // xL xH <-------------------------- widthPx header1.addAll(_intLowHigh(heightPx, 2)); // yL yH // TODO Image alignment // bytes += latin1.encode(align == PosAlign.left // ? cAlignLeft // : (align == PosAlign.center ? cAlignCenter : cAlignRight)); bytes += List.from(header1)..addAll(resterizedData..removeLast()); < ------------ ( this is weird but it adds a "d" after the image) }

andrey-ushakov commented 4 years ago

Unfortunately, it still doesn't work in my case..

niktses commented 4 years ago

if your printer doesn't support it you won't be able to test it.

one last change if it is possible: i changed

const gs2 = '\x38'; const cRasterImg = '$gs${gs2}L'; header1.addAll(_intLowHigh(widthBytes * heightPx + 11, 4)); // pL pH <------------ 4

it allows for images with more height

kechankrisna commented 4 years ago

I test ticket.image by using reciept.jpg and resize it to 572 on device T1, but it prints only half of image.

Abdulazeezvp commented 2 years ago

I test ticket.image by using reciept.jpg and resize it to 572 on device T1, but it prints only half of image.

Did you found any solution to it?

kechankrisna commented 2 years ago

I test ticket.image by using reciept.jpg and resize it to 572 on device T1, but it prints only half of image.

Did you found any solution to it?

Try the package pos printer manager might help you

Abdulazeezvp commented 2 years ago

Try the package pos printer manager might help you

Thank you, it solved my issue. using pos_printer_manager