Java itext xmlworker没有';无法使用自定义字体系列

Java itext xmlworker没有';无法使用自定义字体系列,java,itext,Java,Itext,我的应用程序解析html并将内容放在pdf中,现在它需要支持多种字体,例如:缅甸和中文 我能够做到这一点与短语,但不与html,即使是单一字体的家庭 工作代码 Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("/home/a2.pdf")); Font font = FontFactory.getFont("KozMinPro-Regular", "UniJIS-UC

我的应用程序解析html并将内容放在pdf中,现在它需要支持多种字体,例如:缅甸和中文

我能够做到这一点与短语,但不与html,即使是单一字体的家庭

工作代码

Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("/home/a2.pdf"));
Font font = FontFactory.getFont("KozMinPro-Regular", "UniJIS-UCS2-H", false);
Font font1 = FontFactory.getFont("/home/mm3.ttf", BaseFont.IDENTITY_H, false);
FontSelector fs = new FontSelector();
fs.addFont(font);
fs.addFont(font1);
Phrase phrase = fs.process("長");
phrase.add(fs.process("၀န္ထမ္းလစလႊာ( လ )"));
phrase.add(fs.process("123aab"));
document.open();
document.add(phrase);
document.close();
尝试使用XMLWorker,但无效:

final MyFontFactory fontFactory = new MyFontFactory();
FontFactory.register("/home/Downloads/mm3.ttf");
FontFactory.setFontImp(fontFactory);

final HtmlPipelineContext htmlContext = new HtmlPipelineContext(new CssAppliersImpl(fontFactory));
final CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
Document document = new Document();

PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("/home/a2.pdf"));
document.open();
String str="<span style=\"font-family: &quot;Open Sans&quot;, sans-serif; white-space: pre-wrap; background-color: rgb(255, 255, 255);\">Deduc၀န္ထမ္းလစာေပးေခ်လႊာ( လစာငွေ )tions哈罗</span> ";
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
InputStream is = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
worker.parseXHtml(writer, document, is, Charset.forName("UTF-8"));
// step 5
document.close();

final MyFontFactory fontFactory=新的MyFontFactory();
注册(“/home/Downloads/mm3.ttf”);
FontFactory.setFontImp(FontFactory);
最终HtmlPipelineContext htmlContext=新HtmlPipelineContext(新CSSApplierSiml(fontFactory));
最终CSSResolver CSSResolver=XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
文档=新文档();
PdfWriter writer=PdfWriter.getInstance(文档,新文件输出流(“/home/a2.pdf”);
document.open();
String str=“Deduc၀န္ထမ္းလစာေပးေခ်လႊာ( လစာငွေ )离子哈罗 ";
XMLWorkerHelper worker=XMLWorkerHelper.getInstance();
InputStream is=newbytearrayinputstream(str.getBytes(StandardCharsets.UTF_8));
parseXHtml(writer、document、is、Charset.forName(“UTF-8”);
//步骤5
document.close();