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

Free Support Forum - aspose.com

PDF from HTML with à in debian: NullReferenceException at Aspose.Pdf.Text.Font..ctor

Hi, I’m trying to convert HTML to PDF and I get it working on my local environment (Win10, dotnet2.2) with this code and the attached HTML file: html-sample.zip (2.1 KB)
I’ve also tried without *{ font-family: sans-serif }.

EDIT: More info about the error: the problem is caused by the à elements. When removed, it works fine both in local and in the server. It also fails with à characters.

The code I’m using is this:

var htmlLoadOptions = new HtmlLoadOptions(WWWROOT_PATH);
htmlLoadOptions.PageInfo.Width = PageSize.A4.Width;
htmlLoadOptions.PageInfo.Height = PageSize.A4.Height;
htmlLoadOptions.PageInfo.Margin.Bottom = 40;
htmlLoadOptions.PageInfo.Margin.Top = 72;
htmlLoadOptions.PageInfo.Margin.Left = 42;
htmlLoadOptions.PageInfo.Margin.Right = 42;

var pdf = new Document(htmlOutputFile, htmlLoadOptions)

When executing on the server (docker with linux via microsoft/dotnet:2.2-aspnetcore-runtime and microsoft/dotnet:2.2-sdk) I get the next error:

Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLP0GNPQBNJ4", Request id "0HLP0GNPQBNJ4:00000014": An unhandled exception was thrown by the application.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Aspose.Pdf.Text.Font..ctor(#=z_0JAOBNAg1k6f3wMMYAFwFo= #=ziBI$iwc=)
   at #=zxlvJK7zKQ1Tn3qiwnS026eLTqcpuC7Pc4Hp2AVNdPiTDJ_DcpfKjXjw=.#=z9Q1KDOUQlCaGo3pNrcttC_wmBFfN(String #=zZvq$R5s=, Font #=ziBI$iwc=, Font& #=zecv_xce41s$v_GLmLArZgWY=)
   at #=zNWH_ZPJtQISFVYfUiOSktXoHfHlq.#=zVeJQC2n$h_CB(String #=zJxV6XAs=)
   at Aspose.Pdf.Text.TextFragment.#=z_jDa4RfMyCT_(String #=zJxV6XAs=)
   at Aspose.Pdf.Text.TextFragment..ctor(String text)
   at #=zWimiH1M2dUtqygwEKsN$O12Ybx7hxet$KA==`1.#=zvvrJYK4=(String #=zJxV6XAs=, PointF #=zvlx3Tb0=)
   at #=z7p8xrirYdXlyAHoV1V8RhRPvBqhO1HNdQtjn54U=.#=zNBQj2ME=(#=zldeg9oVcbMByYl6Fo2IMnC1CR59yfIi6Pw== #=zIKwdbj3Mpz4L)
   at #=zldeg9oVcbMByYl6Fo2IMnC1CR59yfIi6Pw==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zUe0YYBzvxibWF_CraWHMgKcP6xr8uWrlNw==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=z4d0V6bXXNHZb$9q2W9FabXcQ8a1nPa2yAA==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zUe0YYBzvxibWF_CraWHMgKcP6xr8uWrlNw==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zOpTJLQyBNSLCTslVKnGxFubOdPeggDkI0g==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zUe0YYBzvxibWF_CraWHMgKcP6xr8uWrlNw==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zOpTJLQyBNSLCTslVKnGxFubOdPeggDkI0g==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zUe0YYBzvxibWF_CraWHMgKcP6xr8uWrlNw==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zOpTJLQyBNSLCTslVKnGxFubOdPeggDkI0g==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zUe0YYBzvxibWF_CraWHMgKcP6xr8uWrlNw==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=z4d0V6bXXNHZb$9q2W9FabXcQ8a1nPa2yAA==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zUe0YYBzvxibWF_CraWHMgKcP6xr8uWrlNw==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=z3n57ii7AgQDrIQPxVb8P67$B1hNkbgN81A==.#=zhk4YQP4=(#=zDxylM1IJbgZEKRMEuQceOjOarlvOrQJ1vg== #=zTTip7Iw=)
   at #=zKuYEebXWf3Tb1jX2Zq91FRlWQUxGHVhoUA==.#=zocfWcImvaYpB(#=zFDwv9zfyVIZ3XGTIAin7Fh4= #=zOCpCAhUczVPnAE511A==, #=zRMr7P5XggIHEPq1B$QpKeKFjDEKw[] #=zDOwlAm_y6IxC, #=zS0IWHtx_bWtoln7Dy5$cuTcJKhso #=zgJT_MRg=, TimeSpan #=zrLy8ioQ=)
   at #=zJu1MfnC6qu9MpGhSX8MjGe1W9eRX.Render(#=zS0IWHtx_bWtoln7Dy5$cuTcJKhso #=zgJT_MRg=, TimeSpan #=zrLy8ioQ=, #=z4UtAfmbHqGzLO9EQetSEotU=[] #=zJrEbD1s=)
   at #=zOx9cjl_bqnKAFAudAofFViq4Igl$.Render(#=zS0IWHtx_bWtoln7Dy5$cuTcJKhso #=zgJT_MRg=, #=zT045q1k= #=zN$orSnY=, TimeSpan #=zrLy8ioQ=)
   at #=zOx9cjl_bqnKAFAudAofFViq4Igl$.Render(#=zS0IWHtx_bWtoln7Dy5$cuTcJKhso #=zgJT_MRg=, #=zT045q1k= #=zN$orSnY=)
   at #=zmbJUxk9JUoLKMCEg_2MI8cuXQntb.#=z7GvScR4=(Stream #=zC4r$acmXfWr1, Document #=zBgPfC3TkBOiI, HtmlLoadOptions #=zt4SRwEpNaIrE, String #=z98oKR50X81EL)
   at #=zmbJUxk9JUoLKMCEg_2MI8cuXQntb.#=z7GvScR4=(Stream #=zC4r$acmXfWr1, Document #=zBgPfC3TkBOiI, HtmlLoadOptions #=zt4SRwEpNaIrE)
   at Aspose.Pdf.Document.#=zOWIJHPM=(Stream #=z3VIghSY=, LoadOptions #=zhQcyZY8=)
   at Aspose.Pdf.Document..ctor(String filename, LoadOptions options)
   at Xxxxx.Services.BusinessModelGenerateDocumentService.GenerateBusinessModelPdf(Int32 businessModelId) in /src/Xxxxx.Services/BusinessModelGenerateDocumentService.cs:line 102

I searched in the forums for a similar issue and I didn’t found anything.

EDIT: The os-release info of the container:

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Thanks!

More info about the error: the problem is caused by the à elements. When removed, it works fine both in local and in the server. It also fails with à characters.

@crul

We have logged an investigation ticket as PDFNET-46856 in our issue tracking system. We will further look into details of it and keep you posted on status of its resolution. Please be patient and spare us little time.

We are sorry for the inconvenience.

@asad.ali Thanks!

Regarding technical support; I understand the limitations for Trial versions (which is what we’re using). If I had found a workaround, we would purchase it and wait for a proper solution, but right now it’s not functional enough to commit to it.

I look forward to any news.
Thanks again.

@crul

We have logged your concerns along with the issue and will definitely consider them during issue investigation. We will let you know as soon as we have some definite updates in this regard. Please spare us little time.

We are sorry for the inconvenience.

1 Like

@crul

We are investigating the earlier logged ticket and will share our findings with you soon. However, would you kindly provide your docker file for our reference. This would help us investigating the ticket accordingly.