【发布时间】:2019-07-25 13:52:34
【问题描述】:
我有厦门容大科技的热敏票据打印机型号RP58E。我知道这个没有适用于 Linux 的驱动程序,但我设法手动设置了它。我做了什么:打印机->添加打印机->选择Unknown->转发->在从数据库中选择打印机下我选择了Generic (recommended)->转发->这里我选择了text-only (recommended)然后完成。但是这样我只能打印文本而不是图像,我也想打印图像。无论如何我可以做到这一点吗?
我正在编写一个用于打印的 Java 程序,我是这样写的:
public void printImage(String printerName, String imgLocation) throws PrintException, IOException {
DocFlavor flavor = DocFlavor.INPUT_STREAM.PNG;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new PrinterResolution(205, 205, PrinterResolution.DPI));
aset.add(new MediaPrintableArea(0, 0, 48, 48, MediaPrintableArea.MM));
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
for(PrintService printService : services) {
if(printService.getName().equals(printerName)) {
DocPrintJob pj = printService.createPrintJob();
FileInputStream fis = new FileInputStream(imgLocation);
Doc doc = new SimpleDoc(fis, flavor, null);
pj.print(doc, aset);
}
}
}
如果我为打印机设置了text-only (recommended),我能以某种方式打印图像吗?
EDDIT:以下是设置打印机时可供选择的选项的屏幕截图:
【问题讨论】:
-
如果它只显示文字,您为什么希望它打印图像?有文字和图片选项吗?
-
@mwarren 是的,有很多选项可供选择。纯文本(推荐)是我选择的选项,因为它是推荐的。我将在问题中添加选项图片。
-
我认为这是推荐的选项,因为它最有可能起作用,其他选项也可能起作用,只是不能保证它们起作用。
-
@mwarren 是的,我已经尝试过使用 PDF 和 PostScript,但没有成功。我总是只打印随机的东西。我编辑了问题并添加了图片。
-
我会先查看打印机制造商的网站,看看打印机支持哪些格式。使用 PCL 或 GDI 可能会更好,但请先检查打印机支持的内容。
标签: java ubuntu printing ubuntu-16.04 linux-device-driver