Custom table : different widths for cells within same column

Hi support,

Please take a look on the attachement and specify if this type of table can be written with aspose.pdf for java.

Thank you,
Milan

Hello Milan,

Please try using the following code snippet to accomplish your requirement. The code is based over Aspose.Pdf for Java 2.5.0. Please try using it and in case you face any problem or you've any further query, please feel free to contact.

The resultant PDF is also in attachment, please take a look.

[Java]

Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();

Table table1 = new Table();
sec1.getParagraphs().add(table1);
table1.setColumnWidths("20 20 20 20 20 20");
table1.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5f));
table1.setDefaultCellBorder(new BorderInfo(BorderSide.All.getValue(), 0.5f));

Row row1 = table1.getRows().add();

Cell cell1Row1 = row1.getCells().add("a1");
cell1Row1.setColumnsSpan(2);

Cell cell2Row1 = row1.getCells().add("a2");
cell2Row1.setColumnsSpan(3);

Row row2 = table1.getRows().add();

Cell cell1Row2 = row2.getCells().add("a3");
cell1Row2.setColumnsSpan(2);

Cell cell2Row2 = row2.getCells().add("a4");
cell2Row2.setColumnsSpan(2);

Cell cell3Row2 = row2.getCells().add("a5");
cell3Row2.setColumnsSpan(2);

pdf1.save("d:/pdftest/Custom_table_Testing.pdf");

Hy Nayyer,

Thank you for the code.

Regards,
Milan