Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate #188

Closed
fitalinformatica opened this issue Sep 23, 2021 · 25 comments
Closed

Rotate #188

fitalinformatica opened this issue Sep 23, 2021 · 25 comments

Comments

@fitalinformatica
Copy link

Good afternoon, I've implemented zebra printer support in my App, for printing labels it's an excellent printer, posi offers support for printing using ZPL, EPL language that allows you to position elements very easily. However, as it is an extremely expensive printer here in BRAZIL, since it is quoted in dollars, to acquire a PT-210 ESC/POS printer from CHINA, and I loved this library, but I have difficulty rotating the elements that are printed on paper, that is, 90 degrees. I looked in the ESC/POS specification... for a way to do this, I even found the byte[] hex that allows you to rotate the element, but when I send a text, it prints everything in a single column, it doesn't distribute it horizontally.

Att
Sebastiao Fidencio

@DantSu
Copy link
Owner

DantSu commented Sep 24, 2021

Hi, share us photos, pieces of code of your problem.

@fitalinformatica
Copy link
Author

fitalinformatica commented Sep 24, 2021

Good Morning,

WhatsApp Image 2021-09-24 at 08 18 05

Follow the way the print is coming out with the 58mm printer model Goojprt PT-210.

Note the arrow rotating clockwise, I need to rotate the content 90º, as this paper is very narrow, so I get more out of the label printing in the other direction.

image
I tried various methods to observe the above situation, I even created the code in computer hexadecimal in the documentation for the low platform ESC / POS command, which allowed this process to run, but it still didn't work.

Maybe I don't know where to put this logic, or I'm hitting my head with something ESC/POS can't do, but I believe you have the answer to that question.

I need to print text, graphics in 90º clockwise., where columns provide rows and rows columns.

Regards ,
Sebastiao Fidencio

@DantSu
Copy link
Owner

DantSu commented Sep 24, 2021

Seems to works only on text. Not on image, barcode or anything else.

https://www.epson-biz.com/modules/ref_escpos/index.php?content_id=30

[Notes]

  • The 90° clockwise rotation mode is effective for alphanumeric, Kana, multilingual, and user-defined characters.
  • When underline mode is turned on, the printer does not underline 90° clockwise-rotated characters.
  • When character orientation changes in 90° clockwise rotation mode, the relationship between vertical and horizontal directions is reversed.
  • The 90° clockwise rotation mode has no effect in Page mode.
  • Some printer models support 90° clockwise rotation mode when n = 2 or 50.
  • Some printer models have a font for which 90° clockwise rotation mode is not effective.
  • Settings of this command are effective until ESC @ is executed, the printer is reset, or the power is turned off.

@DantSu
Copy link
Owner

DantSu commented Sep 24, 2021

@DantSu
Copy link
Owner

DantSu commented Sep 24, 2021

But this library use standard mode not page mode.

@fitalinformatica
Copy link
Author

Grateful for the information, I will analyze... the possibility.

See how the zebra print looks here..that was how necessary.

índice

índice2

@DantSu
Copy link
Owner

DantSu commented Sep 24, 2021

Maybe you can try :

Extend EscPosPrinterCommands like this :

public class MyEscPosPrinterCommands extends EscPosPrinterCommands {
    public static final byte[] ENABLE_PAGE_MODE = new byte[]{0x1B, 0x4C};
    public static final byte[] PAGE_MODE_DIRECTION = new byte[]{0x1B, 0x54, 0x02};
    /**
     * Reset printers parameters.
     */
    public EscPosPrinterCommands reset() {
        if (!this.printerConnection.isConnected()) {
            return this;
        }
        super.reset();
        // ACTIVE HERE PAGE MODE AND DIRECTION
        this.printerConnection.write(EscPosPrinterCommands.ENABLE_PAGE_MODE);
        this.printerConnection.write(EscPosPrinterCommands.PAGE_MODE_DIRECTION);
        return this;
    }
}

and do :

EscPosPrinter printer = new EscPosPrinter(new MyEscPosPrinterCommands(deviceConnection, charsetEncoding), 203, 48f, 32);

@DantSu
Copy link
Owner

DantSu commented Sep 24, 2021

say me if it works

@fitalinformatica
Copy link
Author

fitalinformatica commented Sep 24, 2021

Franck,

I ran the tests now at my lunchtime, and it didn't work, below are the videos...

I changed the modes, varying the hexadecimal code in the 3rd position of the Byte Array....according to EPSON's ESC/POS documentation, which you gave me.

public static final byte[] PAGE_MODE_DIRECTION = new byte[]{0x1B, 0x54, 0x02};

Thank you for your attention and understanding of the matter.

Yours sincerely,
Sebastiao Fidencio


https://drive.google.com/file/d/1-yK_Uy_9vYOWLdD9kNYcb18knUIGV4Kl/view?usp=sharing


https://drive.google.com/file/d/1-ygNcDBGs59EZHeeQUYKccTt6BS2tWXs/view?usp=sharing


