I am using the below code to print a PDF with ICEpdf but for some reason the second page is corrupted as follows:
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();
I am using the below code to print a PDF with ICEpdf but for some reason the second page is corrupted as follows:
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();
Share
Improve this question
asked Jan 30 at 3:37
JonasJonas
8601 gold badge13 silver badges34 bronze badges
2
- I think the PDF is fine. Printing it using the same driver works fine. I have also written code to read the bytes and write them again and the result is ok too. I blelieve ICEpdf is doing some magic... their latest release is from Nov 2024. – Jonas Commented Jan 30 at 5:52
- This looks like font width issue or potential a font substitution. But as mentioned I'd suggest using the above url to get a more recent version of the library. There is a font width fix that is on the main branch and it will be included in the 7.2.3 release which should be out in the next few day. – pcorless Commented Jan 30 at 15:39
1 Answer
Reset to default 0I have solved the problem by simply exporting the PDF again and embedding the fonts via this option in Word: https://docs.prospect365/en/articles/5642928-embedding-fonts-in-word-documents-for-pdfs