pdfbox 2.0.0 及以上版本中 PDDocument.silentprint() 的替代品是什么?

What is the replacement of PDDocument.silentprint() in pdfbox version 2.0.0 and above?

我正在切换到 pdfbox 版本 2.0.0,想知道在 pdfbox 版本 2.0.0 和更高版本中替换 PDDocument.silentprint() 的替换是什么?

OP 提到的方法 PDDocument.silentprint() 有效地做了类似

的事情
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDPageable(this, job));
job.print();

根据 PDFBox 2.0 Migration Guide:

PDF Printing

With PDFBox 2.0.0 PDFPrinter has been removed.

Users of PDFPrinter.silentPrint() should now use this code:

PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(document));
job.print();

While users of PDFPrinter.print() should now use this code:

PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(document));
if (job.printDialog()) {
    job.print();
}

Advanced use case examples can be found in th examples package under org/apache/pdfbox/examples/printing/Printing.java

因此,对于 PDDocument document 替换 1.8.x

document.silentprint();

应该是2.0.x

PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(document));
job.print();