你好,我正在使用Docx4j来转换文字模板到PDF格式。但泰米尔字体是不支持的。它看起来很奇怪。我用下面的Java代码,似乎减少了奇怪的外观,仍然字显示不正确。我已经安装了Latha作为泰米尔字体。请帮助
FontTablePart fontTablePart= wordMLPackage.getMainDocumentPart().getFontTablePart();
fontTablePart.processEmbeddings();
Set<String> fontsInUse = wordMLPackage.getMainDocumentPart().fontsInUse();
// Make each embedded font available to the font mapper.
for(String s : fontsInUse) {
System.out.println("Font in use : "+s);
PhysicalFont physicalFont = PhysicalFonts.get(s);
fontMapper.put(s, physicalFont);
}
2条答案
按热度按时间mm5n2pyu1#
假设您使用docx 4j-export-fo进行转换,请确保已安装字体并使用IdentityPlusMapper,或者使用BestMatchingMapperMap合适的字体。
更多信息请参见https://github.com/plutext/docx4j/blob/VERSION_11_4_8/docx4j-samples-docx-export-fo/src/main/java/org/docx4j/samples/ConvertOutPDFviaXSLFO.java#L152
bqujaahr2#
Docx4J不支持所有语言。我必须使用OpenOffice与JDO转换器创建PDF从Word文档。工作起来像一个魅力。下面的代码,如果它帮助任何人: