List of usage examples for com.lowagie.text Element ALIGN_CENTER
int ALIGN_CENTER
To view the source code for com.lowagie.text Element ALIGN_CENTER.
Click Source Link
From source file:com.bibisco.export.ITextExporter.java
License:GNU General Public License
@Override public void startParagraph(ParagraphAligment pParagraphAligment, boolean pBlnParagraphIndent) { mLog.debug("Start startParagraph()"); mParagraph = new Paragraph(22); if (pBlnParagraphIndent) { mParagraph.setFirstLineIndent(PARAGRAPH_FIRST_LINE_INDENT); } else {// www.j av a2s.c om mParagraph.setFirstLineIndent(0); } switch (pParagraphAligment) { case LEFT: mParagraph.setAlignment(Element.ALIGN_LEFT); break; case CENTER: mParagraph.setAlignment(Element.ALIGN_CENTER); break; case RIGHT: mParagraph.setAlignment(Element.ALIGN_RIGHT); break; case JUSTIFY: mParagraph.setAlignment(Element.ALIGN_JUSTIFIED); break; default: break; } mLog.debug("End startParagraph()"); }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected PdfPTable exportPDFTable(FacesContext context, DataList list, boolean pageOnly, String encoding) { if (!("-".equalsIgnoreCase(encoding))) { createCustomFonts(encoding);//from www. j av a 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.bytecode.customexporter.PDFCustomExporter.java
protected void tableFacet(FacesContext context, PdfPTable pdfTable, DataTable table, int columnCount, String facetType) {//from www .j a v a 2 s . 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.bytecode.customexporter.PDFCustomExporter.java
protected void tableFacet(FacesContext context, PdfPTable pdfTable, SubTable table, int columnCount, String facetType) {//from w w w . j a va2s. 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(); }//ww w . j a v a 2s . co 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(); }// www.j av a 2 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 exportRow(DataTable table, PdfPTable pdfTable, int rowIndex) { table.setRowIndex(rowIndex);//w ww . j a v a 2s.c o m if (!table.isRowAvailable()) { return; } exportCells(table, pdfTable); SummaryRow sr = table.getSummaryRow(); if (sr != null && sr.isInView()) { for (UIComponent summaryComponent : sr.getChildren()) { UIColumn column = (UIColumn) summaryComponent; StringBuilder builder = new StringBuilder(); for (UIComponent component : column.getChildren()) { if (component.isRendered()) { String value = exportValue(FacesContext.getCurrentInstance(), component); if (value != null) { builder.append(value); } } } int rowSpan = column.getRowspan(); int colSpan = column.getColspan(); PdfPCell cell = new PdfPCell(new Paragraph(builder.toString(), 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); } pdfTable.addCell(cell); } } }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected void addColumnFacets(DataTable table, PdfPTable pdfTable, ColumnType columnType) { for (UIColumn col : table.getColumns()) { if (col instanceof DynamicColumn) { ((DynamicColumn) col).applyStatelessModel(); }/*ww w . j a va2 s . c om*/ PdfPCell cell = null; if (col.isRendered() && col.isExportable()) { if (col.getHeaderText() != null && columnType.name().equalsIgnoreCase("header")) { cell = new PdfPCell(new Paragraph(col.getHeaderText(), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell); } else if (col.getFooterText() != null && columnType.name().equalsIgnoreCase("footer")) { cell = new PdfPCell(new Paragraph(col.getFooterText(), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } pdfTable.addCell(cell); } else { addColumnValue(pdfTable, col.getFacet(columnType.facet()), this.facetFont, columnType.name()); } } } }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected void addColumnFacets(SubTable table, PdfPTable pdfTable, ColumnType columnType) { for (UIColumn col : table.getColumns()) { if (col instanceof DynamicColumn) { ((DynamicColumn) col).applyStatelessModel(); }//from w ww . j a va2 s. c om PdfPCell cell = null; if (col.isRendered() && col.isExportable()) { if (col.getHeaderText() != null && columnType.name().equalsIgnoreCase("header")) { cell = new PdfPCell(new Paragraph(col.getHeaderText(), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell); } else if (col.getFooterText() != null && columnType.name().equalsIgnoreCase("footer")) { cell = new PdfPCell(new Paragraph(col.getFooterText(), this.facetFont)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } pdfTable.addCell(cell); } else { addColumnValue(pdfTable, col.getFacet(columnType.facet()), this.facetFont, columnType.name()); } } } }
From source file:com.bytecode.customexporter.PDFCustomExporter.java
protected PdfPCell addColumnAlignments(UIComponent component, PdfPCell cell) { if (component instanceof HtmlOutputText) { HtmlOutputText output = (HtmlOutputText) component; if (output.getStyle() != null && output.getStyle().contains("left")) { cell.setHorizontalAlignment(Element.ALIGN_LEFT); }/*from w w w . j av a2 s .com*/ if (output.getStyle() != null && output.getStyle().contains("right")) { cell.setHorizontalAlignment(Element.ALIGN_RIGHT); } if (output.getStyle() != null && output.getStyle().contains("center")) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); } } return cell; }