Hi,
I have a code like this
Cell c = r.getCells().add(result);
c.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5F));
where “r” is aspose.pdf.Row and “result” is a String object.
I also used pdf.setUnicode(); and Font as Arial Unicode MS. Still I am unable to at least display utf8 characters in the Cell.
Note: I’m however able to display non-unicode characters perfectly in Cell of aspose.pdf.Table.
Please let me know if there is solution for this.
Thanks and Regards,
Baig
Hi Baig,
Thanks for contacting support.
I have tested the scenario using Aspose.Pdf for Java 4.5.1 where I have used the following code snippet and as per my observations, the UTF-8 characters are properly appearing in resultant PDF file. For your reference, I have also attached the resultant PDF generated over my end. In case you still face the same issue, please share the UTF-8 characters which you are using so that we can again test the scenario at our end. We are sorry for your inconvenience.
Java
aspose.pdf.Pdf pdf = new aspose.pdf.Pdf();
aspose.pdf.Section sec = pdf.getSections().add();
// Instantiate a table object
Table table = new Table(sec);
// Add the table in paragraphs collection of the desired section
sec.getParagraphs().add(table);
// Set with column widths of the table
table.setColumnWidths("250 50 50");
// Set default cell border using BorderInfo object
table.setDefaultCellBorder(new BorderInfo(aspose.pdf.BorderSide.All, 0.1F));
// Set table border using another customized BorderInfo object
table.setBorder(new BorderInfo(aspose.pdf.BorderSide.All, 1F));
// Create MarginInfo object and set its left, bottom, right and top margins
MarginInfo margin = new MarginInfo();
margin.setLeft(5f);
margin.setRight(5f);
margin.setTop(5f);
margin.setBottom(5f);
// Set the default cell padding to the MarginInfo object
table.setDefaultCellPadding(margin);
// Create rows in the table and then cells in the rows
Row row1 = table.getRows().add();
aspose.pdf.Cell cell1 = new aspose.pdf.Cell(row1);
cell1.getParagraphs().add(new aspose.pdf.Text("Common: “ ” ‘ ’ – — … ‐ ‒ ° © ® ™ • ½ ¼ ¾ ⅓ ⅔ † ‡ µ ¢ £ € « » ♠ ♣ ♥ ♦ ¿"));
cell1.getDefaultCellTextInfo().setFontName("Arial Unicode MS");
row1.getCells().add(cell1);
row1.getCells().add("col2");
row1.getCells().add("col3");
Row row2 = table.getRows().add();
row2.getCells().add("item1");
row2.getCells().add("item2");
row2.getCells().add("item3");
pdf.setUnicode();
pdf.save("c:/pdftest/UTF-8_Characters.pdf");