https://drive.google.com/file/d/1-zsUXPavzg0BboEaP8Ch6Q7D-tPsvHyx/view?usp=sharing

@DantSu
Copy link
Owner

DantSu commented Sep 24, 2021

Sorry it was my only option to solve your need. :( I don't know how do that.

@fitalinformatica
Copy link
Author

image

Thank you for the committed data, however, no problem.

I will wait for another printer that we acquired ESC / POS to arrive from CHINA, who knows it works, then I will report it here. Thank you anyway.

Note that in the image, it shows printing in another direction, certainly this one has the page mode option.

Regards

@DantSu
Copy link
Owner

DantSu commented Sep 24, 2021

You can do that if you generate a Bitmap programmatically and print bitmap, but is more complicated.

@fitalinformatica
Copy link
Author

In fact, I saw another developer proposing a similar solution, however, I'll wait for the printer to arrive to test the solution you proposed directly in the library, however, if it doesn't work, I'll check the possibility of the bitmap. I don't know at what point I could get the byte array converted through ASCII, and convert it to bitmap, then rotate it using "Canvas"... I got a bit lost, where could I fit this solution into your LIB .

Look at the proposal on another project.

anastaciocintra/escpos-coffee#58

@DantSu DantSu closed this as completed Oct 12, 2021
@fitalinformatica
Copy link
Author

Good evening, passing to say that I solved my problem with printer above, it has ESC / POS support, but I used her SDK, called LPAPI, which allows to print the label using the drawings, X and Y, etc.. and so on. Via ESC/POS it is possible to print only Receipts, because this language uses the maximum size or width of the coil, whether 58mm or 80mm, so that it works with alignments to the left, center and right, that is, does not work with DPI. It would be even possible, but converting the label to Bitmap.

Thanks!

image

@Eftychiou
Copy link

Can you please help me to solve this ? How can i print text and barcode 90% rotated ?

@fitalinformatica
Copy link
Author

It's not 90% but 90º, the printer has to be supported as CPLC, or ZPL, or TSPL languages. In the case of this NETUM printer, it has its own SDK or API that allows you to rotate images and texts, or shapes, in short, it's called LPAPI.

@Eftychiou
Copy link

Good evening, passing to say that I solved my problem with printer above, it has ESC / POS support, but I used her SDK, called LPAPI, which allows to print the label using the drawings, X and Y, etc.. and so on. Via ESC/POS it is possible to print only Receipts, because this language uses the maximum size or width of the coil, whether 58mm or 80mm, so that it works with alignments to the left, center and right, that is, does not work with DPI. It would be even possible, but converting the label to Bitmap.

Thanks!

image

can i have the link to this lpapi sdk please ?

@Eftychiou
Copy link

It's not 90% but 90º, the printer has to be supported as CPLC, or ZPL, or TSPL languages. In the case of this NETUM printer, it has its own SDK or API that allows you to rotate images and texts, or shapes, in short, it's called LPAPI.

can you provide link to this LPAPI sdk please ?

@Eftychiou
Copy link

Untitled
20220420_135713

I am changing the width value(shown in the picture) but the width on the paper remains the same . What could it be ?

@DantSu
Copy link
Owner

DantSu commented Apr 20, 2022

583mm = 58.3cm....0.6 meter.

@DantSu
Copy link
Owner

DantSu commented Apr 20, 2022

This value is for images alignment only.

@Eftychiou
Copy link

but isn't this hexadecimal value ? What is the last parameter printerNbrCharactersPerLine used for ? I've tried to half it from 32 to 16 to see if i can restrict the characters per line but failed :/

@DantSu
Copy link
Owner

DantSu commented Apr 20, 2022

for text alignment, if you do [C]test or [R]test with 16 and 32, you will see a difference.
Is not for restriction. just used for alignment.

@Eftychiou
Copy link

Eftychiou commented Apr 20, 2022 via email

@kelalaka153
Copy link

Maybe you can try :

Extend EscPosPrinterCommands like this :

public class MyEscPosPrinterCommands extends EscPosPrinterCommands {
    public static final byte[] ENABLE_PAGE_MODE = new byte[]{0x1B, 0x4C};
    public static final byte[] PAGE_MODE_DIRECTION = new byte[]{0x1B, 0x54, 0x02};
    /**
     * Reset printers parameters.
     */
    public EscPosPrinterCommands reset() {
        if (!this.printerConnection.isConnected()) {
            return this;
        }
        super.reset();
        // ACTIVE HERE PAGE MODE AND DIRECTION
        this.printerConnection.write(EscPosPrinterCommands.ENABLE_PAGE_MODE);
        this.printerConnection.write(EscPosPrinterCommands.PAGE_MODE_DIRECTION);
        return this;
    }
}

and do :

EscPosPrinter printer = new EscPosPrinter(new MyEscPosPrinterCommands(deviceConnection, charsetEncoding), 203, 48f, 32);

This cannot be work since printerConnection is private.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants