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

Free Support Forum - aspose.com

Aspose.Pdf .Net5 on Linux generates error when a word is replaces with a letter not present in the PDF file


We are running a trial test with Aspose.PDF inside a .Net5 application that is running inside a Linux container. So far everything is working fine but we are running into an issue that is impacting our decision of using Aspose.PDF.

In short: we are importing a PDF document inside our solution using Aspose.PDF.
We then navigate to a TextFragment and want to modify the fragment with a new string value.
For instance, the TextFragment “this is a test text” we want to replace with “this line has been updated”.
When we do this in our code and than save the PDF again we run into an “Object reference not set to an instance of an object” error.
We discovered that if we want to update the TextFragment with a letter that is not present in the original PDF this issue occurs. In the example above for instance the letter “l” from the word “line” is not present in the original PDF. If we change the replacement value so it contains all the letters that are present in the original PDF we do nog get the error and the PDF is generated correctly.
We also discovered this issue is case-sensitive. So even though we have the letter “l” in the original PDF but change it with the uppercase “L” the error is generated.

We would love to get a fix for this issue since this is currently preventing us from buying the full license for the Apose.PDF product.



To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input document.
    Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

aspose_test.zip (171.7 KB)

We have attached a sample console app written in .Net 5.
When running the application on Windows there are no issues and the error does not occur.
However, when running the code inside a Linux OS (see the supplied Dockerfile to run the program inside a Linux container) we do get the error.

Inside the .zip is also an example .PDF file we want to process.
The Aspose license file has been removed.

Perhaps some unneeded extra info, but for completeness.
After building the container image using the Dockerfile you can connect to it using “docker run -it asposetest” then inside the container you can start the app with “dotnet asposetest.dll”.
The app will wait for a keypress before running so you can see the error.




We have tested the scenario using the latest version of Aspose.PDF for .NET 22.4 and have not found the shared issue. So, please use Aspose.PDF for .NET 22.4.

We have installed the latest Aspose.PDF version inside the sample application as you can see in the csproj file.
Have you tested running the application with .Net 5.0 on a Linux machine?
I have just ran the code on a fresh Ubuntu VM and I definitely get the error as you can see in the attached screenshot.aspose_error_ubuntu.png (64.5 KB)

By giving back more information about the error the Object reference error now returns a “Format of font “Symbol” is not supported for new composite fonts”.

Can you please look at this again?



We have found the issue with the code.
Apparently it is needed on Linux to install the Microsoft core fonts through the ttf-mscorefonts-installer package. After installing this the issue is resolved.


It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.PDF, we will be happy to help you.