Tabnine Logo
Chunk
Code IndexAdd Tabnine to your IDE (free)

How to use
Chunk
in
com.itextpdf.text

Best Java code snippets using com.itextpdf.text.Chunk (Showing top 20 results out of 315)

origin: com.itextpdf/itextpdf

/**
 * 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);
}
origin: com.itextpdf/itextg

/**
 * 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);
}
origin: org.technbolts/gutenberg

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;
}
origin: com.itextpdf/itextpdf

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;
}
origin: com.itextpdf/itextg

/**
 * 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;
}
origin: com.itextpdf/itextpdf

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);
origin: com.itextpdf/itextpdf

/**
 * 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;
}
origin: com.itextpdf/itextpdf

/**
 * Sets the listsymbol.
 *
 * @param    symbol    a <CODE>Chunk</CODE>
 */
public void setListSymbol(final Chunk symbol) {
  if (this.symbol == null) {
    this.symbol = symbol;
    if (this.symbol.getFont().isStandardFont()) {
      this.symbol.setFont(font);
    }
  }
}
origin: com.itextpdf/itextpdf

/**
 * 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;
}
origin: org.technbolts.tzatziki/tzatziki-pdf

  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);
origin: dariober/ASCIIGenome

    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);
origin: com.itextpdf/itextpdf

/**
 * 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;
}
origin: com.itextpdf/itextpdf

Chunk chunk = (Chunk) element;
if (!font.isStandardFont()) {
  chunk.setFont(font.difference(chunk.getFont()));
if (hyphenation != null && chunk.getHyphenation() == null && !chunk.isEmpty()) {
  chunk.setHyphenation(hyphenation);
origin: com.itextpdf/itextpdf

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());
origin: org.technbolts/gutenberg

@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);
  }
}
origin: com.itextpdf/itextpdf

/**
 * 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();
}
origin: com.itextpdf/itextpdf

/**
 * Returns the content of this <CODE>Chunk</CODE>.
 *
 * @return a <CODE>String</CODE>
 */
@Override
public String toString() {
  return getContent();
}
origin: com.itextpdf/itextpdf

/**
 * 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());
}
origin: com.itextpdf/itextg

/**
 * 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);
}
origin: com.itextpdf/itextpdf

while (i.hasNext()) {
  chunk = i.next();
  if (name != null && notGotoOK && !chunk.isEmpty()) {
    chunk.setLocalDestination(name);
    notGotoOK = false;
    chunk.setLocalGoto(reference.substring(1));
com.itextpdf.textChunk

Javadoc

This is the smallest significant part of text that can be added to a document.

Most elements can be divided in one or more Chunks. A chunk is a String with a certain Font. All other layout parameters should be defined in the object to which this chunk of text is added.

Example:

 
Chunk chunk = new Chunk("Hello world", 
FontFactory.getFont(FontFactory.COURIER, 20, Font.ITALIC, new BaseColor(255, 0, 
0)));  document.add(chunk); 

Most used methods

  • <init>
    Constructs a chunk of text with a certain content and a certain Font.
  • setBackground
    Sets the color and the size of the background Chunk.
  • getContent
    Returns the content of this Chunk.
  • getWidthPoint
    Gets the width of the Chunk in points.
  • setGenericTag
    Sets the generic tag Chunk. The text for this tag can be retrieved with PdfPageEvent.
  • getFont
    Gets the font of this Chunk.
  • setFont
    Sets the font of this Chunk.
  • setLocalDestination
    Sets a local destination for this Chunk.
  • setTextRise
    Sets the text displacement relative to the baseline. Positive values rise the text, negative values
  • append
    appends some text to this Chunk.
  • createTabspace
  • createWhitespace
  • createTabspace,
  • createWhitespace,
  • getAccessibleAttribute,
  • getAccessibleAttributes,
  • getAttributes,
  • getHorizontalScaling,
  • getHyphenation,
  • getId,
  • getImage,
  • getRole

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now