PdfPTable table = new PdfPTable(2); PdfPCell cellOne = new PdfPCell(new Phrase("Hello")); PdfPCell cellTwo = new PdfPCell(new Phrase("World")); cellOne.setBorder(Rectangle.NO_BORDER); cellOne.setBackgroundColor(new Color(255,255,45)); cellTwo.setBorder(Rectangle.BOX); table.addCell(cellOne); table.addCell(cellTwo);
protected void addColumnValue(PdfPTable pdfTable, String value) { PdfPCell cell = new PdfPCell(new Paragraph(value, facetFont)); if (facetBgColor != null) { cell.setBackgroundColor(facetBgColor); } pdfTable.addCell(cell); }
cell.setBackgroundColor(facetBgColor);
boolean b = true; for(PdfPRow r: table.getRows()) { for(PdfPCell c: r.getCells()) { c.setBackgroundColor(b ? BaseColor.GREY : BaseColor.WHITE); } b = !b; }
public void setBackgroundColor( Color backgroundColor ) { getWrapperCell().setBackgroundColor( backgroundColor ); }
public void setBackgroundColor( Color backgroundColor ) { getWrapperCell().setBackgroundColor( backgroundColor ); }
public void addPdfTableCells(final PdfPTable pdfTable, final List<Map<String, String>> rows, final List<String> columns, final String viewName) { if (L_ORDERS_PLANNING_LIST.equals(viewName) || L_ORDERS_LIST.equals(viewName)) { rows.forEach(row -> { columns.forEach(column -> { String value = row.get(column); pdfTable.getDefaultCell().setBackgroundColor(getBackgroundColor(value, column)); pdfTable.addCell(new Phrase(value, FontUtils.getDejavuRegular7Dark())); }); }); } }
public PdfPCell createCell(int i, int j, int c) { PdfPCell cell = new PdfPCell(); cell.addElement(new Paragraph(String.format("row %s; column %s", i, j))); if (j == c) { cell.setBackgroundColor(BaseColor.LIGHT_GRAY); } return cell; }
PdfPTable table = new PdfPTable(1); table.setTotalWidth(523); PdfPCell cell = new PdfPCell(new Phrase("This is a test document")); cell.setBackgroundColor(BaseColor.ORANGE); table.addCell(cell); cell = new PdfPCell(new Phrase("This is a copyright notice")); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cell);
private static PdfPCell CreateCell(String text, BaseColor backgroundColor) { PdfPCell c = new PdfPCell(new Phrase(text)); c.setBackgroundColor( backgroundColor ); c.setPadding( 20 ); c.setBorder( 0 ); return c; }
PdfPCell cell = new PdfPCell(new Phrase(value, fontValueNew)); cell.setBorder(o); cell.setBackgroundColor(new Color(233,232,232)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_CENTER);
private void formatterCell(HtmlFormatter fmt, PdfPCell cell) { if(nvl(fmt.getBgColor()).trim().length()>0) cell.setBackgroundColor(Color.decode(fmt.getBgColor())); if(nvl(fmt.getAlignment()).trim().length()>0) cell.setHorizontalAlignment(ElementTags.alignmentValue(fmt.getAlignment())); }
protected void addColumnValue(PdfPTable pdfTable, UIComponent component, Font font) { String value = component == null ? "" : exportValue(FacesContext.getCurrentInstance(), component); PdfPCell cell = new PdfPCell(new Paragraph(value, font)); if (this.facetBgColor != null) { cell.setBackgroundColor(this.facetBgColor); } pdfTable.addCell(cell); }
private void setBodyCell(String text, int ridx, int cidx) { PdfPCell bodyCell = table.getRow(ridx).getCells()[cidx]; bodyCell.setBackgroundColor(Color.LIGHT_GRAY); if (text != null) { bodyCell.setPhrase(tableBSelector.process(text)); } }
protected void addColumnValue(final PdfPTable pdfTable, final UIComponent component, final Font font, final String columnType) { final String value = component == null ? Constants.EMPTY_STRING : exportValue(FacesContext.getCurrentInstance(), component); PdfPCell cell = new PdfPCell(new Paragraph(value, font)); if (facetBackground != null) { cell.setBackgroundColor(facetBackground); } if (columnType.equalsIgnoreCase("header")) { cell = addFacetAlignments(component, cell); } else { cell = addColumnAlignments(component, cell); } pdfTable.addCell(cell); }
public void print(Entity operationComponent, Document document, Locale locale) throws DocumentException { String commentContent = operationComponent.getStringField(TechnologyOperationComponentFields.COMMENT); if (commentContent == null) { return; } PdfPTable table = pdfHelper.createPanelTable(1); table.getDefaultCell().setBackgroundColor(null); String commentLabel = translationService.translate("workPlans.workPlan.report.operation.comment", locale); pdfHelper.addTableCellAsOneColumnTable(table, commentLabel, commentContent); table.setSpacingAfter(18); table.setSpacingBefore(9); document.add(table); }
private void setHeaderCell(String text, int ridx, int cidx) { PdfPCell headerCell = table.getRow(ridx++).getCells()[cidx]; if (hType.equals(TBDirection.Horizontal)) { headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); } else if (hType.equals(TBDirection.Vertical)) { headerCell.setHorizontalAlignment(Element.ALIGN_RIGHT); } headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE); headerCell.setBackgroundColor(Color.GRAY); headerCell.setPhrase(tableHSelector.process(text)); }
@Override protected IITextContainer startVisitPargraph( XWPFParagraph docxParagraph, IITextContainer parentContainer ) throws Exception { // 1) Instanciate a pdfParagraph StylableParagraph pdfParagraph = pdfDocument.createParagraph( (IStylableContainer) null ); // apply style for the title font, color, bold style... // 2) Create style instance of the paragraph if needed styleEngine.startVisitPargraph( docxParagraph, pdfParagraph ); pdfParagraph.setITextContainer( parentContainer ); // TODO String backgroundColor = XWPFParagraphUtils.getBackgroundColor( docxParagraph ); if ( StringUtils.isNotEmpty( backgroundColor ) ) { pdfParagraph.getPdfPCell().setBackgroundColor( ColorRegistry.getInstance().getColor( "0x" + backgroundColor ) ); } // finally apply the style to the iText paragraph.... applyStyles( docxParagraph, pdfParagraph ); return pdfParagraph; }
PdfPTable tablesup= new PdfPTable(4); PdfPCell cell = new PdfPCell(new Paragraph("Supplier Information")); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.CYAN); tablesup.addCell(cell); tablesup.addCell("Supplier ID"); tablesup.addCell("Supplier Name"); tablesup.addCell("Address"); tablesup.addCell("Contact Info"); while(rs.next()){ String v1 = rs.getString("SupplierID"); String v2 = rs.getString("SupplierName"); String v3 = rs.getString("Address"); String v4 = rs.getString("ContactInfo"); tablesup.addCell(v1); tablesup.addCell(v2); tablesup.addCell(v3); tablesup.addCell(v4); } pdfsup.add(tablesup); pdfsup.close(); JOptionPane.showMessageDialog(null, "Report Saved...");
private void addRowHeader(PdfPTable table, DataRow dr, int idx, ReportData rd) { table.getDefaultCell().setHorizontalAlignment(Rectangle.ALIGN_CENTER); for(rd.reportRowHeaderCols.resetNext();rd.reportRowHeaderCols.hasNext();) { RowHeaderCol rhc = rd.reportRowHeaderCols.getNext(); if(idx==0) rhc.resetNext(); RowHeader rh = rhc.getNext(); //System.out.println(" =============== RowHeader\n "+rh); Font rowHeaderFont = FontFactory.getFont(FONT_FAMILY, FONT_SIZE, Font.NORMAL, Color.BLACK); if(rh.isBold()) { rowHeaderFont.setStyle(Font.BOLD); rowHeaderFont.setSize(FONT_SIZE+1f); } if(rh.getColSpan()>0) { table.getDefaultCell().setColspan(rh.getColSpan()); table.getDefaultCell().setBackgroundColor(getRowBackgroundColor(dr, idx)); table.addCell(new Paragraph(strip.stripHtml(rh.getRowTitle()),rowHeaderFont)); } } }