Replacing TextFragment's text resets font to Times New Roman

Hello,


I’m using Aspose PDF Version 8.1 to replace some text in a PDF file. The font used is embedded in the PDF and not present in the system.

When I try to replace a particular text (using a TextFragmentAbsorber and then changing the Text property of each TextFragment objects) the font is reset to Times New Roman.

Shouldn’t the font remain unchanged?

I have confirmed that if the font is installed in the system this doesn’t occur and then the font type isn’t changed.

I also tried loading the embedded font into an Aspose Font object and setting it to the TextFragment but nothing changed.

Regards,
Diego.

Hi Diego,


Thanks for using our products and sorry for the delayed response.

I have tried replicating the issue using Aspose.Pdf for .NET 8.1.0 where I have used some of my sample PDF files and I am unable to notice any issue. The text is being displayed in font in which it was present before text replace. Can you please share the source PDF files which you are using so that we can again test the scenario at our end. We are sorry for your inconvenience.

Hi Nayyer,


Apologies for the delay.
Attached you’ll find a PDF document that has an embedded font that’s not installed in my system (FoundryGridnik).

This is some sample code I used to reproduce the issue:
Document doc = new Document(“path_to_file”);
textFragmentAbsorber = new TextFragmentAbsorber("{User.Phone}");
doc.Pages.Accept(textFragmentAbsorber);
foreach (TextFragment textFragment in textFragmentAbsorber.TextFragments){
textFragment.Text = “123-456-789”;
}

doc.Save(“path_to_updated_file”);

At the bottom of the first page you’ll notice that “{User.Phone}” has been replaced with “123-456-789” but the font type has now changed to Times New Roman

Thanks,
Diego.


Hi Diego,

Thanks for sharing source document. While using the latest version of Aspose.Pdf for NET 8.2.0, I've managed to reproduce this issue on my side and logged it in our bug tracking system as PDFNEWNET-35607 for further investigation and resolution. I've also linked your request to this issue and you will be notified via this thread as soon as it is resolved.


Sorry for the inconvenience faced..

<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif”;mso-fareast-font-family:
“Times New Roman”;mso-ansi-language:EN-US;mso-fareast-language:EN-US;
mso-bidi-language:AR-SA”>Best Regards,