We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Multiple fonts and languages in the table or cell

I am searching a library for PDF generation for Java.
We have several requirements:

  1. To insert a picture into PDF document;
  2. The document should be saved into OutputStream class;
  3. Table generation;
  4. Multiple languages (fonts) in one cell. So, I guess several fonts should be loaded and selected when set into the cell.

The last point is most complicated, I think.
Could you tell me if aspose pdf library supports the requirements.



Thank you for contacting support.

Please visit below documentation articles for your kind reference.

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.

Thank you for the reply,

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?

Is your library provides any Asian fonts?



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
TextFragment Font1 = new TextFragment("Times New Roman");
TextFragment Font2 = new TextFragment("Arial");
// Add table object to page of document
dataDir = dataDir + "document_with_table_18.11.pdf";
// Save updated document containing table object

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.