Liran
Liran

Reputation: 11

esc pos set page size ESC W cmd

I read a lot of documentation about ESC POS printer and still don't understand how set page size cmd (ESC W) is working. It seems to be like high and low byte to define the x-y positions

this should be the explaination, I just want to understand how I set some x,y position by it

xL-xH - low and high byte of initial horizontal offset

yL-yH - low and high byte of initial vertical offset

dxL-dxH - low and high byte width of the page

dyL-dyH - low and high byte height of the page

enter image description here

Upvotes: 1

Views: 2961

Answers (1)

c-romeo
c-romeo

Reputation: 408

simply put:

  • xL, yL, dxL, dyL are the remainder after division of x, y, dx and respectively dy to 256;
  • xH, yH, dxH, dyH arre the integer part after division of x, y, dx and respectively dy to 256;

    public void setPageRegion(int x, int y, int width, int height) {
        outputStream.write(new byte[] { 27, 87, 
            (byte)(x & 255), (byte)(x >> 8 & 255), 
            (byte)(y & 255), (byte)(y >> 8 & 255), 
            (byte)(width & 255), (byte)(width >> 8 & 255), 
            (byte)(height & 255), (byte)(height >> 8 & 255) };
    }
    

invoking setPageRegion(0, 230, 830, 500) will result in new byte[] { 27, 87, 0, 0, 230, 0, 62, 3, 244, 1}

Upvotes: 2

Related Questions