当前位置: 首页>>代码示例>>Java>>正文


Java PrinterJob.lookupPrintServices方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DummyPrintTest.java

示例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

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:WPrinterJob.java

示例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;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:11,代码来源:AbstractRamusPrintable.java

示例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);
    }
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:41,代码来源:PrintPdf.java


注:本文中的java.awt.print.PrinterJob.lookupPrintServices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。