Special ASCII character (█) in TextFragment results in error when saving PDF

Hi,

We tried to export a text string that contained a █ character to a PDF file inside a .Net Framework 5 C# project.
When we save the PDF we get a “Object reference not found” error.
However, when we convert the █ character to - for instance - a letter like an “X” the PDF is generated without any issues.

Is there a way to workaround this issue and be able to include these special characters?

Thanks!

Hello,
could you please provide code snippet which you used to export text sting into a PDF document?

Of course!

For instance something like this:

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document();
Page pdfPage = pdfDocument.Pages.Add();
Aspose.Pdf.Text.TextFragment text = new Aspose.Pdf.Text.TextFragment(“example ███ text”);

pdfPage.Paragraphs.Add(text);

MemoryStream stream = new MemoryStream();
pdfDocument.Save(stream, SaveFormat.Pdf);

We convert the stream to BASE64 and return it like so (for example)

byte[] result = null;
result = stream.ToArray();
var outputString = Convert.ToBase64String(result);

Thanks!

Thank you, this code is working fine at my side, could you please pack you application and attach archive to the topic?

Unfortunately I’m not able to do that.
Some additional information that might be of help: we are running .Net 5 inside a Linux container (Debian).
When I remove the █ characters the code above runs without issue, keeping it in returns a “Object reference not set to an instance of an object”

Thank you for information, probably this can be reproduced in Linux only, we will investigate this

The ticket was PDFNET-51739 registered. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

1 Like

A post was merged into an existing topic: Using special characters causes PDF library to crash in docker