/**打印图片支持.png图片*/publicstaticvoiddrawImage(Filefile)throwsException{DocFlavordof=null;StringfileName=file.getName();if(fileName.endsWith(".gif")){dof=DocFlavor.IN...
/*
* 打印图片 支持 .png 图片
*/
public static void drawImage(File file) throws Exception{
DocFlavor dof = null;
String fileName = file.getName();
if(fileName.endsWith(".gif")){
dof = DocFlavor.INPUT_STREAM.GIF;
}else if(fileName.endsWith(".jpg")){
dof = DocFlavor.INPUT_STREAM.JPEG;
}else if(fileName.endsWith(".png")){
dof = DocFlavor.INPUT_STREAM.PNG;
}
//获得打印属性
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
//获得默认打印设备 [服务器端]
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
pras.add(OrientationRequested.PORTRAIT);
pras.add(new Copies(1));
pras.add(PrintQuality.HIGH);
DocAttributeSet das = new HashDocAttributeSet();
das.add(new MediaPrintableArea(0, 0, 4, 6, MediaPrintableArea.INCH));
FileInputStream fin = new FileInputStream(file.getPath());
Doc doc = new SimpleDoc(fin ,dof, das);
DocPrintJob job = ps.createPrintJob();
job.print(doc, pras);
fin.close();
}
以上是我的源码, 现在只能获取服务器端的打印机,如何获取客户端的呢? 求各位大神指教!
展开