java如何获取客户端打印机 求教
2个回答
2016-05-01
展开全部
Server端后台代码实现的打印,当然只能查找server所在的网络打印机咯。Server端最多知道client端IP相关的信息,要操作client端的事情,只能以此为延伸想办法吧。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2016-05-01
展开全部
import java.io.File;
import java.io.FileInputStream;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.ServiceUI;
import javax.print.SimpleDoc;
import javax.print.attribute.DocAttributeSet;
import javax.print.attribute.HashDocAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.swing.JFileChooser;
public class Printers
{
public static void main(String[] args)
{
HashPrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
//查找所有的可用的打印服务
PrintService[] printService = PrintServiceLookup.lookupPrintServices(flavor, pras);
for (int i =0; i<printService.length ;i++ )
{
System.out.println(printService[i].getName());
}
}
}
import java.io.FileInputStream;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.ServiceUI;
import javax.print.SimpleDoc;
import javax.print.attribute.DocAttributeSet;
import javax.print.attribute.HashDocAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.swing.JFileChooser;
public class Printers
{
public static void main(String[] args)
{
HashPrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
//查找所有的可用的打印服务
PrintService[] printService = PrintServiceLookup.lookupPrintServices(flavor, pras);
for (int i =0; i<printService.length ;i++ )
{
System.out.println(printService[i].getName());
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询