Linux上点阵打印机的Java打印质量 [英] Java printing quality in Linux on dot-matrix printer

查看:213
本文介绍了Linux上点阵打印机的Java打印质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将报告从Java桌面应用程序打印到点阵式打印机(Epson LX-300 II)。报告包含文字和一些图形。打印机通过USB连接,我正在使用CUPS进行打印。我正在使用Printable接口进行打印(非常标准的Java)。

I need to print the report from a Java desktop application to a dot-matrix printer (Epson LX-300 II). Report consists of text ang some graphics. Printer is connected via USB and I'm using CUPS to print. I'm printing using the Printable interface (pretty standard in Java).

我的问题:

文本打印每个打印机分辨率(60x60,120x60,120x72)的质量都非常低。在某些打印机驱动程序中似乎没有任何字体提示。信件看起来很难看。我不能使用直接文本输出端口(它看起来很棒),因为我还需要在同一页面上打印图形。

Text printing quality is very low on every printer resolution (60x60, 120x60, 120x72). It seems like there's no font hinting at all in some printer driver. Letters is looking very ugly. I can't use direct text-out to port (it looks great), 'cause I need also to print graphics on the same page.

似乎问题是不是在Java中,导致相同的应用程序在Windows中打印出高质量的文本和图形。此外,似乎问题不在CUPS系统中,因为OpenOffice或Abiword使用相同的字体打印相同的文本,质量非常好(比在Windows中更差但仍然很好)。

It seems that problem is not in Java, cause the same application prints the high-quality text and graphics in Windows. Also it seems that problem is not in CUPS system, cause OpenOffice or Abiword prints the same text with the same fonts with the very good quality (worse than in Windows but still good).

问题不在于字体:我尝试使用Windows中的Tahoma字体,它也是这样:在java / linux下打印时质量低。

Also problem is not with fonts: i'm tryed the Tahoma font from Windows, and it does the same: low quality while printing in java/linux.

问题不在于X.Org中的BCI提示,在屏幕上显示效果很好。

The problem is not with BCI-hinting in X.Org, displaying on the screen is great looking.

当我将任何文档从OpenOffice导出为PDF并打印该PDF时,我得到了同样的效果 - 纸上难看的暗示字体。如果从Office打印相同的文档,一切都还可以。

When I export any document from OpenOffice to PDF and printing that PDF, I got the same effect - ugly not-hinted fonts on the paper. If the same document is printed from Office, everything is ok.

我尝试了不同的Linux(KUbuntu 10.04,Puppy 2,Puppy 4.3.1),我得到了同样的效果在任何Linux上。

I tryed different Linuxes (KUbuntu 10.04, Puppy 2, Puppy 4.3.1) and I got the same effect on any Linux.

也许问题出在Ghostscript中,我在Puppy上获得了9.x版本,但仍然是相同的。或者我认为CUPS光栅化器('rastertoepson'或'foomatic-rip')可能存在问题。

Maybe the problem is in Ghostscript, I got 9.x version on Puppy and still the same. Or also I think that there can be problem with CUPS rasterizer ('rastertoepson' or 'foomatic-rip').

这是输出的例子(对不起移动 - 质量照片):

It's example of output (sorry for the "mobile"-quality photo):

我不知道发生了什么事,请帮帮我。

I just got no idea what's going on, help me please.

-
PS我的最终解决方案是使用'ESCPrinter.java'开源类,根据Epson文档添加打印图像的功能。

-- P.S. my final solution is to use 'ESCPrinter.java" open-source class, adding to it a capability of printing images according Epson documentation.

推荐答案

您可以尝试 setRenderingHint ;将一些调用复制到一起以便轻松输入。
也许它是TEXT_ANTIALIASING,但我不排除其他人。

You could give setRenderingHint a try; copied some calls together for typing ease. Maybe it is TEXT_ANTIALIASING, but I would not exclude the others.

另一个想法是,某个地方的屏幕分辨率会缩放到打印分辨率;一个带有自己动手打印的小型Java应用程序会显示出来。

An other idea, would be that somewhere screen resolution is scaled to print resolution; a small java app with do-it-yourself printing would show that.

你没有做旋转,是吗?(只是看到照片)。

You did not do a rotate, did you? (Just seeing the photo).

public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
    Graphics2D g = (Graphics2D) graphics;
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT);
    g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
    g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
    g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    return Printable.PAGE_EXISTS;
}

这篇关于Linux上点阵打印机的Java打印质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