iText - Output file font looks blurry after using

2019-08-13 11:47发布

问题:

This question is an exact duplicate of:

  • iText 5.5.11 - bold text looks blurry after using PdfCleanUpProcessor 1 answer

I'm using iText 5.5.8 to remove some text in a rectangle in my PDF, exactly following this example. E.g. the code snippet like below:

final Rectangle rect = new Rectangle(0, 12, 300, 21);
final PdfReader reader = new PdfReader(inputPDF);
final PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPDF));
for (int i=1;i<=reader.getNumberOfPages();i++) {        
    cleanUpLocations.add(new PdfCleanUpLocation(i, rect, BaseColor.WHITE));
}

PdfCleanUpProcessor cleaner = new PdfCleanUpProcessor(cleanUpLocations, stamper);   
cleaner.cleanUp();

stamper.close();
reader.close();

However, in the output file, all those bold texts weight becomes heavier, and looks blurry. Meanwhile, all normal texts are still same as original.

Does anyone know how to fix this problem?

回答1:

Finally, I have resolved this problem by downgrading the iText back to version 5.5.4!



回答2:

Here's another possible solution for your problem which worked for me: iText 5.5.11 - bold text looks blurry after using PdfCleanUpProcessor

In version 5.5.10 this worked for me: I downloaded the jar file with the sources (itextpdf-5.5.10-sources.jar), imported it into a new eclipse project, edited the .java file (comment out the two lines of code), compiled it, replaced the original .class file with the newly compiled .class file and created a jar file with the same name. Hope this helps anyone with the same problem!



标签: java pdf itext