List of usage examples for com.lowagie.text.pdf PdfPTable completeRow
public void completeRow()
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected PdfPTable exportPDFTable(FacesContext context, DataList list, boolean pageOnly, String encoding) { if (!("-".equalsIgnoreCase(encoding))) { createCustomFonts(encoding);// w w w . j a va 2 s . c o m } int first = list.getFirst(); int rowCount = list.getRowCount(); int rowsToExport = first + list.getRows(); PdfPTable pdfTable = new PdfPTable(1); if (list.getHeader() != null) { String value = exportValue(FacesContext.getCurrentInstance(), list.getHeader()); PdfPCell cell = new PdfPCell(new Paragraph((value), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell); pdfTable.completeRow(); } StringBuilder builder = new StringBuilder(); String output = null; if (pageOnly) { output = exportPageOnly(first, list, rowsToExport, builder); } else { output = exportAll(list, rowCount, builder); } pdfTable.addCell(new Paragraph(output, cellFont)); pdfTable.completeRow(); if (list.getFooter() != null) { String value = exportValue(FacesContext.getCurrentInstance(), list.getFooter()); PdfPCell cell = new PdfPCell(new Paragraph((value), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell); pdfTable.completeRow(); } return pdfTable; }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected void tableFacet(FacesContext context, PdfPTable pdfTable, DataTable table, int columnCount, String facetType) {// ww w .j av a 2 s . com Map<String, UIComponent> map = table.getFacets(); UIComponent component = map.get(facetType); if (component != null) { String headerValue = null; if (component instanceof HtmlCommandButton) { headerValue = exportValue(context, component); } else if (component instanceof HtmlCommandLink) { headerValue = exportValue(context, component); } else if (component instanceof UIPanel || component instanceof OutputPanel) { String header = ""; for (UIComponent child : component.getChildren()) { headerValue = exportValue(context, child); header = header + headerValue; } PdfPCell cell = new PdfPCell(new Paragraph((header), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); //addColumnAlignments(component,cell); cell.setColspan(columnCount); pdfTable.addCell(cell); pdfTable.completeRow(); return; } else { headerValue = exportFacetValue(context, component); } PdfPCell cell = new PdfPCell(new Paragraph((headerValue), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); //addColumnAlignments(component,cell); cell.setColspan(columnCount); pdfTable.addCell(cell); pdfTable.completeRow(); } }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected void tableFacet(FacesContext context, PdfPTable pdfTable, SubTable table, int columnCount, String facetType) {/*from w w w . ja v a 2 s . c om*/ Map<String, UIComponent> map = table.getFacets(); UIComponent component = map.get(facetType); if (component != null) { String headerValue = null; if (component instanceof HtmlCommandButton) { headerValue = exportValue(context, component); } else if (component instanceof HtmlCommandLink) { headerValue = exportValue(context, component); } else if (component instanceof UIPanel || component instanceof OutputPanel) { String header = ""; for (UIComponent child : component.getChildren()) { headerValue = exportValue(context, child); header = header + headerValue; } PdfPCell cell = new PdfPCell(new Paragraph((header), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); //addColumnAlignments(component,cell); cell.setColspan(columnCount); pdfTable.addCell(cell); pdfTable.completeRow(); return; } else { headerValue = exportFacetValue(context, component); } PdfPCell cell = new PdfPCell(new Paragraph((headerValue), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); // addColumnAlignments(component,cell); cell.setColspan(columnCount); pdfTable.addCell(cell); pdfTable.completeRow(); } }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected void tableColumnGroup(PdfPTable pdfTable, DataTable table, String facetType) { ColumnGroup cg = table.getColumnGroup(facetType); List<UIComponent> headerComponentList = null; if (cg != null) { headerComponentList = cg.getChildren(); }//from w w w.ja va2 s .c o m if (headerComponentList != null) for (UIComponent component : headerComponentList) { if (component instanceof Row) { Row row = (Row) component; for (UIComponent rowComponent : row.getChildren()) { UIColumn column = (UIColumn) rowComponent; String value = null; if (facetType.equalsIgnoreCase("header")) { value = column.getHeaderText(); } else value = column.getFooterText(); int rowSpan = column.getRowspan(); int colSpan = column.getColspan(); PdfPCell cell = new PdfPCell(new Paragraph(value, this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } if (rowSpan > 1) { cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setRowspan(rowSpan); } if (colSpan > 1) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(colSpan); } // addColumnAlignments(component,cell); if (facetType.equalsIgnoreCase("header")) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); } pdfTable.addCell(cell); } } } pdfTable.completeRow(); }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected void tableColumnGroup(PdfPTable pdfTable, SubTable table, String facetType) { ColumnGroup cg = table.getColumnGroup(facetType); List<UIComponent> headerComponentList = null; if (cg != null) { headerComponentList = cg.getChildren(); }// ww w. j av a2s. c o m if (headerComponentList != null) for (UIComponent component : headerComponentList) { if (component instanceof Row) { Row row = (Row) component; for (UIComponent rowComponent : row.getChildren()) { UIColumn column = (UIColumn) rowComponent; String value = null; if (facetType.equalsIgnoreCase("header")) { value = column.getHeaderText(); } else value = column.getFooterText(); int rowSpan = column.getRowspan(); int colSpan = column.getColspan(); PdfPCell cell = new PdfPCell(new Paragraph(value, this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } if (rowSpan > 1) { cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setRowspan(rowSpan); } if (colSpan > 1) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(colSpan); } // addColumnAlignments(component,cell); if (facetType.equalsIgnoreCase("header")) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); } pdfTable.addCell(cell); } } } pdfTable.completeRow(); }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected void exportCells(DataTable table, PdfPTable pdfTable) { for (UIColumn col : table.getColumns()) { if (col instanceof DynamicColumn) { ((DynamicColumn) col).applyStatelessModel(); }//from www .ja v a2 s . co m if (col.isRendered() && col.isExportable()) { if (col.getSelectionMode() != null) { pdfTable.addCell(new Paragraph(col.getSelectionMode(), this.cellFont)); continue; } addColumnValue(pdfTable, col.getChildren(), this.cellFont, "data"); } } pdfTable.completeRow(); FacesContext context = null; if (table.getRowIndex() == 0) { for (UIComponent component : table.getChildren()) { if (component instanceof RowExpansion) { RowExpansion rowExpansion = (RowExpansion) component; if (rowExpansion.getChildren() != null) { if (rowExpansion.getChildren().get(0) instanceof DataTable) { DataTable childTable = (DataTable) rowExpansion.getChildren().get(0); childTable.setRowIndex(-1); } if (rowExpansion.getChildren().get(0) instanceof DataList) { DataList childList = (DataList) rowExpansion.getChildren().get(0); childList.setRowIndex(-1); } } } } } for (UIComponent component : table.getChildren()) { if (component instanceof RowExpansion) { RowExpansion rowExpansion = (RowExpansion) component; if (rowExpansion.getChildren() != null) { if (rowExpansion.getChildren().get(0) instanceof DataTable) { DataTable childTable = (DataTable) rowExpansion.getChildren().get(0); PdfPTable pdfTableChild = exportPDFTable(context, childTable, false, false, "-", false); PdfPCell cell = new PdfPCell(); cell.addElement(pdfTableChild); cell.setColspan(pdfTable.getNumberOfColumns()); pdfTable.addCell(cell); } if (rowExpansion.getChildren().get(0) instanceof DataList) { DataList list = (DataList) rowExpansion.getChildren().get(0); PdfPTable pdfTableChild = exportPDFTable(context, list, false, "-"); pdfTableChild.getDefaultCell().setBorder(Rectangle.NO_BORDER); PdfPCell cell = new PdfPCell(); cell.addElement(pdfTableChild); cell.setColspan(pdfTable.getNumberOfColumns()); } } } pdfTable.completeRow(); } }
From source file:com.crm.webapp.util.PDFCustomExporter.java
License:Apache License
protected PdfPTable exportPDFTable(FacesContext context, DataList list, boolean pageOnly, String encoding) { if (!("-".equalsIgnoreCase(encoding))) { createCustomFonts(encoding);/* w w w . j a va 2s .c o m*/ } int first = list.getFirst(); int rowCount = list.getRowCount(); int rowsToExport = first + list.getRows(); PdfPTable pdfTable = new PdfPTable(1); if (list.getHeader() != null) { String value = exportValue(FacesContext.getCurrentInstance(), list.getHeader()); PdfPCell cell = new PdfPCell(new Paragraph((value), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell); pdfTable.completeRow(); } StringBuilder builder = new StringBuilder(); String output = null; if (pageOnly) { output = exportPageOnly(first, list, rowsToExport, builder); } else { output = exportAll(list, rowCount, builder); } pdfTable.addCell(new Paragraph(output, cellFont)); pdfTable.completeRow(); if (list.getFooter() != null) { String value = exportValue(FacesContext.getCurrentInstance(), list.getFooter()); PdfPCell cell = new PdfPCell(new Paragraph((value), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell); pdfTable.completeRow(); } return pdfTable; }
From source file:com.crm.webapp.util.PDFCustomExporter.java
License:Apache License
protected void tableFacet(FacesContext context, PdfPTable pdfTable, DataTable table, int columnCount, String facetType) {/*w w w.j ava 2s .c om*/ Map<String, UIComponent> map = table.getFacets(); UIComponent component = map.get(facetType); if (component != null) { String headerValue = null; if (component instanceof HtmlCommandButton) { headerValue = exportValue(context, component); } else if (component instanceof HtmlCommandLink) { headerValue = exportValue(context, component); } else if (component instanceof UIPanel || component instanceof OutputPanel) { String header = ""; for (UIComponent child : component.getChildren()) { headerValue = exportValue(context, child); header = header + headerValue; } PdfPCell cell = new PdfPCell(new Paragraph((header), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); //addColumnAlignments(component,cell); cell.setColspan(columnCount); pdfTable.addCell(cell); pdfTable.completeRow(); return; } else { headerValue = exportFacetValue(context, component); } PdfPCell cell = new PdfPCell(new Paragraph((headerValue), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); //addColumnAlignments(component,cell); cell.setColspan(columnCount); pdfTable.addCell(cell); pdfTable.completeRow(); } }
From source file:com.crm.webapp.util.PDFCustomExporter.java
License:Apache License
protected void tableFacet(FacesContext context, PdfPTable pdfTable, SubTable table, int columnCount, String facetType) {//w w w . j av a2s. co m Map<String, UIComponent> map = table.getFacets(); UIComponent component = map.get(facetType); if (component != null) { String headerValue = null; if (component instanceof HtmlCommandButton) { headerValue = exportValue(context, component); } else if (component instanceof HtmlCommandLink) { headerValue = exportValue(context, component); } else if (component instanceof UIPanel || component instanceof OutputPanel) { String header = ""; for (UIComponent child : component.getChildren()) { headerValue = exportValue(context, child); header = header + headerValue; } PdfPCell cell = new PdfPCell(new Paragraph((header), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); //addColumnAlignments(component,cell); cell.setColspan(columnCount); pdfTable.addCell(cell); pdfTable.completeRow(); return; } else { headerValue = exportFacetValue(context, component); } PdfPCell cell = new PdfPCell(new Paragraph((headerValue), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); // addColumnAlignments(component,cell); cell.setColspan(columnCount); pdfTable.addCell(cell); pdfTable.completeRow(); } }
From source file:com.crm.webapp.util.PDFCustomExporter.java
License:Apache License
protected void tableColumnGroup(PdfPTable pdfTable, DataTable table, String facetType) { ColumnGroup cg = table.getColumnGroup(facetType); List<UIComponent> headerComponentList = null; if (cg != null) { headerComponentList = cg.getChildren(); }//from w w w .jav a2 s . c o m if (headerComponentList != null) { for (UIComponent component : headerComponentList) { if (component instanceof Row) { Row row = (Row) component; for (UIComponent rowComponent : row.getChildren()) { UIColumn column = (UIColumn) rowComponent; String value = null; if (facetType.equalsIgnoreCase("header")) { value = column.getHeaderText(); } else { value = column.getFooterText(); } int rowSpan = column.getRowspan(); int colSpan = column.getColspan(); PdfPCell cell = new PdfPCell(new Paragraph(value, this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } if (rowSpan > 1) { cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setRowspan(rowSpan); } if (colSpan > 1) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(colSpan); } // addColumnAlignments(component,cell); if (facetType.equalsIgnoreCase("header")) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); } pdfTable.addCell(cell); } } } } pdfTable.completeRow(); }