Free Support Forum - aspose.com

PDF convert to HTML Error(font issue?)

Hi there,

We use aspose.pdf-17.1.0 to convert pdf to html format.
but got converting error from time to time, which most of error looks like:

Caused by: java.lang.NullPointerException
at sun.font.TrueTypeGlyphMapper.(TrueTypeGlyphMapper.java:44)
at sun.font.TrueTypeFont.getMapper(TrueTypeFont.java:1243)
at sun.font.FileFontStrike.(FileFontStrike.java:169)
at sun.font.FileFont.createStrike(FileFont.java:80)
at sun.font.Font2D.getStrike(Font2D.java:316)
at sun.font.Font2D.getStrike(Font2D.java:229)
at sun.font.Font2D.getItalicAngle(Font2D.java:496)
at java.awt.Font.getItalicAngle(Font.java:2013)
at com.aspose.pdf.internal.p645.z16.m1(Unknown Source)
at com.aspose.pdf.internal.p645.z16.m8(Unknown Source)
at com.aspose.pdf.internal.p277.z10.m1(Unknown Source)
at com.aspose.pdf.internal.p277.z10.m1(Unknown Source)
at com.aspose.pdf.internal.p257.z31.m1(Unknown Source)
at com.aspose.pdf.internal.p205.z12.m1(Unknown Source)
at com.aspose.pdf.internal.p205.z12.m1(Unknown Source)
at com.aspose.pdf.internal.p205.z8.m1(Unknown Source)
at com.aspose.pdf.internal.p205.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p204.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p5.z7.m1(Unknown Source)
at com.aspose.pdf.z94.m1(Unknown Source)
at com.aspose.pdf.z94.m1(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)

And here’s our source code.
com.aspose.pdf.HtmlSaveOptions saveOptions = new com.aspose.pdf.HtmlSaveOptions();
saveOptions.setFixedLayout(true);

		saveOptions.setSplitIntoPages(true);
		saveOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
		 
		saveOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats;
		//saveOptions.CustomResourceSavingStrategy = new CustomResourceSaving();
		 
		doc.save(outHtmlFile, saveOptions);

What’s the issue here? Any similar issue that has been fixed? what’s the solution for this?
thanks a lot

@stonefu

Thanks for contacting support.

Would you please try your scenario with latest version of the API (i.e. Aspose.PDF for Java 18.4) and if does not resolve your issue, please share your sample PDF document along with the JDK version information in which you are working at your side. We will test the scenario in our environment and address it accordingly.