The exception 'Cannot read a name from the name table in a font' when HTML to PDF

Hello @alexey.noskov,

my demo from 通过 Java 转换 HTML、XHTML、Markdown、MHTML、EPUB 和 SVG

public class Test3 {
    public static void main(String[] args) {
        String documentPath = "/index.html";
        String outputPath = "/indexNew.pdf";

        // Source HTML document
        com.aspose.html.HTMLDocument htmlDocument = new com.aspose.html.HTMLDocument(documentPath);
        // Initialize PdfSaveOptions
        com.aspose.html.saving.PdfSaveOptions options = new com.aspose.html.saving.PdfSaveOptions();
        options.setJpegQuality(100);
        // Output file path
        // Convert HTML to PDF
        com.aspose.html.converters.Converter.convertHTML(htmlDocument, options, outputPath);
    }
}

version:23.1
java:1.8
os:mac

Exception in thread "main" java.lang.AssertionError: Cannot read a name from the name table in a font.
	at com.aspose.html.internal.ms.System.Diagnostics.Debug.fail(Unknown Source)
	at com.aspose.html.internal.p234.z1.fail(Unknown Source)
	at com.aspose.html.internal.p127.z26.m201(Unknown Source)
	at com.aspose.html.internal.p127.z26.m1563(Unknown Source)
	at com.aspose.html.internal.p127.z26.m2(Unknown Source)
	at com.aspose.html.internal.p127.z11.m1(Unknown Source)
	at com.aspose.html.internal.p127.z11.<init>(Unknown Source)
	at com.aspose.html.internal.p127.z8.m1518(Unknown Source)
	at com.aspose.html.internal.p127.z8.m1516(Unknown Source)
	at com.aspose.html.internal.p127.z8.m123(Unknown Source)
	at com.aspose.html.internal.p125.z1.m123(Unknown Source)
	at com.aspose.html.internal.p189.z1.m1(Unknown Source)
	at com.aspose.html.internal.p189.z1.m1(Unknown Source)
	at com.aspose.html.internal.p189.z1.m1(Unknown Source)
	at com.aspose.html.internal.p241.z119.m1(Unknown Source)
	at com.aspose.html.internal.p252.z20.<init>(Unknown Source)
	at com.aspose.html.internal.p241.z119.<init>(Unknown Source)
	at com.aspose.html.internal.p241.z65.m1(Unknown Source)
	at com.aspose.html.internal.p133.z16$30.m2(Unknown Source)
	at com.aspose.html.internal.p133.z16$30.m1(Unknown Source)
	at com.aspose.html.internal.p133.z16$6$1.invoke(Unknown Source)
	at com.aspose.html.internal.p31.z1.dispose(Unknown Source)
	at com.aspose.html.internal.p31.z3.dispose(Unknown Source)
	at com.aspose.html.internal.p160.z4.m1(Unknown Source)
	at com.aspose.html.internal.p160.z2.m7(Unknown Source)
	at com.aspose.html.internal.p174.z7.m2338(Unknown Source)
	at com.aspose.html.internal.p174.z7.moveNext(Unknown Source)
	at com.aspose.html.internal.p209.z1.m1(Unknown Source)
	at com.aspose.html.rendering.HtmlRenderer.render(Unknown Source)
	at com.aspose.html.rendering.HtmlRenderer.render(Unknown Source)
	at com.aspose.html.rendering.HtmlRenderer.render(Unknown Source)
	at com.aspose.html.rendering.Renderer.render(Unknown Source)
	at com.aspose.html.rendering.Renderer.render(Unknown Source)
	at com.aspose.html.converters.z5.m1(Unknown Source)
	at com.aspose.html.converters.z5.m1(Unknown Source)
	at com.aspose.html.converters.z5.m1(Unknown Source)
	at com.aspose.html.converters.Converter.convertHTML(Unknown Source)
	at com.example.aspose.Test2.main(Test2.java:25)

@Rivan

Looks like a font-related issue. Can you please try installing windows fonts in the MAC OR use

new FontsSettings().setFontsLookupFolders(new String[]{ "p:/tmp/"}, true);

before performing the conversion. Please let us know in case issue still persists.

@asad.ali Hello,Thanks for your help。
but,I can’t find the parameterless construction of FontsSettings in 23.1 aspose-html,need the fontFactory; eq:
@z30
public FontsSettings(z11 fontFactory) {
this.fontFactory = fontFactory;
}

I try new methods,but same error.
String[] fontsFolders = { “/Users/rivan/Library/fonts/” };
//new FontsSettings(null).setFontsLookupFolders(fontsFolders, true);
Configuration configuration = new Configuration();
IUserAgentService service = configuration.getService(IUserAgentService.class);
service.getFontsSettings().setFontsLookupFolders(fontsFolders,true);
HTMLDocument document = new HTMLDocument(documentPath,configuration);

@Rivan

We have opened the following new ticket(s) in our internal issue tracking system and will investigate it in details. Meanwhile, can you please share your sample HTML in .zip format with us as it would help us in performing the investigation.

Issue ID(s): HTMLJAVA-1448

We are sorry for the inconvenience.

file.zip (11.5 KB)
@asad.ali
Thank you for your help.
Sure, I can use the latest version 23.1 of the HTML package to convert this file. I hope it can help solve the issue.

@Rivan

Thanks for sharing the sample file. We will further inform you once the issue is resolved. Please spare us some time.

@asad.ali
Hello,How’s this issue going

@Rivan

The has not been yet investigated completely. It was logged recently in our issue tracking system and will be resolved on a first come first serve basis. We will inform you once we make some progress towards its fix. Please spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as HTMLJAVA-1448) have been fixed in this update. This message was posted using Bugs notification tool by pavel.terechshenkov