Hallo
I noted that some characters that work in a table cell do not work in other. The code snippet is the following:
com.aspose.pdf.Document doc = new com.aspose.pdf.Document(“Blank.pdf”);
com.aspose.pdf.Table table = new com.aspose.pdf.Table();
table.setColumnWidths(“400”);
table.getRows().add().getCells().add(“竤”);//is show correctly
table.getRows().add().getCells().add(“䧜”);//is not show correctly
table.getRows().add().getCells().add(“竤—”);//is show correctly
table.getRows().add().getCells().add(“竤—䧜”);// both Chinese symbols are not shown correctly
doc.getPages().get_Item(1).getParagraphs().add(table);
doc.save(“Result.pdf”);
(I also attached the pdf)
In the last cell, none of the Chinese characters are shown. It seems that another font is automatically used, but it somehow messes up both characters. I would more or less expect that one is show correctly and the other one not, in worse case. Is this a bug, or is this the correct behavior? If it is the correct behavior, what is the explanation for it?
Thank you,
Samuel
Hi,
Hi Samuel,
com.aspose.pdf.Document doc = new
com.aspose.pdf.Document(myDir+“HelloWorld.pdf”);<o:p></o:p>
com.aspose.pdf.Table table = new com.aspose.pdf.Table();
table.setTop(100);
table.setColumnWidths("400");
TextState textState=new TextState();
textState.setFont(FontRepository.findFont("MingLiU"));
table.getRows().add().getCells().add("竤",textState);//is show correctly
table.getRows().add().getCells().add("䧜",textState);//is not show correctly
table.getRows().add().getCells().add("竤---",textState);//is show correctly
table.getRows().add().getCells().add("竤---䧜",textState);// both Chinese symbols are not shown correctly
doc.getPages().get_Item(1).getParagraphs().add(table);
doc.save(myDir+"Result.pdf");
Hallo
Thank you for the answer. In the application I am writing, the text comes from the user, so I do not know what font to use. The code snippet was a minimal sample to demonstrate my issue.
After I opened the document I attached(I re-attached it, because the first one seems to be a fail) with “PDF-Viewer”, I noticed that the first and 3rd cell use the ArialUnicodeMs font, while the 2nd and 4th cell use the MSGothic font.
When not specifying the font, there seems to be an algorithmus that does the matching, and it seems that in some cases it could be improved. But since you wrote that using an appropriate font for the contents is required, I guess it is too much to ask to improve the matching algorithmus
Thank you for the clarification,
Samuel
Hi Samuel,
Hallo
|Meanwhile can you please confirm whether setting font folder resolved this issue?
They are unrelated.
Setting the font explicitly, as it was proposed, solves this minimal sample.
Thank you,
Samuel
Hi Samuel,
Frunza:
After I opened the document I attached(I re-attached it, because the first one seems to be a fail) with “PDF-Viewer”, I noticed that the first and 3rd cell use the ArialUnicodeMs font, while the 2nd and 4th cell use the MSGothic font.
When not specifying the font, there seems to be an algorithmus that does the matching, and it seems that in some cases it could be improved. But since you wrote that using an appropriate font for the contents is required, I guess it is too much to ask to improve the matching algorithmus
Hi Samuel,
System.out.println(FontRepository.findFont(“MingLiU”).doesFontContainAllCharacters(“竤”));<o:p></o:p>
System.out.println(FontRepository.findFont("Arial Unicode MS").doesFontContainAllCharacters("竤"));
System.out.println(FontRepository.findFont("MSGothic").doesFontContainAllCharacters("竤"));
Best Regards,
Hallo
Ok, I understand how it is done.
This actually works great for me.
Thank you,
Samuel
Hi Samuel,