Print PDF with PDFBox

0

I'm trying to implement printing a PDF directly on the printer with PDFBox 2. Printing works normally, however, the only problem is that I can not change the PDF's scale.

An example of a scale would be when you print from Google Chrome (CTRL + P) below (+ Settings) a checkbox called Scale appears. This causes the PDF content to be completely populated in the printer.

I'm using a non-fiscal printer (80mm X 420mm).

PDDocument document = PDDocument.load(decodedString);
PrintService myPrintService = findPrintService(printername);

PDFPrintable printable = new PDFPrintable(document, Scaling.ACTUAL_SIZE);
                                Orientation.AUTO, false, 300.0F));

job.setPrintable(printable);
try {
  job.setPrintService(myPrintService);
  job.print();
} catch (PrinterException e) {
  e.printStackTrace();
}

What I really need is to do the same thing Chrome does: set a certain scale that will print, but I have not had success so far.

    
asked by anonymous 29.04.2018 / 01:14

0 answers