gpt4 book ai didi

java - 代言 Epson TM-h6000IV Java打印

转载 作者:行者123 更新时间:2023-12-01 12:12:24 24 4
gpt4 key购买 nike

我需要使用 Java 打印到 Epson Endorsement TM-h6000iv 打印机(USB 版本)。然而,我阅读手册并不希望找到任何帮助。我也不希望改变打印机偏好!我尝试使用 java 中的 TextPrinter 类的 java 代码进行打印工作。

主要“打印”功能:

    // ----- 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;
}

但是,预期输出如下图所示:

enter image description here

但是,实际输出如下图所示:

enter image description here

其中如您所见,没有边框也不会出现一些字符!我不知道我的代码哪里错了?!

在这里您可以看到这台打印机的主要属性,其中“认可”一项: enter image description here

抱歉这个冗长的解释,但我们将不胜感激,

最佳答案

在每天头疼的问题之后,我的问题终于解决了!只是我将 Epson Printer Slip 设置更改为 [92,68] [高度,长度] ,, 然后一切都很完美。感谢我的上帝!...

关于java - 代言 Epson TM-h6000IV Java打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27201302/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com