开发者

Print given ip printer

开发者 https://www.devze.com 2023-03-11 03:24 出处:网络
I want to print a pdf file, given the 开发者_运维问答printer\'s IP address, the IP address is stored in a table in the database, I read the ip address of that table (which is type string), and that is

I want to print a pdf file, given the 开发者_运维问答printer's IP address, the IP address is stored in a table in the database, I read the ip address of that table (which is type string), and that is the ip address of the printer where I want to print. I tried a thousand ways, but still I can not get what I need. I'm programming in java language.

In this way, I get a list of ip address:

PrintService[] service = PrinterJob.lookupPrintServices();// list of ip address 
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintService(service[0]);//I get the first address 

But, I need to set the ip address, which I read from my database, I don't need that list:

I know this is not correct, but this is the idea:

service[0] = "\\10.100.17.93\HP LaserJet Professional P1102w";
//I want to assign the ip address


Related question on SO
Jipsi @Sourceforge

Haven't used Jipsi myself, though I intend to try it out soon. From what I understand, you can send printjobs to a networkprinter which is declared on a server. This could be an Active Directory (domain) server in a Microsoft setup, or a Cups server which is on Linux.

Let me know if this works for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消