use of org.apache.pdfbox.printing.PDFPageable in project BoofCV by lessthanoptimal.
the class CreateQrCodeDocumentPDF method sendToPrinter.
public void sendToPrinter() throws PrinterException, IOException {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(document));
if (job.printDialog()) {
job.print();
}
document.close();
}
use of org.apache.pdfbox.printing.PDFPageable in project pdfbox by apache.
the class PDFDebugger method printMenuItemActionPerformed.
private void printMenuItemActionPerformed(ActionEvent evt) {
if (document == null) {
return;
}
try {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(document));
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
PDViewerPreferences vp = document.getDocumentCatalog().getViewerPreferences();
if (vp != null && vp.getDuplex() != null) {
String dp = vp.getDuplex();
if (PDViewerPreferences.DUPLEX.DuplexFlipLongEdge.toString().equals(dp)) {
pras.add(Sides.TWO_SIDED_LONG_EDGE);
} else if (PDViewerPreferences.DUPLEX.DuplexFlipShortEdge.toString().equals(dp)) {
pras.add(Sides.TWO_SIDED_SHORT_EDGE);
} else if (PDViewerPreferences.DUPLEX.Simplex.toString().equals(dp)) {
pras.add(Sides.ONE_SIDED);
}
}
if (job.printDialog(pras)) {
job.print(pras);
}
} catch (PrinterException e) {
throw new RuntimeException(e);
}
}
use of org.apache.pdfbox.printing.PDFPageable in project pdfbox by apache.
the class Printing method print.
/**
* Prints the document at its actual size. This is the recommended way to print.
*/
private static void print(PDDocument document) throws IOException, PrinterException {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(document));
job.print();
}
use of org.apache.pdfbox.printing.PDFPageable in project pdfbox by apache.
the class Printing method printWithDialog.
/**
* Prints with a print preview dialog.
*/
private static void printWithDialog(PDDocument document) throws IOException, PrinterException {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(document));
if (job.printDialog()) {
job.print();
}
}
Aggregations