We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem with glyphs (font) rendering after text replacement

Hi. I’ve got problems with font rendering after replacement:
Original text fragment has “ArialMT” font (it not install on my local machine). When I set new text value the font become “Arial”. And result pdf file for some reason can’t render it well (see attached screen).
image.png (19.5 KB)

Could you, pls, describe the reason why?

Java code snippet

    var document = new Document("medical_history.pdf");
    var page = document.getPages().get_Item(3);
    var absorber = new TextFragmentAbsorber();
    absorber.setPhrase("17652-6001524");
    page.accept(absorber);

    var textFragment = absorber.getTextFragments().get_Item(1);
    System.out.println("Font BEFORE replacement: " + textFragment.getTextState().getFont().getFontName());
    textFragment.setText("[Medical History]");
    System.out.println("Font AFTER  replacement: " + textFragment.getTextState().getFont().getFontName());

    var newDocument = new Document();
    newDocument.getPages().add(page);
    newDocument.save("result.pdf");

Original file: medical_history.pdf (220.3 KB)

@dkuksa

A ticket with ID PDFJAVA-40818 has been created in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.