setfreezeChildren(true) will render all the child components of Div in a single page.
Example:
Div div = new Div();
div.setFreezeChildren(true);
div.setWidth(200);
div.setHeight(100);
div.borders(true);
div.setBorderColor(Color.decode("#057dcd"));
Div childDiv1 = new Div();
childDiv1.setWidth(div.getWidth() / 2);
childDiv1.setHeight(90);
childDiv1.borders(true);
childDiv1.setBorderColor(Color.decode("#464646"));
div.appendChild(childDiv1);
Div childDiv2 = new Div();
childDiv2.setWidthPercentage(50);
childDiv2.setHeight(90);
childDiv2.borders(true);
childDiv2.setMarginLeft(childDiv1.getWidth());
childDiv2.setBorderColor(Color.decode("#464646"));
div.appendChild(childDiv2);
page.addWidget(div);
Table
Table allows you to arrange data like text, images, links, etc. in rows and columns. It implements FontProperties.
DataTable is a wrapper on top of the Table to provide abstraction of low-level details for table construction like, creating table, row objects etc. It provides methods to deal with data.
The available methods are:
void
setCellConfigs(List<CellConfig> cellConfigs);
List<CellConfig> getCellConfigs();
void setRows(List<RowData> rowsData);
List<RowData> getRows();
Color getHeaderBackgroundColor();
void setHeaderBackgroundColor(Color HeaderBackgroundColor);
Color getHeaderFontColor();
void setHeaderFontColor(Color headerFontColor);
Color getCellBackgroundColor();
void setCellBackgroundColor(Color cellBackgroundColor);
Color getCellFontColor();
void setCellFontColor(Color cellFontColor);
Alignment getHeaderCellAlignment();
void setHeaderCellAlignment(Alignment headerCellAlignment);
boolean isHideHeader();
void setHideHeader(boolean hideHeader);
Example:
DataTable dataTable = new DataTable();
// Create each CellConfiguaration like title, backgroundColor etc..
CellConfig cell1Config = new CellConfig("id", "Id #");
cell1Config.setBackgroundColor(Color.BLUE);
CellConfig cell2Config = new CellConfig("name", "Name");
List < CellConfig > cellConfigs = new ArrayList < > ();
cellConfigs.add(cell1Config);
cellConfigs.add(cell2Config);
// Prepare the Data, a simple list of RowData Object
List < RowData > rowsData = getData();
dataTable.setCellConfigs(cellConfigs);
dataTable.setRows(rowsData);
page.addWidget(dataTable);
FormPanel
Formpanel allows you to arrange a row of data in a form-like structure and provides methods to customize the form.
The widget uses the properties of its parent component.
Image is a container to hold an image. You can use all methods of widget provider.
The available constructors are:
public Image(String filePath, float, width, float, height);
public Image(File file, float, width, float, height);
public Image(URL remoteFileUrl, float, width, float, height);
public Image(String filePath);
public Image(File file);
public Image(URL remoteFileUrl);
Example:
Image image = new Image( new File("path to image"));
image.setWidth(100);
image.setHeight(100);
page.addWidget(image);
TextBox
TextBox is the wrapper for a paragraph in a PDF. It automatically breaks and aligns the paragraph to fit into its width. You can use all methods of widget provider.
The widget uses the properties of its parent component.
Example:
TextBox textBox = new TextBox("Sed ut perspiciatis, unde omnis iste natus error ");
textBox.setWidth(50);
textBox.setHeight(50);
page.addWidget(textBox);
BorderProps
BorderProps can be used to implement methods for creating and customizing borders.
PageCounter is the wrapper to render a dynamic value of current page index or total pages count in PDF. You can use all methods of MBWidget provider.
The available methods and expressions are:
public static final String CURRENT_PAGE_INDEX = "#{currPage}";
public static final String TOTAL_PAGES = "#{totalPages}";
void setExpression(String expression);
String getExpression();
Example:
Div div = new Div();
div.getExpression();
Header
Header is the wrapper for an area at the top of a PDF Page. You can use all methods of the Div provider.