Endorsement Epson TM-h6000IV Java Printing
Asked Answered
T

1

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,

Tadpole answered 29/11, 2014 at 10:38 Comment(5)
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.En
@En 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 !!Tadpole
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.En
Did you change the PageFormat? The printer may not be capable of of printing beyond a given rangeParamaribo
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!!!Tadpole
T
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!..

Tadpole answered 2/12, 2014 at 19:12 Comment(1)
Maheera what epson codes did you use to get it to print on the endorsement printer instead of the receipt printer?Speciosity

© 2022 - 2024 — McMap. All rights reserved.