Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
I have two lists of dynamic sizes containing child part numbers (first level BOM) of a part and its predecessor. I would like to print on pdf in the format of a table as shown below;
list 1 | list 2 |
1003 | 1000 |
1002 | 1002 |
1004 |
|
1005 |
|
The function I am using retrieves one list and populates the already created table using that list (itextPDF.PDFcell) See code snippets below;
PdfPTable table = new PdfPTable(2);
table.setSpacingBefore(8);
table.setWidthPercentage(80f);
insertCell(table, list1, Element.ALIGN_CENTER, 1, fa); // insert 1st column
insertCell(table, list2, Element.ALIGN_CENTER, 1, fa); // insert 2nd column
table.setHeaderRows(1);
for (String value : list) {
insertCellAll(table, value, fa); //insert rows
}
public static void insertCellAll(PdfPTable table, String text, Font fa) {
// create a new cell with the specified Text and Font
PdfPCell cell = new PdfPCell(new Phrase(text.trim(), fa));
if (text.trim().equalsIgnoreCase("")) {
cell.setMinimumHeight(10f);
}
// add the call to the table
table.addCell(cell);
}
How do I concatenate both lists to allow me solve this problem and is there another way to go about printing tables using lists with dynamic values?