本文整理汇总了Java中java.awt.print.PrinterJob.lookupPrintServices方法的典型用法代码示例。如果您正苦于以下问题:Java PrinterJob.lookupPrintServices方法的具体用法?Java PrinterJob.lookupPrintServices怎么用?Java PrinterJob.lookupPrintServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.print.PrinterJob
的用法示例。
在下文中一共展示了PrinterJob.lookupPrintServices方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: thirdPartyPrintLogic
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
static void thirdPartyPrintLogic(String printerName) throws Exception {
PrinterJob printerjob = PrinterJob.getPrinterJob();
printerjob.setCopies(2);
printerjob.setJobName("myJobName");
printerjob.setPrintable(new DummyPrintable());
for (PrintService printService : PrinterJob.lookupPrintServices()) {
System.out.println("check printer name of service " + printService);
if (printerName.equals(printService.getName())) {
System.out.println("correct printer service do print...");
printerjob.setPrintService(printService);
printerjob.print();
break;
}
}
}
示例2: setPrinterNameAttrib
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
private void setPrinterNameAttrib(String printerName) {
PrintService service = this.getPrintService();
if (printerName == null) {
return;
}
if (service != null && printerName.equals(service.getName())) {
return;
} else {
PrintService []services = PrinterJob.lookupPrintServices();
for (int i=0; i<services.length; i++) {
if (printerName.equals(services[i].getName())) {
try {
this.setPrintService(services[i]);
} catch (PrinterException e) {
}
return;
}
}
}
//** END Functions called by native code for querying/updating attributes
}
示例3: getPrintService
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
@Override
public PrintService getPrintService() {
if (printService == null) {
PrintService[] lookupPrintServices = PrinterJob
.lookupPrintServices();
if (lookupPrintServices.length > 0)
printService = lookupPrintServices[0];
}
return printService;
}
示例4: initialize
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
private void initialize(byte[] pdfContent, String jobName,String nomeImpressora) throws IOException, PrinterException {
ByteBuffer bb = ByteBuffer.wrap(pdfContent);
PDFFile pdfFile = new PDFFile(bb);
PDFPrintPage pages = new PDFPrintPage(pdfFile);
PrintService[] pservices = PrinterJob.lookupPrintServices();
System.out.println(pservices.length);
if (pservices.length > 0) {
for (PrintService ps : pservices) {
System.out.println("Impressora Encontrada: " + ps.getName());
if (ps.getName().contains(nomeImpressora)) {
System.out.println("Impressora Selecionada: " + nomeImpressora);
impressora = ps;
break;
}
}
}
if (impressora != null) {
pjob = PrinterJob.getPrinterJob();
pjob.setPrintService(impressora);
PageFormat pf = PrinterJob.getPrinterJob().defaultPage();
pjob.setJobName(jobName);
Book book = new Book();
book.append(pages, pf, pdfFile.getNumPages());
pjob.setPageable(book);
Paper paper = new Paper();
paper.setSize(getWidth, getHeight);
paper.setImageableArea(margin, (int) margin / 4, getWidth - margin * 2, getHeight - margin * 2);
//paper.setImageableArea(margin,margin, paper.getWidth()-margin*2,paper.getHeight()-margin*2);
pf.setOrientation(orientacao);
pf.setPaper(paper);
}
}