Hi,
we saved a docx to pdf using version 23.4 with the following code in Java and found that the Myanmar text is not showing correctly in the PDF file.
com.aspose.words.Document doc = new com.aspose.words.Document("C:\\temp\\docTemplate\\original.docx");
doc.save("C:\\temp\\docTemplate\\output.pdf");
I’ve uploaded both files and the fonts that we are using in the zip file.
Please help to check what is the issue, if it is font issue please recommend which Myanmar font is supported by Aspose when saving docx to PDF.
docx_convert_pdf_myanmar_font_issue.zip (422.4 KB)
Thanks.
@mingzhe.foo sorry could you point to me what’s the problem with the font, as long as I can see the font is set and displayed properly in the PDF document that you attached.
@eduardo.canal I’ve highlighted the text below in the PDF file that are having issues for you to compare with the DOCX that I’ve uploaded in my previous post. Please help to check.
pdf_file_comparison.jpg (241.8 KB)
@mingzhe.foo Also, you should note that by default MS Word uses font open type features. Aspose.Words.Shaping.Harfbuzz package provides support for OpenType features in Aspose.Words using the HarfBuzz text shaping engine. You should enabling open type features to get the result closer to MS Word’s result. To achieve this you should add reference to Aspose.Words Shaping Harfbuzz plugin:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>23.5</version>
<classifier>shaping-harfbuzz-plugin</classifier>
</dependency>
and use the following code for conversion:
Document doc = new Document("C:\\Temp\\in.docx");
// Set fonts sources if required.
doc.setFontSettings(new FontSettings());
doc.getFontSettings().setFontsSources(new FontSourceBase[]{new FolderFontSource("C:\\Temp\\fonts", true)});
// Enable open type features
doc.getLayoutOptions().setTextShaperFactory(com.aspose.words.shaping.harfbuzz.HarfBuzzTextShaperFactory.getInstance());
doc.save("C:\\Temp\\out.pdf");
FYI @eduardo.canal
2 Likes
Thanks @alexey.noskov and @eduardo.canal, it is working now.
1 Like