最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ICEpdf: PDF Printing corrupted second page - Stack Overflow

programmeradmin1浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

I 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

发布评论

评论列表(0)

  1. 暂无评论