/** * Sets the listsymbol. * <P> * This is a shortcut for <CODE>setListSymbol(Chunk symbol)</CODE>. * * @param symbol a <CODE>String</CODE> */ public void setListSymbol(final String symbol) { this.symbol = new Chunk(symbol); }
/** * 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); }
private static Element discardNewline(Element sub) { if (sub instanceof Chunk) { Chunk c = (Chunk) sub; String content = c.getContent(); if (content.endsWith("\n") && content.length() < 2) { return new Chunk(" "); } } return sub; }
public static Chunk createWhitespace(final String content, final boolean preserve) { Chunk whitespace = null; if (!preserve) { whitespace = new Chunk(' '); whitespace.setAttribute(WHITESPACE, content); } else { whitespace = new Chunk(content); } return whitespace; }
/** * Applies the properties of the Anchor to a Chunk. * @param chunk the Chunk (part of the Anchor) * @param notGotoOK if true, this chunk will determine the local destination * @param localDestination true if the chunk is a local goto and the reference a local destination * @return the value of notGotoOK or false, if a previous Chunk was used to determine the local destination */ protected boolean applyAnchor(Chunk chunk, boolean notGotoOK, boolean localDestination) { if (name != null && notGotoOK && !chunk.isEmpty()) { chunk.setLocalDestination(name); notGotoOK = false; } if (localDestination) { chunk.setLocalGoto(reference.substring(1)); } else if (reference != null) chunk.setAnchor(reference); return notGotoOK; }
Font f = chunk.getFont(); String c = chunk.getContent(); if (font != null && !font.isStandardFont()) { f = font.difference(chunk.getFont()); if (size() > 0 && !chunk.hasAttributes()) { try { Chunk previous = (Chunk) get(size() - 1); PdfName previousRole = previous.getRole(); PdfName chunkRole = chunk.getRole(); boolean sameRole; if(previousRole == null || chunkRole == null) else sameRole = previousRole.equals(chunkRole); if (sameRole && !previous.hasAttributes() && !chunk.hasAccessibleAttributes() && !previous.hasAccessibleAttributes() && (f == null || f.compareTo(previous.getFont()) == 0) && !"".equals(previous.getContent().trim()) && !"".equals(c.trim())) { previous.append(c); return true; Chunk newChunk = new Chunk(c, f); newChunk.setAttributes(chunk.getAttributes()); newChunk.role = chunk.getRole(); newChunk.accessibleAttributes = chunk.getAccessibleAttributes(); if (hyphenation != null && newChunk.getHyphenation() == null && !newChunk.isEmpty()) { newChunk.setHyphenation(hyphenation);
/** * Adds an <CODE>Element</CODE> to the <CODE>List</CODE>. * * @param o the object to add. * @return true if adding the object succeeded */ @Override public boolean add(Element o) { if (o instanceof ListItem) { ListItem item = (ListItem) o; Chunk chunk = new Chunk(preSymbol, symbol.getFont()); chunk.setAttributes(symbol.getAttributes()); chunk.append(String.valueOf((char)zn)); chunk.append(postSymbol); item.setListSymbol(chunk); item.setIndentationLeft(symbolIndent, autoindent); item.setIndentationRight(0); list.add(item); } else if (o instanceof List) { List nested = (List) o; nested.setIndentationLeft(nested.getIndentationLeft() + symbolIndent); first--; return list.add(nested); } return false; }
/** * Create an index entry. * * @param text The text for the Chunk. * @param in1 The first level. * @param in2 The second level. * @param in3 The third level. * @return Returns the Chunk. */ public Chunk create(final String text, final String in1, final String in2, final String in3) { Chunk chunk = new Chunk(text); String tag = "idx_" + indexcounter++; chunk.setGenericTag(tag); chunk.setLocalDestination(tag); Entry entry = new Entry(in1, in2, in3, tag); indexentry.add(entry); return chunk; }
p.add(Chunk.NEWLINE); Chunk keywordChunk = new Chunk(kwPattern.getKeyword(), keywordFont); Chunk regexChunk = new Chunk(kwPattern.getPattern(), regexFont); regexChunk.setBackground(regexBg); p.add(new Chunk(" ")); p.add(regexChunk);
Chunk chunk= new Chunk(c, new Font(Font.FontFamily.COURIER, fontSize, Font.NORMAL, fgBaseCol)); chunk.setBackground(bgBaseCol); pdfLine.add(chunk); Chunk chunk= new Chunk("X", f); this.setMaxWidth((int) ((currentMax) * chunk.getWidthPoint())); for(Paragraph p : paraList){ p.setSpacingBefore(-3);
/** * Creates an iText Chunk * @param content the content of the Chunk * @param chain the hierarchy chain * @return a Chunk */ public Chunk createChunk(final String content, final ChainedProperties chain) { Font font = getFont(chain); Chunk ck = new Chunk(content, font); if (chain.hasProperty(HtmlTags.SUB)) ck.setTextRise(-font.getSize() / 2); else if (chain.hasProperty(HtmlTags.SUP)) ck.setTextRise(font.getSize() / 2); ck.setHyphenation(getHyphenation(chain)); return ck; }
Chunk chunk = (Chunk) element; if (!font.isStandardFont()) { chunk.setFont(font.difference(chunk.getFont())); if (hyphenation != null && chunk.getHyphenation() == null && !chunk.isEmpty()) { chunk.setHyphenation(hyphenation);
value = chunk.getContent(); Font f = chunk.getFont(); float size = f.getSize(); if (size == Font.UNDEFINED) HashMap<String, Object> attr = chunk.getAttributes(); if (attr != null) { for (Map.Entry<String, Object>entry: attr.entrySet()) { attributes.put(Chunk.GENERICTAG, chunk.getContent());
@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); } }
/** * Gets the width of the Chunk in points. * * @return a width in points */ public float getWidthPoint() { if (getImage() != null) { return getImage().getScaledWidth(); } return font.getCalculatedBaseFont(true).getWidthPoint(getContent(), font.getCalculatedSize()) * getHorizontalScaling(); }
/** * Returns the content of this <CODE>Chunk</CODE>. * * @return a <CODE>String</CODE> */ @Override public String toString() { return getContent(); }
/** * Constructs a <CODE>Phrase</CODE> with a certain <CODE>Chunk</CODE>. * * @param chunk a <CODE>Chunk</CODE> */ public Phrase(final Chunk chunk) { super.add(chunk); font = chunk.getFont(); setHyphenation(chunk.getHyphenation()); }
/** * Create an index entry. * * @param text The text. * @param in1 The first level. * @param in2 The second level. * @param in3 The third level. */ public void create(final Chunk text, final String in1, final String in2, final String in3) { String tag = "idx_" + indexcounter++; text.setGenericTag(tag); text.setLocalDestination(tag); Entry entry = new Entry(in1, in2, in3, tag); indexentry.add(entry); }
while (i.hasNext()) { chunk = i.next(); if (name != null && notGotoOK && !chunk.isEmpty()) { chunk.setLocalDestination(name); notGotoOK = false; chunk.setLocalGoto(reference.substring(1));