0

I need to print to an Epson Endorsement TM-h6000iv printer (usb version) with Java. However, I read the manual without hope to find sth can help. I change in printer preferences without hope also! I try with this code of java which TextPrinter class in java for printing work.

Main "Print" function:

    // ----- start printing ------
public int print(Graphics g, PageFormat pf, int pageIndex) {
    double ww, hh, x, y;
    String s;

    pf = PF; // The PF indicates for defaultPage PF= Pj.defaultPage(); 
    GG = (Graphics2D) g;
    s = "Serif";
    GG.setFont(new Font(s, Font.BOLD, Fy));
    GG.setColor(Color.black);
    GFont = GG.getFont();
    FM = GG.getFontMetrics();

    // Insure printing of ONE page
    if (pageIndex != 0)
        return Printable.NO_SUCH_PAGE;

    ww = pf.getImageableWidth();
    hh = pf.getImageableHeight();
    x = pf.getImageableX();
    y = pf.getImageableY();

    GG.translate(x, y);

    int xpos = 0;
    draw(getLine(10), xpos, 5);//getLine to return line of String from 0-9 this line will return "0123456789"
    draw(getLine(20), xpos, 6);//"01234567890123456789"
    draw(getLine(30), xpos, 7); // etc. 
    draw(getLine(40), xpos, 8);

    int x0 = 0, x1 = (int) ww - 10;
    // GG.drawRect(x0, x0, x1, x1);

    // draw Rectangular 
    GG.drawLine(x0, x0, x1, x0);
    GG.drawLine(x0, x0, x0, x1);
    GG.drawLine(x0, x1, x1, x1);
    GG.drawLine(x1, x1, x1, x0);

    return Printable.PAGE_EXISTS;
}

However, the Expected Output Is as in this Image:

enter image description here

BUT, the actual output Is as in this Image:

enter image description here

Which as you can see without Border also some characters not appear! Where is the wrong in my Code I do not know?!

Here you can see The main properties of this printer which "Endorsement" one: enter image description here

Sorry for this Long explanation BUT any help will be appreciated,

Maheera Jazi
  • 214
  • 1
  • 6
  • 19
  • 1
    I would suggest trying to do this drawing to the screen first, and only when you see what you want to see, change it to printing. This is really not about the printer, it's about the layout. Your rectangle makes no sense, and you are not using the font metrics at all. Once you get the drawing done properly in a screen graphics context, you can use the same code to print. – RealSkeptic Nov 30 '14 at 12:05
  • @RealSkeptic thanks for your comment, really I tried all what you are suggest! The problem was that the printer does not print outside specific area which almost 50mm ! I don't know why?!! I changed on printer layout without hope also!! this will lead me to mad !! – Maheera Jazi Nov 30 '14 at 18:41
  • Not sure you understood what I said. Your drawing is *wrong*, no matter what the printer does. Please draw it to a window first, and after you fix it on the window, try to print it on a printer. If it doesn't work, edit your question and put in your new code. – RealSkeptic Nov 30 '14 at 19:05
  • Did you change the `PageFormat`? The printer may not be capable of of printing beyond a given range – MadProgrammer Dec 01 '14 at 08:19
  • what do you mean by PageFormat please? the size? or orientation? or ImageableArea? I change on all of them without hope!! The printer does not print specific area!! where is the problem I do not know!!! – Maheera Jazi Dec 01 '14 at 08:38

1 Answers1

1

Finally, my problem solved after a lot of daily headache!! Just I changed on Epson Printer Slip Setting to [92,68] [Height,Length] ,, Then everything works perfect. Thanks to my God!..

Maheera Jazi
  • 214
  • 1
  • 6
  • 19
  • Maheera what epson codes did you use to get it to print on the endorsement printer instead of the receipt printer? – grouchomc Jan 05 '20 at 17:49