/** * Sets the color of the background <CODE>Chunk</CODE>. * * @param color * the color of the background * @return this <CODE>Chunk</CODE> */ public Chunk setBackground(final BaseColor color) { return setBackground(color, 0, 0, 0, 0); }
/** * Sets the color of the background <CODE>Chunk</CODE>. * * @param color * the color of the background * @return this <CODE>Chunk</CODE> */ public Chunk setBackground(final BaseColor color) { return setBackground(color, 0, 0, 0, 0); }
Font font = new Font(FontFamily.HELVETICA, 6, Font.BOLD, BaseColor.WHITE); Chunk id = new Chunk("Text", font); // with a background color id.setBackground(BaseColor.BLACK, 1f, 0.5f, 1f, 1.5f);
Font f = new Font(FontFamily.TIMES_ROMAN, 25.0f, Font.BOLD, BaseColor.WHITE); Chunk c = new Chunk("Total Cost:" + dbsumcallcost, f); c.setBackground(BaseColor.RED); Paragraph p = new Paragraph(c); document.add(p);
Font f3 = new Font(Font.FontFamily.TIMES_ROMAN, 18.0f, Font.BOLD, BaseColor.BLACK); Chunk c3 = new Chunk("INVOICE", f3); c3.setBackground(BaseColor.WHITE); Paragraph p3 = new Paragraph(c3); p3.setAlignment(Element.ALIGN_CENTER);
Chunk textAsChunk = new Chunk(text, textFont); textAsChunk.setBackground(new BaseColor(120, 200, 50)); ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, new Phrase(textAsChunk), x, y, 0);
@Override public void process(int level, Node node, InvocationContext context) { CodeNode cNode = (CodeNode) node; Font font = styles.getFont(Styles.INLINE_CODE_FONT).or(inlineCodeFont(styles)); List<Element> elements = context.iTextContext().emitButCollectElements(new RichText(cNode.getText(), font)); for (Element element : elements) { if (element instanceof Chunk) { Chunk chunk = (Chunk) element; chunk.setBackground(styles.getColor(Styles.INLINE_CODE_BACKGROUND).or(BaseColor.GRAY)); chunk.setGenericTag("code"); } context.append(element); } }
nChars += 1; Chunk chunk= new Chunk(c, new Font(Font.FontFamily.COURIER, fontSize, Font.NORMAL, fgBaseCol)); chunk.setBackground(bgBaseCol); pdfLine.add(chunk);
regexChunk.setBackground(regexBg);
public List<Element> process(SourceCode sourceCode) { String lang = sourceCode.lang(); String content = sourceCode.content(); boolean linenos = sourceCode.showLineNumbers(); Tokens tokens = pygments.tokenize(lang, content); Paragraph p = new Paragraph(); for (TokenWithValue token : tokens) { Style style = styleSheet.styleOf(token.token); BaseColor color = toColor(style.fg()); int s = calculateStyle(style); Font font = styles.getFont(Styles.CODE_FONT, s, color).get(); Chunk o = new Chunk(token.value, font); RGB bg = style.bg(); if (bg != null) o.setBackground(toColor(bg)); p.add(o); } PdfPCell cell = new PdfPCell(p); cell.setPaddingBottom(5.0f); cell.setBorder(Rectangle.NO_BORDER); PdfPTable table = new PdfPTable(1); table.addCell(cell); table.setSpacingBefore(5.0f); table.setSpacingAfter(5.0f); table.setTableEvent(new TableBackground(toColor(styleSheet.backgroundColor()))); return Arrays.<Element>asList(table); }