esc_pos_utils icon indicating copy to clipboard operation
esc_pos_utils copied to clipboard

Replacing obsolete GS v 0

Open niktses opened this issue 4 years ago • 11 comments

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 avatar Mar 13 '20 14:03 niktses

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

niktses avatar Mar 13 '20 15:03 niktses

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"?

andrey-ushakov avatar Mar 13 '20 16:03 andrey-ushakov

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

niktses avatar Mar 13 '20 16:03 niktses

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.

andrey-ushakov avatar Mar 14 '20 13:03 andrey-ushakov

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) }

niktses avatar Mar 16 '20 11:03 niktses

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

andrey-ushakov avatar Mar 16 '20 11:03 andrey-ushakov

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

niktses avatar Mar 16 '20 12:03 niktses

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

kechankrisna avatar Apr 01 '20 13:04 kechankrisna

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?

Abdulazeezvp avatar Mar 24 '22 13:03 Abdulazeezvp

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

kechankrisna avatar Mar 24 '22 14:03 kechankrisna

Try the package pos printer manager might help you

Thank you, it solved my issue. using pos_printer_manager

Abdulazeezvp avatar Mar 25 '22 12:03 Abdulazeezvp