當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。