Hello everybody!!
I'm trying to print a *.pdf file from Java code, and the printer out gives the right document, but smaller than the original pdf (smaller text, images, margins, everything), the print result seems shrinked from the original...
Here is the code I'm using:
File f = new File("\\Some.pdf");
FileInputStream fis = new FileInputStream(f);
FileChannel fc = fis.getChannel();
Paper paper = new Paper();
paper.setImageableArea(20, 40, paper.getWidth() - 20, paper.getHeight() - 40);
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
PDFFile pdfFile = new PDFFile(bb);
PDFPrintPage pages = new PDFPrintPage(pdfFile);
PrinterJob pjob = PrinterJob.getPrinterJob();
PageFormat pf = PrinterJob.getPrinterJob().defaultPage();
pf.setPaper(paper);
pf = pjob.validatePage(pf);
pjob.setJobName(f.getName());
Book book = new Book();
book.append(pages, pf, pdfFile.getNumPages());
pjob.setPageable(book);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.NA_LETTER);
aset.add(MediaTray.MIDDLE);
pjob.print(aset);
Thanks for your possible help,
Greetings!