用Java代碼打印PDF

字號:


    1、工具類庫
    類庫名:Apache PDFBox
    軟件首頁:
    說明:此類庫由Apache軟件基金會提供,使用Apache License 2.0,開源免費。
    2、使用此類庫打印pdf文件的代碼示例
    package com.why.test.pdf;
    import org.apache.pdfbox.PrintPDF;
    public class PrintPFDWithJava {
    public static void main(String[] args) throws Exception {
    //pdf文件全路經(jīng)
    String pdfPath = "E:\20_tmp\aaa.pdf";
    //--silentPrint:靜默打印
    PrintPDF.main(new String[]{"-silentPrint",pdfPath});
    }
    }