如何使用com.itextpdf.html2pdf.HtmlConverter嵌入系统字体

问题描述

我正在尝试使用itextpdf.html2pdf.HtmlConverter将HTML文件转换为PDF。我创建了

 DefaultFontProvider to register the system fonts.
    
    PdfADocument pdf = new PdfADocument(writer,PdfAConformanceLevel.PDF_A_1B,new PdfOutputIntent("Custom","","https://www.color.org","sRGB IEC61966-2.1",new FileInputStream(PDFA1B_PROFILE_FILENAME)));
    ConverterProperties properties = new ConverterProperties();
    HtmlConverter.convertToPdf(new ByteArrayInputStream(content.getBytes()),pdf,properties);        
    properties.setBaseUri("C:\\Temp");
    FontProvider fontProvider =  new DefaultFontProvider(true,true,true);
    properties.setFontProvider(fontProvider);

HtmlConverter.convertToPdf(new ByteArrayInputStream(content.getBytes()),properties);

但是在转换过程中出现此错误

com.itextpdf.pdfa.PdfAConformanceException:必须嵌入所有字体。这个不是:Times-Roman

我尝试注册 Windows / Fonts 文件夹,并将ttf文件添加属性中。仍然没有运气。任何建议都将不胜感激。

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)