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

Free Support Forum - aspose.com

Replace Font in PDF is not working


I am trying to replace the attached PDF Font to “Verdana” with the following code :

Issues :
1. the absorber.TextFragments takes lot of time to loop through each TextFragment
2. The result pdf is having text overlapped.

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filePath);
// Search text fragments and set edit option as remove unused fonts
Aspose.Pdf.Text.TextFragmentAbsorber absorber =
new Aspose.Pdf.Text.TextFragmentAbsorber(
new Aspose.Pdf.Text.TextEditOptions(Aspose.Pdf.Text.TextEditOptions.FontReplace.RemoveUnusedFonts));

//accept the absorber for all the pages
// traverse through all the TextFragments
foreach (Aspose.Pdf.Text.TextFragment textFragment in absorber.TextFragments)

textFragment.TextState.Font = Aspose.Pdf.Text.<span style="color:#2b91af;">FontRepository</span>.FindFont(<span style="color:#a31515;">"Verdana"</span>);

// save the updated document

Hello There,

Thanks for contacting support.

2. The result pdf is having text overlapped.

I have tested the scenario with Aspose.Pdf for .NET 17.6 and observed the text overlapping issue in the resultant file. Therefore I have logged an issue as PDFNET-42894 in our issue tracking system, for the sake of correction.

1. the absorber.TextFragments takes lot of time to loop through each TextFragment

While testing the scenario, I have also observed that the API took more than 5 minutes to complete the task. Please note that the performance of the API depends upon many factors to be noticed i.e structure and complexity of the file, environment in which you are using the API, version of the API, application type, etc. However, I have logged a performance issue as PDFNET-42895 in our issue tracking system as well.

We will further investigate both issues and keep you posted with the status of their resolution. Please be patient and spare us little time.

We are sorry for the inconvenience.

Best Regards,

Thank you for the response.

Where can i track the logged issues?

“The result pdf is having text overlapped” is very critical for us.

Hi Mangalorewala,

Thanks for contacting support.

The issues are logged in our internal bug management system and I am afraid you may not have access over it. However, as soon as we have some definite updates regarding its resolution, we will update you within this forum thread.

The issues you have found earlier (filed as PDFNET-42894) have been fixed in Aspose.PDF for .NET 21.10.


In addition to the above notification and regarding the ticket PDFNET-42895, please try to use method “absorber.ApplyForAllFragments(FontRepository.FindFont(“Verdana”));” instead of a cycle for better performance.