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!

Even I need to know the reason why it happens. If anybody replies it will be helpfull.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.