Hello,
I was wondering if its possible to add a parameter or a way to define a # rows in a table while rendering the PDF.
Example: Right now, when we use tables, the # of rows equals the # of records, but what I am looking to find is - If I define a parameter (lets say 5) and the number of records I have is 3, my table still displays 5 rows but the last 2 will be empty rows.
Is there a way to do this? Please advice.
Thank you!
@gbrunda There is no direct way to achieve this upon building the report. You have three options:
-
Add empty records in your data source so that upon building the report empty rows will be added to the table.
-
Define empty rows after the data rows in your template.
-
You can add empty rows to the table programmatically:
Document doc = new Document("C:\\Temp\\in.docx");
// Get the table.
Table table = doc.getFirstSection().getBody().getTables().get(0);
// Add empty rows to the table.
Row emptyRow = (Row)table.getLastRow().deepClone(true);
emptyRow.getChildNodes(NodeType.PARAGRAPH, true).clear();
for (int i = 0; i < 5; i++)
table.appendChild(emptyRow.deepClone(true));
doc.save("C:\\Temp\\out.docx");
1 Like
Thank you, I think this is helpful for now. If any questions or need additional information, I will repost.
1 Like