作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要使用 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;
}
但是,预期输出如下图所示:
但是,实际输出如下图所示:
其中如您所见,没有边框也不会出现一些字符!我不知道我的代码哪里错了?!
在这里您可以看到这台打印机的主要属性,其中“认可”一项:
抱歉这个冗长的解释,但我们将不胜感激,
最佳答案
在每天头疼的问题之后,我的问题终于解决了!只是我将 Epson Printer Slip 设置更改为 [92,68] [高度,长度] ,, 然后一切都很完美。感谢我的上帝!...
关于java - 代言 Epson TM-h6000IV Java打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27201302/
我需要使用 Java 打印到 Epson Endorsement TM-h6000iv 打印机(USB 版本)。然而,我阅读手册并不希望找到任何帮助。我也不希望改变打印机偏好!我尝试使用 java 中
我是一名优秀的程序员,十分优秀!