if(StringUtils.isNotEmpty(left)){ if(StringUtils.isNotEmpty(center) && StringUtils.isNotEmpty(right)){ table = new PdfPTable(3); table.setWidths(new int[]{1, 1, 1}); table.addCell(buildPdfPCell(hf,left,1)); table.addCell(buildPdfPCell(hf,right,3)); }else if(StringUtils.isNotEmpty(center)){ table = new PdfPTable(3); table.setWidths(new int[]{1, 1, 1}); table.addCell(buildPdfPCell(hf,left,1)); table.addCell(buildPdfPCell(hf,"",3)); }else if(StringUtils.isNotEmpty(right)){ table = new PdfPTable(3); table.setWidths(new int[]{1, 1, 1}); table.addCell(buildPdfPCell(hf,left,1)); table.addCell(buildPdfPCell(hf,right,3)); }else{ table = new PdfPTable(1); table.setWidths(new int[]{1}); table.addCell(buildPdfPCell(hf,left,1)); table = new PdfPTable(3); table.setWidths(new int[]{1, 1, 1}); table.addCell(buildPdfPCell(hf,"",1)); table.addCell(buildPdfPCell(hf,right,3));
/** * Makes a shallow copy of a table (format without content). * * @param table * @return a shallow copy of the table */ public static PdfPTable shallowCopy(final PdfPTable table) { PdfPTable nt = new PdfPTable(); nt.copyFormat(table); return nt; }
/** * Makes a shallow copy of a table (format without content). * * @param table * @return a shallow copy of the table */ public static PdfPTable shallowCopy(final PdfPTable table) { PdfPTable nt = new PdfPTable(); nt.copyFormat(table); return nt; }
Map<Row, Map<Column, Cell>> cellMap=report.getRowColCellMap(); for(List<Page> pages:list){ PdfPTable table=new PdfPTable(size); table.setLockedWidth(true); table.setTotalWidth(w); PdfPTable childTable=new PdfPTable(colSize); childTable.setLockedWidth(true); childTable.setTotalWidth(totalWidth); Map<Row, Map<Column, Cell>> cellMap=report.getRowColCellMap(); for(Page page:pages){ PdfPTable table=new PdfPTable(colSize); table.setLockedWidth(true); table.setTotalWidth(totalWidth);
private PdfPTable createTable( PdfPCell cell ) { PdfPTable table = new PdfPTable( 1 ); table.setWidthPercentage( 100.0f ); table.setSplitLate( false ); table.addCell( cell ); return table; }
/** * Factory method for create a new {@link PdfPTable} with the given count of columns and the * column header names * * @param numColumns * the count of columns of the table * @param headerNames * the column header names * @return the new {@link PdfPTable} */ public static PdfPTable newPdfPTable(int numColumns, List<String> headerNames) { PdfPTable table = new PdfPTable(numColumns); headerNames.stream().forEach(columnHeaderName -> { PdfPCell header = new PdfPCell(); header.setBackgroundColor(BaseColor.LIGHT_GRAY); header.setBorderWidth(2); header.setPhrase(new Phrase(columnHeaderName)); table.addCell(header); }); return table; }
public static Paragraph constructTitle( IParagraphFactory factory, Paragraph ancestorTitle, ArrayList numbers, int numberDepth, int numberStyle, PdfPCell cell ) { if ( ancestorTitle != null && cell != null ) { Paragraph newTitle = factory.createParagraph(); PdfPTable table = new PdfPTable( 1 ); table.setWidthPercentage( 100f ); cell.addElement( ancestorTitle ); table.addCell( cell ); newTitle.add( table ); return newTitle; } return ancestorTitle; }
/** * Initialize the main info holder table. */ protected void initTable() { this.tablePDF = new PdfPTable(this.model.getNumberOfColumns()); this.tablePDF.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP); this.tablePDF.setWidthPercentage(100); this.smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new BaseColor(0, 0, 0)); }
@Override public void emit(Steps stepContainer, ITextContext emitterContext) { PdfPTable steps = new PdfPTable(new float[]{1f, 2f, 22f}); for (StepExec stepExec : stepContainer.steps()) { emitStep(steps, stepExec, emitterContext); } steps.setWidthPercentage(100); steps.setSpacingBefore(5f); steps.setSpacingAfter(5f); steps.setHorizontalAlignment(Element.ALIGN_LEFT); emitterContext.append(steps); }
public void doExport(OutputStream out) throws DocumentException { Document document = new Document(); PdfWriter.getInstance(document, out); document.open(); PdfPTable pdf = new PdfPTable(table.getHeaders().size()); pdf.setWidthPercentage(100); title(pdf); header(pdf); body(pdf); document.add(pdf); document.close(); }
@Override public void process(int level, Node node, InvocationContext context) { TableNode tableNode = (TableNode) node; List<TableColumnNode> tableNodeColumns = tableNode.getColumns(); PdfPTable table = new PdfPTable(tableNodeColumns.size()); for (PdfPTableEvent tableEvent : tableEvents) { table.setTableEvent(tableEvent); } context.pushTable(new TableInfos(table, tableNodeColumns)); context.processChildren(level, node); context.popTable(); KeyValues kvs = context.iTextContext().keyValues(); Float spacingBefore = kvs.<Float>getNullable(TABLE_SPACING_BEFORE).or(5f); Float spacingAfter = kvs.<Float>getNullable(TABLE_SPACING_AFTER).or(5f); table.setSpacingBefore(spacingBefore); table.setSpacingAfter(spacingAfter); applyAttributes(context, table); context.append(table); }
private PdfPTable createTable(final TestRunCoverageStatistics runStats) throws DocumentException { final PdfPTable table = new PdfPTable(4); table.setSpacingBefore(10); table.setSpacingAfter(10); table.setWidthPercentage(100); table.setHeaderRows(1); table.setWidths(new int[] {70, 10, 10, 10}); addHeader(table); addTotalRow(runStats, table); addFileStatsRows(runStats, table); return table; }
private PdfPTable stepDataTable(DataTable table, Styles styles) { PdfPTable iTable = new PdfPTable(table.nbColumns()); iTable.setTableEvent(new AlternateTableRowBackground(styles)); int rownum = 0; for (DataTable.Row row : table.rows()) { Font font = null; if (rownum == 0) { Optional<Font> fontOpt = styles.getFont(STEP_TABLE_CELL_HEADER); if (fontOpt.isPresent()) { font = fontOpt.get(); } } if (font == null) font = styles.getFontOrDefault(STEP_TABLE_CELL); for (String value : row.cells()) { PdfPCell cell = new PdfPCell(new Phrase(value, font)); iTable.addCell(noBorder(cell)); } rownum++; } return iTable; }
@Override public void emit(TagViews views, ITextContext emitterContext) { Styles styles = emitterContext.styles(); float w = 0.1f; PdfPTable table = new PdfPTable(new float[]{1 - 3 * w, w, w, w}); table.setWidthPercentage(100); table.setSpacingBefore(5f); table.setSpacingAfter(5f); table.setTableEvent(new AlternateTableRowBackground(styles)); emitHeader(table, emitterContext); emitBody(table, views, emitterContext); emitterContext.append(table); }
private PdfPTable createTable( PdfPCell cell ) { PdfPTable table = new PdfPTable( 1 ); table.setSpacingBefore( this.spacingBefore() ); table.setSpacingAfter( this.spacingAfter() ); table.setHorizontalAlignment( this.getHorizontalAlignment() ); table.setTotalWidth( cell.getPaddingLeft() + this.getTotalWidth() + cell.getPaddingRight() ); table.setLockedWidth( true ); table.setSplitLate( false ); table.addCell( cell ); return table; }
/** * @see org.displaytag.export.BinaryExportView#doExport(OutputStream) */ @Override public void doExport(OutputStream out) throws JspException { try { Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40); this.initItextWriter(document, out); document.open(); PdfPTable table = new PdfPTable(this.model.getNumberOfColumns()); ItextTableWriter writer = new ItextTableWriter(table, document); writer.writeTable(this.model, "-1"); document.add(table); document.close(); } catch (Exception e) { throw new ItextGenerationException(e); } }
@Override public void emit(TagDictionary dictionary, ITextContext emitterContext) { Styles styles = emitterContext.styles(); if (headerCellStyler == null) headerCellStyler = new DefaultHeaderCellStyler(styles); FluentIterable<Tag> tags = dictionary.tags(); float w = widthPercent(tags, emitterContext); PdfPTable table = new PdfPTable(new float[]{w, 1 - w}); table.setWidthPercentage(100); table.setSpacingBefore(5f); table.setSpacingAfter(5f); table.setTableEvent(new AlternateTableRowBackground(styles)); emitHeaders(table, headerCellStyler); emitBody(table, tags, emitterContext); emitterContext.append(table); }
private void emitFeature(FeatureExec feature, ITextContext emitterContext) { Styles styles = emitterContext.styles(); Sections sections = emitterContext.sections(); Section featureSection = sections.newSection(feature.name(), hLevel); try { PdfPTable table = new PdfPTable(new float[]{1f, 22f}); for (ScenarioExec scenarioExec : feature.scenario()) { table.addCell(statusCell(scenarioExec.status(), styles)); table.addCell(titleCell(scenarioExec, styles)); } table.setWidthPercentage(100); table.setSpacingBefore(5f); table.setSpacingAfter(5f); featureSection.add(table); } finally { sections.leaveSection(hLevel); } }
private void emitStepInErrorLegend(ITextContext emitterContext) { Styles styles = emitterContext.styles(); PdfPTable table = new PdfPTable(new float[]{1f, 24f}); table.addCell(noBorder(topRight(new PdfPCell(stepInErrorMarker(styles))))); table.addCell(noBorder(new PdfPCell(new Phrase(": First step in error within the scenario", new FontCopier(styles.defaultFont()).italic().get())))); table.setSpacingBefore(10f); table.setSpacingAfter(10f); emitterContext.append(table); }
public static PdfPTable createPDFTable (ReportTableModel rtm) { if (rtm == null ) return null; int colC = rtm.getModel().getColumnCount(); PdfPTable pdfTable = new PdfPTable (colC); for (int i=0; i <colC; i++ ) { PdfPCell c1 = new PdfPCell(new Phrase(rtm.getModel().getColumnName(i), DataDictionaryPDF.getFont(10, Font.BOLD))); c1.setBackgroundColor(BaseColor.GRAY); c1.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(c1); } pdfTable.setHeaderRows(1); // First row is header int rowC = rtm.getModel().getRowCount(); for (int i=0; i < rowC; i++) { for (int j=0; j < colC; j++) { PdfPCell c1 = new PdfPCell(); String valS=""; if (rtm.getModel().getValueAt(i,j) != null) valS= rtm.getModel().getValueAt(i,j).toString(); if(i % 2 == 0 ) c1.setBackgroundColor(new BaseColor(150, 255, 150, 255)); c1.setPhrase(new Phrase(valS, DataDictionaryPDF.getFont(9, Font.NORMAL))); pdfTable.addCell(c1); } } return pdfTable; }