You can use any font for any text with setFont method as in suggested examples. Moreover, Document class includes several overloads of Save method which allows to save into OutputStream as well.
We hope this will be helpful. Please feel free to contact us if you need any further assistance.
Could you confirm that there is an ability to use multiple languages (Chinese, Japan, Spanish, for example) in ONE cell of pdf table? And how should I use setFont in this case?
You may use different fonts in same cell as demonstrated in below code snippet:
// Load source PDF document
Document doc = new Document();
Page page = doc.getPages().add();
// Initializes a new instance of the Table
Table table = new Table();
// Set the table border color as LightGray
table.setBorder(new BorderInfo(BorderSide.All, .5f, Color.getLightGray()));
// set the border for table cells
table.setDefaultCellBorder(new BorderInfo(BorderSide.All, .5f, Color.getLightGray()));
// Add a row to table
Row row = table.getRows().add();
// Add table cells
row.getCells().add();
row.getCells().add();
TextFragment Font1 = new TextFragment("Times New Roman");
TextFragment Font2 = new TextFragment("Arial");
Font1.getTextState().setFont(FontRepository.findFont("TimesNewRoman"));
Font2.getTextState().setFont(FontRepository.findFont("Arial"));
table.getRows().get_Item(0).getCells().get_Item(0).getParagraphs().add(Font1);
table.getRows().get_Item(0).getCells().get_Item(0).getParagraphs().add(Font2);
// Add table object to page of document
page.getParagraphs().add(table);
dataDir = dataDir + "document_with_table_18.11.pdf";
// Save updated document containing table object
doc.save(dataDir);
Moreover, Aspose.PDF for Java supports all fonts, be it TTF or OTF fonts. We hope this will be helpful. Please feel free to contact us if you need any further assistance.