简体   繁体   English

在带有打印服务的Java上的ubuntu上找不到打印机

[英]Can't find printer on ubuntu from java with print service

I have problem with getting list of printers from java in ubuntu i have to find EPSON TM88V and BIXOLON SRP350II both are connected over USB. 我在从Ubuntu的Java中获取打印机列表时遇到问题,我必须找到EPSON TM88V和BIXOLON SRP350II都通过USB连接。

This is the code i used 这是我使用的代码

 PrintService[] service = PrinterJob.lookupPrintServices();
         for(int i=0;i<=service.length;i++)
         {
             JOptionPane.showMessageDialog(null,service[i]);

         }

I solved this and this is the solution: 我解决了这个,这是解决方案:

 PrintService[] service = java.awt.print.PrinterJob.lookupPrintServices();

  for (int i=0;i<service.length;i++) 
  { 
    JOptionPane.showMessageDialog(null,service[i].getName());
  }

it's appeared to be an issue with the network printers. 这似乎是网络打印机的问题。 any printer to be seen by JRE has to be in "shared" state. JRE可以看到的任何打印机都必须处于“共享”状态。 unfortunately network printers aren't. 不幸的是,网络打印机并非如此。 the only option so far is to install cups-pdf bridge and print from Java glovebox through PDF exported file (printed by "local" PDF sink appeared in the configuration after installing cups-pdf). 到目前为止,唯一的选择是安装cups-pdf桥并通过PDF导出文件从Java手套箱进行打印(安装cups-pdf后,配置中会出现“本地” PDF接收器打印)。

the command for installing necessary cups-pdf sink: 安装必要的cups-pdf水槽的命令:

sudo apt-get install cups-pdf

next, System Settings->Printers->PDF->->Shared (enable checkbox) 接下来,系统设置->打印机-> PDF->->共享(启用复选框)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM