我正在使用以下代码将RAW数据(转义码)发送到打印机:
PrintService pservice = this.getPrintService();
DocPrintJob job = pservice.createPrintJob();
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new SimpleDoc(printdata, flavor, null);
job.addPrintJobListener(this);
try {
job.print(doc, null);
...
这在Windows中正常工作,打印机解释转义码并按照我的预期进行打印。
在Linux(我安装了CUPS版本的驱动程序)中,当我发送原始数据时,它只是打印一个空页并报告打印错误。 奇怪的是,如果我使用系统 lpr 命令发送数据,一切正常。
任何可能出错的线索?
[注意]随意编辑我的标题,我想不出更好的一个
[edit]这是我得到的错误日志:LOGS
[edit2]与我不太喜欢的解决方案类似的线程:Linux printing in java
[EDIT3] 尝试不同的DocFlavor我想出了新的错误:
E [07/Dec/2012:17:45:44 +0100] Unknown directive SystemGroup on line 4 of /etc/cups/cupsd.conf.
E [07/Dec/2012:17:45:44 +0100] Unknown directive JobPrivateAccess on line 85 of /etc/cups/cupsd.conf.
E [07/Dec/2012:17:45:44 +0100] Unknown directive JobPrivateValues on line 86 of /etc/cups/cupsd.conf.
E [07/Dec/2012:17:45:44 +0100] Unknown directive SubscriptionPrivateAccess on line 87 of /etc/cups/cupsd.conf.
E [07/Dec/2012:17:45:44 +0100] Unknown directive SubscriptionPrivateValues on line 88 of /etc/cups/cupsd.conf.
W [07/Dec/2012:17:45:44 +0100] CreateProfile failed: org.freedesktop.ColorManager.AlreadyExists:profile id 'LabelWriter-400-Gray..' already exists
W [07/Dec/2012:17:45:44 +0100] CreateDevice failed: org.freedesktop.ColorManager.AlreadyExists:device id 'cups-LabelWriter-400' already exists
这是否指向CUPS配置错误?