NullPointerException when running in Docker

The following java code (version 19.9) runs fine in development and in a spring boot jar:

        HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions()
    htmlLoadOptions.pageInfo.width =  request.JSON.printWidth
    htmlLoadOptions.pageInfo.height =  request.JSON.printHeight
    htmlLoadOptions.pageInfo.margin.bottom =  request.JSON.printMarginBottom
    htmlLoadOptions.pageInfo.margin.top =  request.JSON.printMarginTop
    htmlLoadOptions.pageInfo.margin.left =  request.JSON.printMarginLeft
    htmlLoadOptions.pageInfo.margin.right =  request.JSON.printMarginRight

    Document document = new Document (new ByteArrayInputStream( request.JSON.content.getBytes( 'UTF-8' ) ), htmlLoadOptions)

When the same jar is run in a docker container, I get the following NPE:

java.lang.NullPointerException: null
at com.aspose.pdf.internal.l44p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l44p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.lc.lc(Unknown Source)
at com.aspose.pdf.internal.l42p.lt.l1n(Unknown Source)
at com.aspose.pdf.internal.l42p.l0l.l6f(Unknown Source)
at com.aspose.pdf.internal.l42p.l0l.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l0l.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.lk.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.lk.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l3n.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l3n.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l3n.lj(Unknown Source)
at com.aspose.pdf.internal.l42p.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l3n.lI(Unknown Source)
at com.aspose.pdf.internal.l42p.l4if.l2n(Unknown Source)
at com.aspose.pdf.internal.l38u.lb.lf(Unknown Source)
at com.aspose.pdf.internal.l39f.lk.l0p(Unknown Source)
at com.aspose.pdf.internal.l39p.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l39p.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l39p.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l38v.lj.lI(Unknown Source)
at com.aspose.pdf.internal.l38p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l46f.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l39if.lt.lI(Unknown Source)
at com.aspose.pdf.internal.l39if.lf.lj(Unknown Source)
at com.aspose.pdf.internal.html.collections.lf.lj(Unknown Source)
at com.aspose.pdf.internal.html.collections.lf.hasNext(Unknown Source)
at com.aspose.pdf.internal.l46f.lI.lI(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.Renderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.Renderer.render(Unknown Source)
at com.aspose.pdf.l6u.lI(Unknown Source)
at com.aspose.pdf.l6u.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.(Unknown Source)
at com.aspose.pdf.Document.(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:237)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:257)
at physician.query.api.TemplateController.postReturnPdf(TemplateController.groovy:57)

I found the solution to this. This must be run in the docker container:

RUN apk --no-cache add msttcorefonts-installer fontconfig &&
update-ms-fonts &&
fc-cache -f

@pawlorj

Yes, all Microsoft Essential Fonts should be installed in the environment in order to generate correct results using Aspose.PDF. It is good to know that you managed to resolve the issue. Please keep using our API and in case you face any issue, please feel free to let us know.