Using special characters causes PDF library to crash in docker

When special characters are encountered, such as the ° symbol when running inside a docker container the following error is thrown:

app_1  | Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
app_1  |    at Aspose.Pdf.Text.Font..ctor(#=zIeekTqBn_681KsTbazA$Esk= #=zi1KmaYg=)
app_1  |    at #=z8hvi3dDxmmrMvE7_zssGl7j1HEgjwiQ5a1CuXqf6wCCjh26I3ryEPjw=.#=zy8mim9jCF72nlFzIiBGUIgzJLTwa(String #=zDYqJm8o=, Font #=zi1KmaYg=, Font& #=zWfJrMbGoA3Mi6ntWOaszxGU=)
app_1  |    at #=zxAbyhYtY07Qh7rw3NIv8ZU3Hf8XU.#=zVIe52ToSwRM7(String #=zngxtGG0=)
app_1  |    at Aspose.Pdf.Text.TextFragment.#=z9qdNuS68Gepo(String #=zngxtGG0=)
app_1  |    at Aspose.Pdf.Text.TextFragment..ctor(String text)
app_1  |    at PdfSpecialChar.Program.Main(String[] args) in /app/PdfSpecialChar/Program.cs:line 43
pdfspecialchar_app_1 exited with code 139

I am attaching a sample app to show this behavior.

The Aspose.Total.lic file has been blanked for obvious reasons, so you will have to add a license file. If you don’t have a licence file set other errors are thrown.

To build the project: docker build -t pdf-special-char .

To run the project: docker-compose up

Thank you,
~Tim

PdfSpecialChar.zip (333.8 KB)

@TimothyBlue

We need to further investigate whether this issue is related to specific font that you are using or with your specific docker environment as we initially tested the scenario in Windows 10 environment and were unable to notice the exception. We have logged an investigation ticket as PDFNET-48451 in our issue tracking system. We will further look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issue only happens in a linux docker container which is what we use for our web apps. When run in a windows environment everything is fine.

The docker environment I supplied in the sample should easily reproduce this issue.

~Tim

@TimothyBlue

We will surely investigate the issue from this perspective and share updates with you as soon as we have some.

This issue is critical to our release and I would like to move it to our paid support forums.

Thank you,
~Tim

@TimothyBlue

Please create a post in paid support forum with the reference of logged ticket ID and your issue will be escalated accordingly.

The issues you have found earlier (filed as PDFNET-48451) have been fixed in this update.

I still have issue with special characters using in pdf.

I am using aspose.pdf.drawing library for pdf generation. Its licenced as well. I am getting error when there is a special character in the pdf. When we call document.Save(stream) and if the content is having any special character it shows error.

Aspose.PDF.Drawing" Version=“23.3.0”
Running using Docker (Linux).
Dotnet core 6

Any help will be appreciated.

I still have issue with special characters using in pdf.

I am using aspose.pdf.drawing library for pdf generation. Its licenced as well. I am getting error when there is a special character in the pdf. When we call document.Save(stream) and if the content is having any special character it shows error.

Aspose.PDF.Drawing" Version=“23.3.0”
Running using Docker (Linux).
Dotnet core 6

Any help will be appreciated.

@sijuvijayan

Would you please share your sample PDF along with the docker file for our reference? Please also share sample code snippet that you are using. We will create a dedicated ticket for your case and share the ID with you.

I still have issue with special characters using in pdf.

I am using aspose.pdf.drawing library for pdf generation. Its licenced as well. I am getting error when there is a special character in the pdf. When we call document.Save(stream) and if the content is having any special character it shows error. If the content not having any special character, then it work well as well.

Aspose.PDF.Drawing" Version=“23.3.0”
Running using Docker (Linux).
Dotnet core 6

Any help will be appreciated.

@sijuvijayan

Would you please share your sample PDF along with the docker file for our reference? Please also share sample code snippet that you are using. We will create a dedicated ticket for your case and share the ID with you.

Hi Asad Ali, @asad.ali
Thanks of the consideration.
Please see the sample code below

    [HttpGet(Name = "DownloadPdf")]
    public FileResult DownloadPdf(string pdfContent)
    {
        Document document = new()
        {
            CenterWindow = true
        };
        Page page = document.Pages.Add();
        Heading heading = new(1)
        {
            Text = pdfContent
        };
        page.Paragraphs.Add(heading);
        using MemoryStream stream = new();
        document.Save(stream);
        byte[] docBytes = stream.ToArray();

        FileContentResult fileContentResult = new(docBytes, "application/pdf")
        {
            FileDownloadName = "samplePdf"
        };

        return fileContentResult;
    }

While I am passing normal text its generating pdf and we are able to get this downloaded.

But when I am passing some special characters it throws below error. sample charectors for re producing : 源氏郎 具志
image.png (61.4 KB)
image.png (32.9 KB)

image.png (43.9 KB)

Docker file
#See Customize Docker containers in Visual Studio - Visual Studio (Windows) | Microsoft Learn to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY [“AsposePdfSpecialCharectIssue/AsposePdfSpecialCharectIssue.csproj”, “AsposePdfSpecialCharectIssue/”]
RUN dotnet restore “AsposePdfSpecialCharectIssue/AsposePdfSpecialCharectIssue.csproj”
COPY . .
WORKDIR “/src/AsposePdfSpecialCharectIssue”
RUN dotnet build “AsposePdfSpecialCharectIssue.csproj” -c Release -o /app/build

FROM build AS publish
RUN dotnet publish “AsposePdfSpecialCharectIssue.csproj” -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT [“dotnet”, “AsposePdfSpecialCharectIssue.dll”]

@sijuvijayan

We are checking it and will get back to you shortly.

@sijuvijayan

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-56309

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.