Need to make PDF sample with drawers as table columns using android app
I need to make a sample PDF file in the same way as in the image below, but I haven't found a suitable guide to do exactly that. I followed some links
http://itextpdf.com/examples/iia.php?id=102
Is there a way to draw a rectangle in PdfPCell in iText (Java version)?
but from the second link I didn't understand how I could be more likely to fulfill my requirements.
Thanks in advance.
source to share
It's not clear to me why you are referring to this example: http://itextpdf.com/examples/iia.php?id=102 The PDF generated with this example shows me in Superman gear. What is the relationship with creating a table with rounded borders?
Please see the NestedTableRoundedBorder example . It creates a PDF that looks like this: nested_table_rounded_border.pdf
This construct consists of nested tables. The outer table only has one column, but we use it to create rounded corners:
class RoundRectangle implements PdfPCellEvent {
public void cellLayout(PdfPCell cell, Rectangle rect,
PdfContentByte[] canvas) {
PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
cb.roundRectangle(
rect.getLeft() + 1.5f, rect.getBottom() + 1.5f, rect.getWidth() - 3,
rect.getHeight() - 3, 4);
cb.stroke();
}
}
This cell event is used like this:
cell = new PdfPCell(innertable); cell.setCellEvent(roundRectangle); cell.setBorder(Rectangle.NO_BORDER); cell.setPadding(8); outertable.addCell(cell);
Internal tables are used to create cells with or without borders, for example:
// inner table 1
PdfPTable innertable = new PdfPTable(5);
innertable.setWidths(new int[]{8, 12, 1, 4, 12});
// first row
// column 1
cell = new PdfPCell(new Phrase("Record Ref:"));
cell.setBorder(Rectangle.NO_BORDER);
innertable.addCell(cell);
// column 2
cell = new PdfPCell(new Phrase("GN Staff"));
cell.setPaddingLeft(2);
innertable.addCell(cell);
// column 3
cell = new PdfPCell();
cell.setBorder(Rectangle.NO_BORDER);
innertable.addCell(cell);
// column 4
cell = new PdfPCell(new Phrase("Date: "));
cell.setBorder(Rectangle.NO_BORDER);
innertable.addCell(cell);
// column 5
cell = new PdfPCell(new Phrase("30/4/2015"));
cell.setPaddingLeft(2);
innertable.addCell(cell);
// spacing
cell = new PdfPCell();
cell.setColspan(5);
cell.setFixedHeight(3);
cell.setBorder(Rectangle.NO_BORDER);
innertable.addCell(cell);
If some of the parameters are very similar, you want to change the parameters like the array width, padding, fixed height, etc.
source to share