Aspose.PDF Html-To-PDF Japanese Fonts issue on Linux container

Hi there,

We’re facing production issues when trying to generate PDF from a HTML that contains Japanese text on a linux container (kubernetes).

Here’s the error stacktrace:

2024-07-18 12:13:13.8206|ERROR|Microsoft.AspNetCore.Server.Kestrel|Connection id "0HN571FRAEMKI", Request id "0HN571FRAEMKI:00000003": An unhandled exception was thrown by the application.|System.NullReferenceException: Object reference not set to an instance of an object.
   at #=zvTxKLI1OlGQU7jHc4HTDSZpoumyslyHBhEGdOflBNBYc.#=zpdYKRGk=(#=zXFI$PkwD5mclRyda7K$ek8w= #=zyJSjC8Y=, Boolean #=z6CXU3DrCRaay, Boolean #=zvjEU4jk=, Boolean #=zBxy3WBk=)
   at #=zvTxKLI1OlGQU7jHc4HTDSZpoumyslyHBhEGdOflBNBYc.#=zZbNOkNbuhZ8NHShG9g==(#=zThOTcVS7vx_xnMB8_b7S8JaxPM8$b5joIrReTeU= #=zrQYCh$Y=, #=zXFI$PkwD5mclRyda7K$ek8w= #=zyJSjC8Y=, Boolean #=zvjEU4jk=, Boolean #=zBxy3WBk=, String& #=zZMZL3LM=)
   at #=zHs8i4O_2tzemSlkWtw2VJwjSxA2eoYqQz9jQO72zLFKQI935ec_jZ__cQu6Q1H7IGvgbxTKl0kqZ.#=zuyUE7IZ7BV9nEnpFgg==(String #=z1yTkQw4=, #=zThOTcVS7vx_xnMB8_b7S8JaxPM8$b5joIrReTeU= #=zrQYCh$Y=, #=zxx9TNoWXDpxvyA5SAQOBi$L1mH2uTIkhBwyw5562Wh
