Unicode Character Issue when Generating Aspose PDF (.Net) from HTML in Linux Container

Hi Team,
We have license for Aspose. We are trying to generate PDF from HTML which contains some unicode characters like ballot box ☒
On windows OS, it is working fine but such characters are not recognized on Linux containers.
Following are the details to reproduce,

  • Nuget Library - Aspose.PDF / Aspose.PDF.Drawing (Any)
  • Technology Stack - (Azure Functions) (C#) (.Net 6)
  • OS - Linux (Debian 11)
  • Containerization - Yes
  • Base Image - mcr.microsoft.com/azure-functions/dotnet:4

We have already tried below options,

  • Installed MS truetype fonts (added “apt-get install -y ttf-mscorefonts-installer fontconfig” in dockerfile)
  • Installed unicode, ttf-unifont & font-noto via dockerfile
  • Set locale culture to en_US.UTF-8
  • Explicitly set UTF-8 encoding in Aspose HtmlLoadOptions, HtmlFragment.TextState
  • Explicitly set unicode font in Aspose HtmlFragment.TextState

However, nothing has solved the issue. Could you please guide us on this?

@ShripalNahata

If possible, can you please provide the code snippet that you are using along with sample HTML and generated PDF document? We will log an investigation ticket and share the ID with you.

Hi @asad.ali ,
Following is the code snippet and also attached the sample HTML.

var _pdfDocument = new Document();
Page dummyInfoPage1 = _pdfDocument.Pages.Add(); 
var dummyInfoHtml = RenderView("DummyInfo", dummyInfoModel);
HtmlFragment htmlFragment = new(dummyInfoHtml);
dummyInfoPage1.Paragraphs.Add(htmlFragment);
using (var stream = new MemoryStream())
{
    _pdfDocument.Save(stream);
}

private string RenderView(string viewName, object model)
{
	string templateText = System.IO.File.ReadAllText("path to razor view");

	IRazorEngineCompiledTemplate template = _razorEngine.Compile(templateText, x =>
	{
		x.AddAssemblyReference(typeof(Constants.QuestionType));
	});

	string result = template.Run(model);
	return result;
}

Aspose Html Sample.docx (15.4 KB)

@ShripalNahata

Would it also be possible for you to share your docker file? We need to check how you are installing fonts and how your docker file looks so that we can perform investigation in respective environment?

@asad.ali docker file

FROM mcr.microsoft.com/azure-functions/dotnet:4 AS final
ARG INSTALL_WIN_FONT
ARG INSTALL_GDIPLUS
RUN if [ "$INSTALL_GDIPLUS" = "true" ]; then \
        apt-get update && apt-get install -y libgdiplus ; \
    fi
RUN if [ "$INSTALL_WIN_FONT" = "true" ]; then \
        sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list && \
        apt-get update && \
        apt-get install -y ttf-mscorefonts-installer fontconfig ; \
    fi
WORKDIR /home/site/wwwroot
COPY . .
ARG PORT=5457   # default PORT
EXPOSE ${PORT}
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

@ShripalNahata

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-56734

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.

1 Like

@asad.ali Actually, we have the ASPOSE PDF license, but was not sure about point of contact or support email to raise the issue. So, raised on this platform.

@ShripalNahata

You reported the issue at right place. We have logged the ticket in order to rectify the issue that you are facing. As soon as the ticket is resolved, we will update you via this forum thread. Please spare us some time.

1 Like

Hi @asad.ali , I see that issue status is Open for PDFNET-56734 in bottom of this post. Is there any link where I can see detailed status or timeline?

@ShripalNahata

The issue is logged in our internal issue management system and we are afraid that you cannot access it. However, we will keep you posted within this forum thread once we make some progress towards ticket resolution. Please be patient and spare us some time.

1 Like