Search code examples
pdfprintingcorrupticepdf

ICEpdf: PDF Printing corrupted second page


I am using the below code to print a PDF with ICEpdf but for some reason the second page is corrupted as follows:

Corrupted Second Page

Also, the file size of the original is 328kb and the printed on (Print to PDF) is 579kb. I have tried another one which is only 29kb and resulted in 366kb.

Are there any encoding problems but I cannot see how to control that with ICEpdf?

Document pdf = new Document();
pdf.setFile("my.pdf");

// create a new print helper with a specified paper size and print
// quality
PrintHelper printHelper = new PrintHelper(null, pdf.getPageTree(),
        0f, MediaSizeName.NA_LEGAL, PrintQuality.DRAFT);
// try and print pages 1 - 10, 1 copy, scale to fit paper.
printHelper.setupPrintService(Printers.getInstance().getDefaultService(), 0, 0, 1, true);
// print the document
printHelper.print();

Solution

  • I have solved the problem by simply exporting the PDF again and embedding the fonts via this option in Word: https://docs.prospect365.com/en/articles/5642928-embedding-fonts-in-word-documents-for-pdfs