65iE15E$pV65c= #=zaCXgNVgmVjsU, Boolean #=zvjEU4jk=, Boolean #=zBxy3WBk=, #=z9gVuRkYFRMCEQGyA6LjnOYrHbqMN8TWcEPqb5HSzPYIQ #=zwHYmGgg=, #=zjH3VutoxAH1gxdWjdCYBTMnvMgR1GnWRuQ==& #=zmpKQG7c=, #=z_9ObQQ9GU3KJNKcr2VBtGVWkJHjRlNtxJ4tGzZoU7nje& #=zUCLsqpXZKkVp, String& #=zy3ZYzH7j1VpX)
   at #=zdiGXry6g1aGRA7ztT4ArNuCp4iuYJbqT6DQScuV6Tw7suCmdlt5EXM4=.#=zI6o7$HEZaBg6QhbPtA==(#=zs1$sfY4961tYkQ8nfbEBn$Oyh51LI9QTlgdtAjCq48iIlIZ4vQPxHeSyHZuULC_9xkhluY6yU0tXAt0Hhg==[] #=zT2mIiX6txX7dRdWt1shv$1E73Tv5, String #=z1yTkQw4=,
 #=zThOTcVS7vx_xnMB8_b7S8JaxPM8$b5joIrReTeU= #=zrQYCh$Y=, #=zxx9TNoWXDpxvyA5SAQOBi$L1mH2uTIkhBwyw5562Wh65iE15E$pV65c= #=zaCXgNVgmVjsU, Boolean #=zvjEU4jk=, Boolean #=zBxy3WBk=, #=z9gVuRkYFRMCEQGyA6LjnOYrHbqMN8TWcEPqb5HSzPYIQ #=zwHYmGgg=, #=zjH3VutoxAH1gxdWjdCYBTMnvMgR1GnWRuQ==& #=ziamEq1Q=, #=z_9ObQQ9GU3KJNKcr2VBtGVWkJHjRlNtxJ4tGzZoU7nje& #=zUCLsqpXZKkVp, String& #=zy3ZYzH7j1VpX)
   at #=z8pYDI6kogR3x8TNhrL$jD4A7ADzHVqd86$Q1uNYsMJnqMy_F8Q==.#=zimKF$tMys4rE(#=zHAIHFjk_J9Fj_BEpC01tdAsQb4eyAiGZPQ== #=zI6g_YkY=, TextEditOptions #=z5hrkyKQ=)
   at Aspose.Pdf.Text.TextSegment.set_Text(String value)
   at Aspose.Pdf.Text.TextSegment.#=zjhFZ81k=(#=zCMe860x6aToji5WldQw2$LPOa2JLddSB2dueen_rdR_GSJzvOKam2$Y= #=zxtVdWA6Kirin)
   at Aspose.Pdf.Text.TextBuilder.#=z2p5Hlkg=(TextFragment #=zXdbXckqij_BM, Int32 #=zjw7sj0s=, Boolean #=zyzo4YJI88VPi)
   at #=z02F$bS3F8EizCFCGcU9sQR9i6cdx$T75Fw==.#=zqWdT1OM=(String #=zCabdGDE=, PointF #=zX3in$2g=)
   at #=zyVdZLS0AGlajKX92dejVm5Lc0zyI.#=z1N1vBbk=(#=zEl1Cj3zjyEEdK$N37Bk7cgV8eDkIZDvnAQ== #=z2FyujrSj4_Ux, Boolean #=ztYY3iFQ9fadeG5IcPQ==, #=zc8AGRFtSiM62OMzL0G6ZOjOz0LSSnWfBUw== #=zx9_GDlA=)
   at #=zyVdZLS0AGlajKX92dejVm5Lc0zyI.#=zLSooC3YKHIjW(#=zKJFxxLDcodxlcjXCBmKB5eN8EhYEKscDxA== #=zQxXJrA8=, Boolean #=ztYY3iFQ9fadeG5IcPQ==, #=zc8AGRFtSiM62OMzL0G6ZOjOz0LSSnWfBUw== #=zx9_GDlA=)
   at #=zyVdZLS0AGlajKX92dejVm5Lc0zyI.#=zAXpUZF3lkHWbPFcppA==(#=zJ4GAc93I0OjSgY7iVw== #=z7ZLSNq0Dlt_I2$gwqQ==, Boolean #=ztYY3iFQ9fadeG5IcPQ==, #=zc8AGRFtSiM62OMzL0G6ZOjOz0LSSnWfBUw== #=zx9_GDlA=)
   at #=zyVdZLS0AGlajKX92dejVm5Lc0zyI.#=zHOWmhEw=(#=zwe0A3gNaeqtNruvXjumaiha5ZbsFuVCTWg== #=zi5nCRvI=, #=zEy39tdb9UrGgmr1QJQ== #=z7ZLSNq0Dlt_I2$gwqQ==, Boolean #=ztYY3iFQ9fadeG5IcPQ==, #=zc8AGRFtSiM62OMzL0G6ZOjOz0LSSnWfBUw== #=zx9_GDlA=)
   at #=zRbyTmJpmDz5mZpmZdSBbUj1jtb3XETB0rw==.Render(#=zfpXws1Rj_9psYg6f_94Ofj8Js97G #=zKg5_s7w=, CancellationToken #=zLwJ3Aog=)
   at #=zLXnFpPvoqGgtZGSvS1MDbCzsFSAH.#=znV_aDKKLrzwb(#=zc6MQDGZaacmHf$nYiTvoqq4= #=z9PhS86XlYSDI$3hZgA==, #=z0DLAXrb0fZNT29zV62LRvt7EIpf0[] #=zzDGP6AaZw1A5, #=zfpXws1Rj_9psYg6f_94Ofj8Js97G #=zKg5_s7w=, CancellationToken #=z4MKdEXo=)
   at #=zr1Xx6Wl0tiVOQW8nPJB1qKjFfQev.Render(#=zfpXws1Rj_9psYg6f_94Ofj8Js97G #=zKg5_s7w=, CancellationToken #=z4MKdEXo=, #=zcqCKb61vpl7VBBUtIIY_HBU=[] #=zKaquk2o=, #=zZlq9MYtsOy9qU6dxppicPoc=[] #=z530$eOI=)
   at #=zr1Xx6Wl0tiVOQW8nPJB1qKjFfQev.Render(#=zfpXws1Rj_9psYg6f_94Ofj8Js97G #=zKg5_s7w=, TimeSpan #=zyT3ghRw=, #=zZbDD4BJwG4gq6k8yhXJ$sdY=[] #=z4kGKS7Q=)
   at #=zU3jNWfjjms0sVo0gFrhp5ehb7tFu.Render(#=zfpXws1Rj_9psYg6f_94Ofj8Js97G #=zKg5_s7w=, #=z1GZiE$s= #=ziz9w4mo=, TimeSpan #=zyT3ghRw=)
   at #=zhV6jTDqy0$KjrNSWhalA2nTG_4mZ.#=z52TR86xZi3FY(Stream #=zkItnLb5$_f5E, Document #=z9dCksvh4gxIx, HtmlLoadOptions #=z9PMoY9yovmYe, String #=zWRQwgoBW_BzB)
   at #=zhV6jTDqy0$KjrNSWhalA2nTG_4mZ.#=zC2bSPhs=(Stream #=zkItnLb5$_f5E, Document #=z9dCksvh4gxIx, HtmlLoadOptions #=z9PMoY9yovmYe, String #=zWRQwgoBW_BzB)
   at #=zhV6jTDqy0$KjrNSWhalA2nTG_4mZ.#=zC2bSPhs=(Stream #=zkItnLb5$_f5E, Document #=z9dCksvh4gxIx, HtmlLoadOptions #=z9PMoY9yovmYe)
   at Aspose.Pdf.Document.#=zSRfH2Dg=(Stream #=zEmiolq4=, LoadOptions #=z5hrkyKQ=, Boolean #=zVH6uFEdCPybM)
   at Aspose.Pdf.Document..ctor(Stream input, LoadOptions options)
   at RystadEnergy.Shared.FileUtilities.Services.Aspose.BaseHtmlToPdfGenerator`1.GenerateForHtml(String mainContentHtml, T metadata)
   at RystadEnergy.FileServices.Domain.Service.Aspose.AsposeDocumentHtmlToPdfFileService.GeneratePdfFromHtml(DocumentHtmlToPdfGenerationMetaData metaData) in C:\data\Rystad Energy\RystadEnergy.FileServices\RystadEnergy.FileServices.Domain\Service\Aspose\AsposeDocumentHtmlToPdfFileService.cs:line 33
   at RystadEnergy.FileServices.RestApi.V1.Controllers.HtmlToPdfController.GenerateDocumentPdfFromHtml(DocumentHtmlToPdfGenerationViewModel metadataViewModel) in C:\data\Rystad Energy\RystadEnergy.FileServices\RystadEnergy.FileServices.RestApi\V1\Controllers\HtmlToPdfController.cs:line 48
   at lambda_method53(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Here’s the Dockerfile contents

FROM <Ubuntu 20.04.4 LTS  image>
RUN apt update && apt install tzdata -y
RUN apt-get update \
    && apt-get install -y --no-install-recommends  \
        libgdiplus  \
        libc6-dev \
        fonts-noto-cjk \
        fonts-ipafont-mincho \
        fonts-ipafont-gothic \
        libfontconfig \
        libfreetype6 \
        xfonts-cyrillic \
        xfonts-scalable \
        fonts-liberation \
        fonts-wqy-zenhei \
        fonts-tlwg-loma-otf \
        ttf-ubuntu-font-family \
        fonts-arphic-ukai \
        fonts-arphic-uming \
        fonts-unfonts-core \
        language-pack-ja \
        japan* \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*
ENV TZ="Europe/Oslo"
COPY bin/Release/net6.0/linux-x64/publish/ App/
WORKDIR /App
ENTRYPOINT ["bootstrap", "FileServices.RestApi.dll"]

It works fine for Chinese fonts, but not Japanese and Cyrillic.
On Windows - there aren’t any issues with the fonts.

If I run: fc-list from within the container, this is what I get:

root@61592adb1995:/App# fc-list :lang=ja
/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc: Noto Serif CJK SC:style=Bold
/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc: Noto Serif CJK TC:style=Bold
/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc: Noto Serif CJK JP:style=Bold
/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc: Noto Serif CJK KR:style=Bold
/usr/share/fonts/opentype/ipafont-mincho/ipam.ttf: IPAMincho,IPA明朝:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans CJK JP:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans CJK HK:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans CJK KR:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans CJK SC:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans CJK TC:style=Regular
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: WenQuanYi Zen Hei,文泉驛正黑,文泉驿正黑:style=Regular
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: WenQuanYi Zen Hei Sharp,文泉驛點陣正黑,文泉驿点阵正黑:style=Regular
/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc: Noto Serif CJK SC:style=Regular
/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc: Noto Serif CJK TC:style=Regular
/usr/share/fonts/opentype/ipaexfont-gothic/ipaexg.ttf: IPAexGothic,IPAexゴシック:style=Regular
/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc: Noto Serif CJK JP:style=Regular
/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc: Noto Serif CJK KR:style=Regular
/usr/share/fonts/opentype/ipafont-gothic/ipagp.ttf: IPAPGothic,IPA Pゴシック:style=Regular
/usr/share/fonts/opentype/ipaexfont-mincho/ipaexm.ttf: IPAexMincho,IPAex明朝:style=Regular
/usr/share/fonts/opentype/ipafont-mincho/ipamp.ttf: IPAPMincho,IPA P明朝:style=Regular
/usr/share/fonts/opentype/ipafont-gothic/ipag.ttf: IPAGothic,IPAゴシック:style=Regular
/usr/share/fonts/truetype/fonts-japanese-mincho.ttf: IPAexMincho,IPAex明朝:style=Regular
/usr/share/fonts/truetype/fonts-japanese-gothic.ttf: IPAexGothic,IPAexゴシック:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans Mono CJK TC:style=Bold
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans Mono CJK SC:style=Bold
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans Mono CJK KR:style=Bold
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans Mono CJK HK:style=Bold
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans Mono CJK JP:style=Bold
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: WenQuanYi Zen Hei Mono,文泉驛等寬正黑,文泉驿等宽正黑:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans Mono CJK SC:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans Mono CJK TC:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans Mono CJK HK:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans Mono CJK KR:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans Mono CJK JP:style=Regular
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans CJK JP:style=Bold
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans CJK KR:style=Bold
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans CJK HK:style=Bold
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans CJK TC:style=Bold
/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc: Noto Sans CJK SC:style=Bold

If I run dpkg -l:

root@61592adb1995:/App# dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                           Architecture Description
+++-=========================================-=================================-============-=============================================================================
ii  adduser                                   3.118ubuntu2                      all          add and remove users and groups
ii  apt                                       2.0.6                             amd64        commandline package manager
ii  base-files                                11ubuntu5.5                       amd64        Debian base system miscellaneous files
ii  base-passwd                               3.5.47                            amd64        Debian base system master password and group files
ii  bash                                      5.0-6ubuntu1.1                    amd64        GNU Bourne Again SHell
ii  bind9-host                                1:9.16.1-0ubuntu2.10              amd64        DNS Lookup Utility
ii  bind9-libs:amd64                          1:9.16.1-0ubuntu2.10              amd64        Shared Libraries used by BIND 9
ii  bsdutils                                  1:2.34-0.1ubuntu9.3               amd64        basic utilities from 4.4BSD-Lite
ii  bzip2                                     1.0.8-2                           amd64        high-quality block-sorting file compressor - utilities
ii  ca-certificates                           20210119~20.04.2                  all          Common CA certificates
ii  coreutils                                 8.30-3ubuntu2                     amd64        GNU core utilities
ii  dash                                      0.5.10.2-6                        amd64        POSIX-compliant shell
ii  debconf                                   1.5.73                            all          Debian configuration management system
ii  debianutils                               4.9.1                             amd64        Miscellaneous utilities specific to Debian
ii  diffutils                                 1:3.7-3                           amd64        File comparison utilities
ii  dpkg                                      1.19.7ubuntu3                     amd64        Debian package management system
ii  e2fsprogs                                 1.45.5-2ubuntu1                   amd64        ext2/ext3/ext4 file system utilities
ii  emacsen-common                            3.0.4                             all          Common facilities for all emacsen
ii  fdisk                                     2.34-0.1ubuntu9.3                 amd64        collection of partitioning utilities
ii  findutils                                 4.7.0-1ubuntu1                    amd64        utilities for finding files--find, xargs
ii  fontconfig                                2.13.1-2ubuntu3                   amd64        generic font configuration library - support binaries
ii  fontconfig-config                         2.13.1-2ubuntu3                   all          generic font configuration library - configuration
ii  fonts-arphic-ukai                         0.2.20080216.2-5                  all          "AR PL UKai" Chinese Unicode TrueType font collection Kaiti style
ii  fonts-arphic-uming                        0.2.20080216.2-10ubuntu2          all          "AR PL UMing" Chinese Unicode TrueType font collection Mingti style
ii  fonts-ipaexfont-gothic                    00301-4ubuntu1                    all          Japanese OpenType font, IPAex Gothic Font
ii  fonts-ipaexfont-mincho                    00301-4ubuntu1                    all          Japanese OpenType font, IPAex Mincho Font
ii  fonts-ipafont-gothic                      00303-18ubuntu1                   all          Japanese OpenType font set, IPA Gothic and IPA P Gothic Fonts
ii  fonts-ipafont-mincho                      00303-18ubuntu1                   all          Japanese OpenType font set, IPA Mincho and IPA P Mincho Fonts
ii  fonts-liberation                          1:1.07.4-11                       all          Fonts with the same metrics as Times, Arial and Courier
ii  fonts-lmodern                             2.004.5-6                         all          OpenType fonts based on Computer Modern
ii  fonts-noto-cjk                            1:20190410+repack1-2              all          "No Tofu" font families with large Unicode coverage (CJK regular and bold)
ii  fonts-tlwg-loma-otf                       1:0.7.1-3                         all          Thai Loma OpenType font
ii  fonts-ubuntu                              0.83-4ubuntu1                     all          sans-serif font set from Ubuntu
ii  fonts-unfonts-core                        1:1.0.2-080608-16                 all          Un series Korean TrueType fonts
ii  fonts-wqy-zenhei                          0.9.45-7ubuntu1                   all          "WenQuanYi Zen Hei" A Hei-Ti Style (sans-serif) Chinese font
ii  gcc-10-base:amd64                         10.5.0-1ubuntu1~20.04             amd64        GCC, the GNU Compiler Collection (base package)
ii  gpgv                                      2.2.19-3ubuntu2.1                 amd64        GNU privacy guard - signature verification tool
ii  grep                                      3.4-1                             amd64        GNU grep, egrep and fgrep
ii  gzip                                      1.10-0ubuntu4.1                   amd64        GNU compression utilities
ii  hostname                                  3.23                              amd64        utility to set/show the host name or domain name
ii  init-system-helpers                       1.57                              all          helper tools for all init systems
ii  japa                                      0.9.2-1                           amd64        JACK and ALSA Perceptual Analyser
ii  krb5-config                               2.6ubuntu1                        all          Configuration files for Kerberos Version 5
ii  krb5-user                                 1.17-6ubuntu4.1                   amd64        basic programs to authenticate using MIT Kerberos
ii  kstart                                    4.2-2                             amd64        Kerberos kinit supporting AFS and ticket refreshing
ii  language-pack-ja                          1:20.04+20220818                  all          translation updates for language Japanese
ii  language-pack-ja-base                     1:20.04+20220818                  all          translations for language Japanese
ii  latex-cjk-common                          4.8.4+git20170127-2               amd64        LaTeX macro package for CJK (Chinese/Japanese/Korean)
ii  latex-cjk-japanese                        4.8.4+git20170127-2               amd64        Japanese module of LaTeX CJK
ii  latex-cjk-japanese-wadalab                0.20050817-17                     all          type1 and tfm DNP Japanese fonts for latex-cjk
ii  libacl1:amd64                             2.2.53-6                          amd64        access control list - shared library
ii  libapt-pkg6.0:amd64                       2.0.6                             amd64        package management runtime library
ii  libasound2:amd64                          1.2.2-2.1ubuntu2.5                amd64        shared library for ALSA applications
ii  libasound2-data                           1.2.2-2.1ubuntu2.5                all          Configuration files and profiles for ALSA drivers
ii  libattr1:amd64                            1:2.4.48-5                        amd64        extended attribute handling - shared library
ii  libaudit-common                           1:2.8.5-2ubuntu6                  all          Dynamic library for security auditing - common files
ii  libaudit1:amd64                           1:2.8.5-2ubuntu6                  amd64        Dynamic library for security auditing
ii  libblkid1:amd64                           2.34-0.1ubuntu9.3                 amd64        block device ID library
ii  libbsd0:amd64                             0.10.0-1                          amd64        utility functions from BSD systems - shared library
ii  libbz2-1.0:amd64                          1.0.8-2                           amd64        high-quality block-sorting file compressor library - runtime
ii  libc-bin                                  2.31-0ubuntu9.7                   amd64        GNU C Library: Binaries
ii  libc-dev-bin                              2.31-0ubuntu9.16                  amd64        GNU C Library: Development binaries
ii  libc6:amd64                               2.31-0ubuntu9.16                  amd64        GNU C Library: Shared libraries
ii  libc6-dev:amd64                           2.31-0ubuntu9.16                  amd64        GNU C Library: Development Libraries and Header Files
ii  libcairo2:amd64                           1.16.0-4ubuntu1                   amd64        Cairo 2D vector graphics library
ii  libcap-ng0:amd64                          0.7.9-2.1build1                   amd64        An alternate POSIX capabilities library
ii  libclthreads2:amd64                       2.4.2-1build1                     amd64        POSIX threads C++ access library  (shared library)
ii  libclxclient3:amd64                       3.9.2-1                           amd64        X Window System C++ access library (shared library)
ii  libcom-err2:amd64                         1.45.5-2ubuntu1                   amd64        common error description library
ii  libcrypt-dev:amd64                        1:4.4.10-10ubuntu4                amd64        libcrypt development files
ii  libcrypt1:amd64                           1:4.4.10-10ubuntu4                amd64        libcrypt shared library
ii  libdb5.3:amd64                            5.3.28+dfsg1-0.6ubuntu2           amd64        Berkeley v5.3 Database Libraries [runtime]
ii  libdebconfclient0:amd64                   0.251ubuntu1                      amd64        Debian Configuration Management System (C-implementation library)
ii  libexif12:amd64                           0.6.21-6ubuntu0.4                 amd64        library to parse EXIF files
ii  libexpat1:amd64                           2.2.9-1ubuntu0.6                  amd64        XML parsing C library - runtime library
ii  libext2fs2:amd64                          1.45.5-2ubuntu1                   amd64        ext2/ext3/ext4 file system libraries
ii  libfdisk1:amd64                           2.34-0.1ubuntu9.3                 amd64        fdisk partitioning library
ii  libffi7:amd64                             3.3-4                             amd64        Foreign Function Interface library runtime
ii  libfftw3-single3:amd64                    3.3.8-2ubuntu1                    amd64        Library for computing Fast Fourier Transforms - Single precision
ii  libfontconfig1:amd64                      2.13.1-2ubuntu3                   amd64        generic font configuration library - runtime
ii  libfontenc1:amd64                         1:1.1.4-0ubuntu1                  amd64        X11 font encoding library
ii  libfreetype6:amd64                        2.10.1-2ubuntu0.3                 amd64        FreeType 2 font engine, shared library files
ii  libgcc-s1:amd64                           10.5.0-1ubuntu1~20.04             amd64        GCC support library
ii  libgcc1                                   1:10.5.0-1ubuntu1~20.04           amd64        GCC support library (dependency package)
ii  libgcrypt20:amd64                         1.8.5-5ubuntu1.1                  amd64        LGPL Crypto library - runtime library
ii  libgdbm-compat4:amd64                     1.18.1-5                          amd64        GNU dbm database routines (legacy support runtime version) 
ii  libgdbm6:amd64                            1.18.1-5                          amd64        GNU dbm database routines (runtime version) 
ii  libgdiplus                                6.0.4+dfsg-2                      amd64        interface library for System.Drawing of Mono
ii  libgif7:amd64                             5.1.9-1ubuntu0.1                  amd64        library for GIF images (library)
ii  libglib2.0-0:amd64                        2.64.6-1~ubuntu20.04.7            amd64        GLib library of C routines
ii  libgmp10:amd64                            2:6.2.0+dfsg-4                    amd64        Multiprecision arithmetic library
ii  libgnutls30:amd64                         3.6.13-2ubuntu1.6                 amd64        GNU TLS library - main runtime library
ii  libgomp1:amd64                            10.5.0-1ubuntu1~20.04             amd64        GCC OpenMP (GOMP) support library
ii  libgpg-error0:amd64                       1.37-1                            amd64        GnuPG development runtime library
ii  libgraphite2-3:amd64                      1.3.13-11build1                   amd64        Font rendering engine for Complex Scripts -- library
ii  libgssapi-krb5-2:amd64                    1.17-6ubuntu4.1                   amd64        MIT Kerberos runtime libraries - krb5 GSS-API Mechanism
ii  libgssrpc4:amd64                          1.17-6ubuntu4.1                   amd64        MIT Kerberos runtime libraries - GSS enabled ONCRPC
ii  libharfbuzz-icu0:amd64                    2.6.4-1ubuntu4.2                  amd64        OpenType text shaping engine ICU backend
ii  libharfbuzz0b:amd64                       2.6.4-1ubuntu4.2                  amd64        OpenType text shaping engine (shared library)
ii  libhogweed5:amd64                         3.5.1+really3.5.1-2ubuntu0.2      amd64        low level cryptographic library (public-key cryptos)
ii  libice6:amd64                             2:1.0.10-0ubuntu1                 amd64        X11 Inter-Client Exchange library
ii  libicu66:amd64                            66.1-2ubuntu2.1                   amd64        International Components for Unicode
ii  libidn2-0:amd64                           2.2.0-2                           amd64        Internationalized domain names (IDNA2008/TR46) library
ii  libjack-jackd2-0:amd64                    1.9.12~dfsg-2ubuntu2              amd64        JACK Audio Connection Kit (libraries)
ii  libjbig0:amd64                            2.1-3.1ubuntu0.20.04.1            amd64        JBIGkit libraries
ii  libjpeg-turbo8:amd64                      2.0.3-0ubuntu1.20.04.3            amd64        IJG JPEG compliant runtime library.
ii  libjpeg8:amd64                            8c-2ubuntu8                       amd64        Independent JPEG Group's JPEG runtime library (dependency package)
ii  libjson-c4:amd64                          0.13.1+dfsg-7ubuntu0.3            amd64        JSON manipulation library - shared library
ii  libk5crypto3:amd64                        1.17-6ubuntu4.1                   amd64        MIT Kerberos runtime libraries - Crypto Library
ii  libkadm5clnt-mit11:amd64                  1.17-6ubuntu4.1                   amd64        MIT Kerberos runtime libraries - Administration Clients
ii  libkadm5srv-mit11:amd64                   1.17-6ubuntu4.1                   amd64        MIT Kerberos runtime libraries - KDC and Admin Server
ii  libkdb5-9:amd64                           1.17-6ubuntu4.1                   amd64        MIT Kerberos runtime libraries - Kerberos database
ii  libkeyutils1:amd64                        1.6-6ubuntu1                      amd64        Linux Key Management Utilities (library)
ii  libkpathsea6:amd64                        2019.20190605.51237-3ubuntu0.2    amd64        TeX Live: path search library for TeX (runtime part)
ii  libkrb5-3:amd64                           1.17-6ubuntu4.1                   amd64        MIT Kerberos runtime libraries
ii  libkrb5support0:amd64                     1.17-6ubuntu4.1                   amd64        MIT Kerberos runtime libraries - Support library
ii  liblmdb0:amd64                            0.9.24-1                          amd64        Lightning Memory-Mapped Database shared library
ii  liblz4-1:amd64                            1.9.2-2ubuntu0.20.04.1            amd64        Fast LZ compression algorithm library - runtime
ii  liblzma5:amd64                            5.2.4-1ubuntu1.1                  amd64        XZ-format compression library
ii  libmaxminddb0:amd64                       1.4.2-0ubuntu1.20.04.1            amd64        IP geolocation database library
ii  libmount1:amd64                           2.34-0.1ubuntu9.3                 amd64        device mounting library
ii  libmpfr6:amd64                            4.0.2-1                           amd64        multiple precision floating-point computation
ii  libncurses6:amd64                         6.2-0ubuntu2                      amd64        shared libraries for terminal handling
ii  libncursesw6:amd64                        6.2-0ubuntu2                      amd64        shared libraries for terminal handling (wide character support)
ii  libnettle7:amd64                          3.5.1+really3.5.1-2ubuntu0.2      amd64        low level cryptographic library (symmetric and one-way cryptos)
ii  libp11-kit0:amd64                         0.23.20-1ubuntu0.1                amd64        library for loading and coordinating access to PKCS#11 modules - runtime
ii  libpam-krb5:amd64                         4.8-2ubuntu1                      amd64        PAM module for MIT Kerberos
ii  libpam-modules:amd64                      1.3.1-5ubuntu4.3                  amd64        Pluggable Authentication Modules for PAM
ii  libpam-modules-bin                        1.3.1-5ubuntu4.3                  amd64        Pluggable Authentication Modules for PAM - helper binaries
ii  libpam-runtime                            1.3.1-5ubuntu4.3                  all          Runtime support for the PAM library
ii  libpam0g:amd64                            1.3.1-5ubuntu4.3                  amd64        Pluggable Authentication Modules library
ii  libpaper-utils                            1.1.28                            amd64        library for handling paper characteristics (utilities)
ii  libpaper1:amd64                           1.1.28                            amd64        library for handling paper characteristics
ii  libpcre2-8-0:amd64                        10.34-7                           amd64        New Perl Compatible Regular Expression Library- 8 bit runtime files
ii  libpcre3:amd64                            2:8.39-12build1                   amd64        Old Perl 5 Compatible Regular Expression Library - runtime files
ii  libperl5.30:amd64                         5.30.0-9ubuntu0.5                 amd64        shared Perl library
ii  libpixman-1-0:amd64                       0.38.4-0ubuntu2.1                 amd64        pixel-manipulation library for X and cairo
ii  libpng16-16:amd64                         1.6.37-2                          amd64        PNG library - runtime (version 1.6)
ii  libprocps8:amd64                          2:3.3.16-1ubuntu2.3               amd64        library for accessing process information from /proc
ii  libptexenc1:amd64                         2019.20190605.51237-3ubuntu0.2    amd64        TeX Live: pTeX encoding library
ii  libreadline8:amd64                        8.0-4                             amd64        GNU readline and history libraries, run-time libraries
ii  libruby2.7:amd64                          2.7.0-5ubuntu1.14                 amd64        Libraries necessary to run Ruby 2.7
ii  librust-encoding-index-japanese-dev:amd64 1.20141219.5-1                    amd64        Index tables for Japanese character encodings - Rust source code
ii  librust-encoding-index-tests-dev:amd64    0.1.4-1                           amd64        Helper macros to test index tables for character encodings - Rust source code
ii  libsamplerate0:amd64                      0.1.9-2                           amd64        Audio sample rate conversion library
ii  libseccomp2:amd64                         2.5.1-1ubuntu1~20.04.2            amd64        high level interface to Linux seccomp filter
ii  libselinux1:amd64                         3.0-1build2                       amd64        SELinux runtime shared libraries
ii  libsemanage-common                        3.0-1build2                       all          Common files for SELinux policy management libraries
ii  libsemanage1:amd64                        3.0-1build2                       amd64        SELinux policy management library
ii  libsepol1:amd64                           3.0-1                             amd64        SELinux library for manipulating binary security policies
ii  libsm6:amd64                              2:1.2.3-1                         amd64        X11 Session Management library
ii  libsmartcols1:amd64                       2.34-0.1ubuntu9.3                 amd64        smart column output alignment library
ii  libss2:amd64                              1.45.5-2ubuntu1                   amd64        command-line interface parsing library
ii  libssl1.1:amd64                           1.1.1f-1ubuntu2.12                amd64        Secure Sockets Layer toolkit - shared libraries
ii  libstdc++6:amd64                          10.5.0-1ubuntu1~20.04             amd64        GNU Standard C++ Library v3
ii  libsynctex2:amd64                         2019.20190605.51237-3ubuntu0.2    amd64        TeX Live: SyncTeX parser library
ii  libsystemd0:amd64                         245.4-4ubuntu3.16                 amd64        systemd utility library
ii  libtasn1-6:amd64                          4.16.0-2                          amd64        Manage ASN.1 structures (runtime)
ii  libteckit0:amd64                          2.5.8+ds2-5ubuntu2                amd64        Encoding conversion library
ii  libtexlua53:amd64                         2019.20190605.51237-3ubuntu0.2    amd64        TeX Live: Lua 5.3, modified for use with LuaTeX
ii  libtexluajit2:amd64                       2019.20190605.51237-3ubuntu0.2    amd64        TeX Live: LuaJIT, modified for use with LuaJITTeX
ii  libtiff5:amd64                            4.1.0+git191117-2ubuntu0.20.04.13 amd64        Tag Image File Format (TIFF) library
ii  libtinfo6:amd64                           6.2-0ubuntu2                      amd64        shared low-level terminfo library for terminal handling
ii  libudev1:amd64                            245.4-4ubuntu3.16                 amd64        libudev shared library
ii  libunicode-japanese-perl                  0.49-1build5                      amd64        module for converting Japanese encodings
ii  libunistring2:amd64                       0.9.10-2                          amd64        Unicode string library for C
ii  libuuid1:amd64                            2.34-0.1ubuntu9.3                 amd64        Universally Unique ID library
ii  libuv1:amd64                              1.34.2-1ubuntu1.3                 amd64        asynchronous event notification library - runtime library
ii  libwebp6:amd64                            0.6.1-2ubuntu0.20.04.3            amd64        Lossy compression of digital photographic images.
ii  libx11-6:amd64                            2:1.6.9-2ubuntu1.6                amd64        X11 client-side library
ii  libx11-data                               2:1.6.9-2ubuntu1.6                all          X11 client-side library
ii  libxau6:amd64                             1:1.0.9-0ubuntu1                  amd64        X11 authorisation library
ii  libxaw7:amd64                             2:1.0.13-1                        amd64        X11 Athena Widget library
ii  libxcb-render0:amd64                      1.14-2                            amd64        X C Binding, render extension
ii  libxcb-shm0:amd64                         1.14-2                            amd64        X C Binding, shm extension
ii  libxcb1:amd64                             1.14-2                            amd64        X C Binding
ii  libxdmcp6:amd64                           1:1.1.3-0ubuntu1                  amd64        X11 Display Manager Control Protocol library
ii  libxext6:amd64                            2:1.3.4-0ubuntu1                  amd64        X11 miscellaneous extension library
ii  libxft2:amd64                             2.3.3-0ubuntu1                    amd64        FreeType-based font drawing library for X
ii  libxi6:amd64                              2:1.7.10-0ubuntu1                 amd64        X11 Input extension library
ii  libxml2:amd64                             2.9.10+dfsg-5ubuntu0.20.04.2      amd64        GNOME XML library
ii  libxmu6:amd64                             2:1.1.3-0ubuntu1                  amd64        X11 miscellaneous utility library
ii  libxpm4:amd64                             1:3.5.12-1ubuntu0.20.04.2         amd64        X11 pixmap library
ii  libxrender1:amd64                         1:0.9.10-1                        amd64        X Rendering Extension client library
ii  libxt6:amd64                              1:1.1.5-1                         amd64        X11 toolkit intrinsics library
ii  libyaml-0-2:amd64                         0.2.2-1                           amd64        Fast YAML 1.1 parser and emitter library
ii  libzita-alsa-pcmi0:amd64                  0.3.2-1                           amd64        C++ wrapper around the ALSA API
ii  libzstd1:amd64                            1.4.4+dfsg-3ubuntu0.1             amd64        fast lossless compression algorithm
ii  libzzip-0-13:amd64                        0.13.62-3.2ubuntu1.1              amd64        library providing read access on ZIP-archives - library
ii  linux-libc-dev:amd64                      5.4.0-189.209                     amd64        Linux Kernel Headers for development
ii  locales                                   2.31-0ubuntu9.16                  all          GNU C Library: National Language (locale) data [support]
ii  login                                     1:4.8.1-1ubuntu5.20.04.1          amd64        system login tools
ii  logsave                                   1.45.5-2ubuntu1                   amd64        save the output of a command in a log file
ii  lsb-base                                  11.1.0ubuntu2                     all          Linux Standard Base init script functionality
ii  mawk                                      1.3.4.20200120-2                  amd64        Pattern scanning and text processing language
ii  mount                                     2.34-0.1ubuntu9.3                 amd64        tools for mounting and manipulating filesystems
ii  ncurses-base                              6.2-0ubuntu2                      all          basic terminal type definitions
ii  ncurses-bin                               6.2-0ubuntu2                      amd64        terminal-related programs and man pages
ii  openssl                                   1.1.1f-1ubuntu2.12                amd64        Secure Sockets Layer toolkit - cryptographic utility
ii  passwd                                    1:4.8.1-1ubuntu5.20.04.1          amd64        change and administer password and group data
ii  perl                                      5.30.0-9ubuntu0.5                 amd64        Larry Wall's Practical Extraction and Report Language
ii  perl-base                                 5.30.0-9ubuntu0.5                 amd64        minimal Perl system
ii  perl-modules-5.30                         5.30.0-9ubuntu0.5                 all          Core Perl modules
ii  poppler-data                              0.4.9-2                           all          encoding data for the poppler PDF rendering library
ii  procps                                    2:3.3.16-1ubuntu2.3               amd64        /proc file system utilities
ii  rake                                      13.0.1-4                          all          ruby make-like utility
ii  readline-common                           8.0-4                             all          GNU readline and history libraries, common files
ii  ruby                                      1:2.7+1                           amd64        Interpreter of object-oriented scripting language Ruby (default version)
ii  ruby-minitest                             5.13.0-1                          all          Ruby test tools supporting TDD, BDD, mocking, and benchmarking
ii  ruby-net-telnet                           0.1.1-2                           all          telnet client library
ii  ruby-power-assert                         1.1.7-1                           all          library showing values of variables and method calls in an expression
ii  ruby-test-unit                            3.3.5-1                           all          unit testing framework for Ruby
ii  ruby-xmlrpc                               0.3.0-2                           all          XMLRPC library for Ruby
ii  ruby2.7                                   2.7.0-5ubuntu1.14                 amd64        Interpreter of object-oriented scripting language Ruby
ii  rubygems-integration                      1.16                              all          integration of Debian Ruby packages with Rubygems
ii  sed                                       4.7-1                             amd64        GNU stream editor for filtering/transforming text
ii  sensible-utils                            0.0.12+nmu1                       all          Utilities for sensible alternative selection
ii  sysvinit-utils                            2.96-2.1ubuntu1                   amd64        System-V-like utilities
ii  t1utils                                   1.41-3                            amd64        Collection of simple Type 1 font manipulation programs
ii  tar                                       1.30+dfsg-7ubuntu0.20.04.2        amd64        GNU version of the tar archiving utility
ii  tegaki-zinnia-japanese                    0.3-1                             all          Japanese handwriting model for Zinnia
ii  tex-common                                6.13                              all          common infrastructure for building and installing TeX
ii  texlive-base                              2019.20200218-1                   all          TeX Live: Essential programs and files
ii  texlive-binaries                          2019.20190605.51237-3ubuntu0.2    amd64        Binaries for TeX Live
ii  texlive-font-utils                        2019.202000218-1                  all          TeX Live: Graphics and font utilities
ii  texlive-lang-cjk                          2019.20200218-1                   all          TeX Live: Chinese/Japanese/Korean (base)
ii  texlive-lang-japanese                     2019.20200218-1                   all          TeX Live: Japanese
ii  texlive-latex-base                        2019.20200218-1                   all          TeX Live: LaTeX fundamental packages
ii  ttf-ubuntu-font-family                    1:0.83-4ubuntu1                   all          sans-serif font set from Ubuntu (transitional package)
ii  tzdata                                    2023d-0ubuntu0.20.04              all          time zone and daylight-saving time data
ii  ubuntu-keyring                            2020.02.11.4                      all          GnuPG keys of the Ubuntu archive
ii  ucf                                       3.0038+nmu1                       all          Update Configuration File(s): preserve user changes to config files
ii  util-linux                                2.34-0.1ubuntu9.3                 amd64        miscellaneous system utilities
ii  x11-common                                1:7.7+19ubuntu14                  all          X Window System (X.Org) infrastructure
ii  xdg-utils                                 1.1.3-2ubuntu1.20.04.2            all          desktop integration utilities from freedesktop.org
ii  xfonts-cyrillic                           1:1.0.4                           all          Cyrillic fonts for X
ii  xfonts-encodings                          1:1.0.5-0ubuntu1                  all          Encodings for X.Org fonts
ii  xfonts-intl-japanese                      1.2.1-10                          all          international fonts for X - Japanese
ii  xfonts-intl-japanese-big                  1.2.1-10                          all          international fonts for X - large Japanese
ii  xfonts-scalable                           1:1.0.3-1.1                       all          scalable fonts for X
ii  xfonts-utils                              1:7.7+6                           amd64        X Window System font utility programs
ii  zlib1g:amd64                              1:1.2.11.dfsg-2ubuntu1.3          amd64        compression library - runtime

Any advice on how to resolve the issue?

Thanks!

@rystadenergy

The issue may be occurring due to the fonts not being supported by the Linux environment. You can try installing different fonts (Maybe the fonts that are present in the Window environment. You can copy and paste them inside Linux system). msttcorefonts package is also seems to be missing in your docker file. You can try installing them as well. In case you still face the issue, please share your sample file with us with the sample code snippet. We will log an investigation ticket and share the ID with you.

Hi Asad,

Thanks for your response.
If I install the msttcorefonts this is what I end up with:
JapaneseTextBroken-Example.png (3.2 KB)
Do I need to specify a specific japanese font to make it work? We specify the font-family in css, and currently it’s Verdana.

By the way, which file do you require?
Regarding the code, here’s a snippet:

protected virtual HtmlLoadOptions DefaultHtmlLoadOptions => new HtmlLoadOptions
        {
            PageInfo =
            {
                Width = PageSize.A4.Width, 
                Height = PageSize.A4.Height, 
                IsLandscape = false,
                Margin = new MarginInfo(
                    DefaultPageMarginLeft, DefaultPageMarginBottom, DefaultPageMarginRight, DefaultPageMarginTop)
            },
            HtmlMediaType = HtmlMediaType.Print,
            IsEmbedFonts = true,
            IsRenderToSinglePage = false
        };

        public Document GenerateForHtml(string mainContentHtml, T metadata)
        {
            var htmlForMainContent = GetHtmlForMainContent(mainContentHtml, metadata);
            
            var htmlStream = GenerateStreamFromString(htmlForMainContent);
            var pdfDocument = new Document(htmlStream, DefaultHtmlLoadOptions);

            var pageNumberStamp = GetPageNumberStamp();

            foreach(var page in pdfDocument.Pages)
            {
                if (pageNumberStamp != null)
                {
                    page.AddStamp(pageNumberStamp);   
                }

                var headerString = GetHeaderHtml();
                if (!string.IsNullOrEmpty(headerString))
                {
                    var headerFragment = new HtmlFragment(headerString);
                    page.Header = new HeaderFooter();
                    page.Header.Paragraphs.Add(headerFragment);
                    page.Header.Margin = new MarginInfo(10, 10, 10, 10);
                }

                var footerString = GetFooterHtml();
                if (!string.IsNullOrEmpty(footerString))
                {
                    var footerFragment = new HtmlFragment(footerString);
                    page.Footer = new HeaderFooter();
                    page.Footer.Paragraphs.Add(footerFragment);
                    page.Footer.Margin = new MarginInfo(10, 0, 10, 10);   
                }
            }

            pdfDocument.DisplayDocTitle = true;
            pdfDocument.SetTitle(metadata.Title);
            
            return pdfDocument;
        }

        private static Stream GenerateStreamFromString(string s)
        {
            var stream = new MemoryStream();
            var writer = new StreamWriter(stream);
            writer.Write(s);
            writer.Flush();
            stream.Position = 0;
            return stream;
        }

        private string GetHtmlForMainContent(string htmlForMainSection, T metadata)
        {
            var htmlForStartingSection = GetStartSectionHtml(metadata);
            var htmlForEndSection = GetEndSectionHtml(metadata);
            return $@"<html>
                    <head>
                    <title>{metadata.Title}</title>
                    <style>{GetCssStyles()}</style>
                    </head>
                    <body>
                      <div class=""pdf-content"">
                        {htmlForStartingSection}
                        <div class=""main-content"">
                          {htmlForMainSection}
                        </div>
                        {htmlForEndSection}
                      </div>
                    </body>
                   ";
        }

Best Regards

@rystadenergy

You can please share the sample HTML in .zip format with us that you are trying to convert into PDF file. We will log an investigation ticket to analyze the issue and address it accordingly.

Hi, here’s the sample HTML

<p>ガス市場ではこのところ、カリブ海とメキシコ湾で被害を出したハリケーン「ベリル」が大きな懸念材料になっていた。米国の液化天然ガス(LNG)生産に支障をきたす可能性があったからだ。だがハリケーン関連のリスクは後退し、米国の液化施設の操業にほとんど影響を及ぼさなかったため、主要取引ハブのガス価格は軒並み下落した。欧州の天然ガス指標であるオランダTTFの価格は7月9日には1メガワット時(MWh)当たり31.335ユーロと、前週の33.685ユーロから7%下がり、アジアのスポットLNG価格も100万Btu(MMBtu)当たり12.365ドルと、1週間前の12.56ドルから1.6%下落した。アジア北部の猛暑はこの地域の輸入業者のLNG購入に至っておらず、アジアのガス需要への期待が総じて低いことも価格下落の一因だ。主要市場での豊富な供給と潤沢な在庫も価格を下押ししている。</p><p><strong>米国:ハリケーンの懸念後退も、国内需給が緩和</strong><br>米国の天然ガス指標であるヘンリーハブ価格(期近物)は7月9日には2.344ドル/MMBtuと、前週の2.435ドル/MMBtuから3.7%下がり、過去2週間で最低の水準になった。供給は増えている一方で、電力需要は昨年の夏に比べて伸び悩んでいるのが下落基調の主な理由だ。6月の米48州(アラスカ州とハワイ州を除く)の乾性ガス生産量は依然として日量1000億立方フィート(Bcfd)前後だった。ガス在庫は底堅く、6月22日~28日の週は前週比320億立方フィート増の3兆1340億立方フィートだった。ライスタッド・エナジーの予測ではこの冬の在庫は豊富で、ヘンリーハブ価格は低水準にとどまる。</p><p>ハリケーン「ベリル」が米国のLNG生産に影響を及ぼすのではないかとの懸念は後退した。米メキシコ湾岸に上陸する前に「(5段階のうち一番下の)カテゴリー1」になり、7月8日にかけてさらに勢力が弱くなった。米国の液化プラントとLNG生産はほとんど影響を受けず、フリーポートLNGだけが週末に生産を減らした。フリーポートLNGへのフィードガスは7月6日には日量20億立方フィート(Bcfd)近くだったが、7日にはわずか870万立方フィートと大きく減少した。これにより、フリーポートの稼働率(30日移動平均)は7月6日の100%から7月7日には98%に低下した。同LNGはハリケーンの通過後、フル稼働に戻った。</p><p><strong>欧州:豊富な供給で価格下落</strong><br>欧州では在庫も供給も豊富なため、TTFはここ数週間11ドル/MMBtuを割り込んでいる。7月7日の在庫は最大キャパの78.7%と、前週の77.1%から増え、前年同時期とほぼ同水準になった。7月9日のノルウェーのパイプラインの流量は日量3億3380万立方メートル(MMcmd)で、前週の334.6MMcmdから若干減少したものの、前年同時期よりも25%多かった。ノルウェーからのパイプラインの流量が安定しているため、欧州のLNG需要も伸びず、24年に入ってからは前年よりも低い水準にとどまっている。</p><p>夏の天候は7~8月に注視すべき重要な要因で、電力部門のガス需要の急増を招く場合もある。ドイツなど欧州の一部では今後2週間、気温が平年よりも高くなる見通しだ。もっとも、現時点では欧州のLNG輸入量は低迷している。ドイツは電力部門への追加投資を計画しており、ガス発電所が増設されるもようだ。ドイツ経済・気候保護省によると、25年初めまでに約5ギガワット(GW)のガス火力発電(水素火力発電に転換する見通し)の入札が実施される予定だ。</p><p><strong>アジア:北部は猛暑に</strong><br>アジア北部の夏は平年よりも暑くなるもようで、LNG価格は上昇基調にある。ライスタッド・エナジーの「LNG取引トラッカー」によると、東京の7月9日の気温は30度以上と、過去22年間の平均23.1度を大きく上回った。このため東京の電力需要が増え、送電網を圧迫している。日本卸電力取引所(JEPX)の電力スポット市場価格は年初来で最高の水準に達した。同様に、中国南部はここ数週間の豪雨と洪水の後、気温が上昇し始めている。広東省の気温は28度を超え、過去22年間の平均よりも約2度高くなった。日本と中国の暑さは7月中旬まで続く見通しだ。日本の一部の電力会社は8月以降に受け渡しされるLNGカーゴの購入を検討しているが、実際の購入にはまだ至っておらず、アジアのスポットLNG価格を強く下支えしてはいない。日本の6月のLNG在庫は489万トンで、前月の506万トン、前年6月の547万トンを下回った。猛暑が続けば、発電用のガス需要が増え、在庫がさらに減る可能性がある。中国のLNG輸入の裁定はなお有効だが、利ざやは6月の2ドル弱/MMBtuから7月9日には沿海部で0.9ドル程度まで縮小し(2カ月の取引ラグを考慮した場合)、産業用の消費が軟調なため、中国の輸入業者による調達は一定にとどまっている。中国の製造業購買担当者景気指数(PMI)はなお低迷しており、好調・不調の境目である50を上回ったのは3月と4月だけだ。</p><p>南アジアでは、インドでモンスーンの影響で気温が下がり、電力部門の需要は抑えられている。モンスーンにより水力発電の出力も増え、ガス火力発電よりも価格競争力で優位に立っている。それでもなお、インド企業はここ数カ月の熱波を受け、LNGの購入を続けている。インディアン・オイル(IOC)は7月下旬~8月上旬受け渡しのカーゴを購入し、国営ガス輸送のGAILは9~10月受け渡しの4カーゴを求めている。</p>

In fact, it can be any HTML, the Japanese text is what’s causing the issue.

Thanks

@rystadenergy

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

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.