Free Support Forum - aspose.com

Aspoce.HTML フォントでの例外


#1

MACで利用した場合に、下記のエラーが発生してHTMLからPDFへの変換ができませんでした。
PDFにフォントを指定して埋め込んだりすれば解消されますか?

Caused by: 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) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z26.m306(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z26.m666(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z26.m2(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z11.m1(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z11.(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z8.m618(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z8.m617(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z8.m7(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z10.m2(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z10.m1(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p31.z10.m3(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p185.z2.m1(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p184.z10.m1(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p207.z6.m6(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p144.z33.(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p144.z5.m1(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p144.z5.(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p206.z21.m2(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p155.z1.(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p142.z3.m2193(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p143.z1.m1(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.internal.p241.z1.m1(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]
at com.aspose.html.rendering.HtmlRenderer.render(Unknown Source) ~[aspose-html-18.11.1.jar: 18.11.1]

実行ソース

        com.aspose.html.rendering.pdf.PdfRenderingOptions pdf_options = new com.aspose.html.rendering.pdf.PdfRenderingOptions();
        //デフォルトのページを取得 A4縦
        com.aspose.html.drawing.Page defpage = new com.aspose.html.drawing.Page();
        pdf_options.getPageSetup().setAnyPage(new com.aspose.html.drawing.Page(defpage.getSize(), new com.aspose.html.drawing.Margin(72,54,54,54)));
        com.aspose.html.rendering.pdf.PdfDevice pdf_device = new com.aspose.html.rendering.pdf.PdfDevice(pdf_options, file.getPath());
        com.aspose.html.rendering.HtmlRenderer renderer = new com.aspose.html.rendering.HtmlRenderer();
        String url = "https://{ドメイン}/XXXX.html";
        com.aspose.html.HTMLDocument html_document = new com.aspose.html.HTMLDocument(url);
        renderer.render(pdf_device, html_document);
        renderer.dispose();

#2

HTMLの生成側で下記の指定を入れたら正常に動作しました。自己解決です。
ありがとうございます!

@font-face {
	font-family: 'MyFont';
	src: url(/location/of/font/myfont.ttf);
}

html {
	font-family: MyFont;
}

#3

@Misuda_Tomoya

ご意見ありがとうございました。

私たちはあなたの問題が解決されたことを知って喜んでいます。私たちのAPIを使い続け、さらなる質問がある場合はお気軽にお問い合わせください。