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

Free Support Forum - aspose.com

Function Inadvertently overwrite font style

Dear Support,

I have an application whereby I read a Pdf document, and replace all embedded fonts in text with unembedded fonts, save the new pdf, and pass it to a 3rd party reader (i.e acrobat).

the resultant pdf is exactly like the original, except for Calibri and Verdana; their style (italic, bold) is gone after the replacement. other fonts preserve their style.

the issue happens with FontRepository.FindFont() . when I call this function like this:
if (installedEcofont.Contains(“Arial”))
textFragment.TextState.Font = FontRepository.FindFont(installedEcofont);
textFragment.TextState.Font.IsEmbedded = false;
if (installedEcofont.Contains(“Calibri”))
textFragment.TextState.Font = FontRepository.FindFont(installedEcofont);
textFragment.TextState.Font.IsEmbedded = false;
it overwrites the font style of the left-hand side of code. i.e textFragment.TextState.Font. What is curious
is this behaviour happens only for Calibri and Verdana. Arial, for example, the font style remains the same.

I have attached a VS2015 solution. project name is PdfView_test. The problem happens in line 85, line 80 is OK.
at PdfView_test.cs:66 you need to supply a license.
at project properties -> Debug you need to give it path of a pdf file. attached is the test PDF I used.

solution file

test pdf


Thank you for contacting support.

Please always share narrowed down sample applications including SSCCE examples as the shared solution file includes 27 projects; that will help us assist you efficiently. Moreover, Build fails for shared solution and below mentioned error occurs in our environment:

The command "cd "D:\sw\sw\src\EcofontCommon\"  && powershell -File "D:\sw\sw\src\EcofontCommon\\ValidateUsedTranslations.ps1" -solutionDir:D:\sw\sw\src\ && cd "D:\sw\sw\src\EcofontCommon\\translations" && powershell -File "D:\sw\sw\src\EcofontCommon\\translations\TranslationsValidator.ps1"" exited with code 1.	EcofontCommon

We have supplied the license and PDF path has been updated in Command line arguments as well. Would you please review the issue and guide us to reproduce it in our environment, so that we may proceed further to help you out.

Hi Farhan,
thanks for response.

The shared project is self contained and can compile. but you need to set PdfView_test as “Startup project”,
and only debug this one. dont build the solution.

so set PdfView_test as startup project, set solution configuration to “Debug”, set a breakpoint in for example PdFView_test.cs:46 and click run.

Let me know how it goes.



We had tried the same steps already, except setting a breakpoint. We have tried this again but the problem stays exactly as we have mentioned previously. Moreover, is there any pre-requisite for shared application to execute, for example, we can notice a comment mentioning: it is only supposed to work when there are Ecofont fonts installed. Can you please try executing the same project on some other system and then update us accordingly.

Hi Farhan,
for this error you need to execute on Powershell:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser

Let us know


Thank you for sharing the details.

We are trying your suggestions to execute the project and will share our findings as soon as we obtain some results.

1 Like


Thank you for being patient.

We have logged an investigation ticket with ID PDFNET-45765 in our issue management system. We will let you know as soon as some significant updates will be available in this regard.