com.lowagie.text.TextElementArray Java Examples

The following examples show how to use com.lowagie.text.TextElementArray. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventsTest.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * We only alter the handling of some endtags.
 * 
 * @param uri
 *            the uri of the namespace
 * @param lname
 *            the local name of the tag
 * @param name
 *            the name of the tag
 */
public void endElement(String uri, String lname, String name) {
	if (myTags.containsKey(name)) {
		XmlPeer peer = (XmlPeer) myTags.get(name);
		// we don't want the document to be close
		// because we are going to add a page after the xml is parsed
		if (isDocumentRoot(peer.getTag())) {
			return;
		}
		handleEndingTags(peer.getTag());
		// we want to add a paragraph after the speaker chunk
		if ("SPEAKER".equals(name)) {
			try {
				TextElementArray previous = (TextElementArray) stack
						.pop();
				previous.add(new Paragraph(16));
				stack.push(previous);
			} catch (EmptyStackException ese) {
			}
		}
	} else {
		handleEndingTags(name);
	}
}
 
Example #2
Source File: SAXiTextHandler.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
protected void addImage(Image img) throws EmptyStackException {
	// if there is an element on the stack...
	Object current = stack.pop();
	// ...and it's a Chapter or a Section, the Image can be
	// added directly
	if (current instanceof Chapter || current instanceof Section || current instanceof Cell) {
		((TextElementArray) current).add(img);
		stack.push(current);
		return;
	}
	// ...if not, we need to to a lot of stuff
	else {
		Stack newStack = new Stack();
		while (!(current instanceof Chapter || current instanceof Section || current instanceof Cell)) {
			newStack.push(current);
			if (current instanceof Anchor) {
				img.setAnnotation(new Annotation(0, 0, 0, 0, ((Anchor) current).getReference()));
			}
			current = stack.pop();
		}
		((TextElementArray) current).add(img);
		stack.push(current);
		while (!newStack.empty()) {
			stack.push(newStack.pop());
		}
		return;
	}
}
 
Example #3
Source File: SAXiTextHandler.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void addImage(Image img) throws EmptyStackException {
    // if there is an element on the stack...
    Object current = stack.pop();
    // ...and it's a Chapter or a Section, the Image can be
    // added directly
    if (current instanceof Chapter
            || current instanceof Section
            || current instanceof Cell) {
        ((TextElementArray) current).add(img);
        stack.push(current);
        return;
    }
    // ...if not, we need to to a lot of stuff
    else {
        Stack newStack = new Stack();
        while (!(current instanceof Chapter
                || current instanceof Section || current instanceof Cell)) {
            newStack.push(current);
            if (current instanceof Anchor) {
                img.setAnnotation(new Annotation(0, 0, 0,
                        0, ((Anchor) current).getReference()));
            }
            current = stack.pop();
        }
        ((TextElementArray) current).add(img);
        stack.push(current);
        while (!newStack.empty()) {
            stack.push(newStack.pop());
        }
        return;
    }
}
 
Example #4
Source File: RTFTextExtractor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected StyleContext( final TextElementArray target, final StyleSheet styleSheet,
    final RTFOutputProcessorMetaData metaData ) {
  this.target = target;
  this.metaData = metaData;
  this.fontName = (String) styleSheet.getStyleProperty( TextStyleKeys.FONT );
  this.fontSize = styleSheet.getDoubleStyleProperty( TextStyleKeys.FONTSIZE, 0 );
  this.bold = styleSheet.getBooleanStyleProperty( TextStyleKeys.BOLD );
  this.italic = styleSheet.getBooleanStyleProperty( TextStyleKeys.ITALIC );
  this.underline = styleSheet.getBooleanStyleProperty( TextStyleKeys.UNDERLINED );
  this.strikethrough = styleSheet.getBooleanStyleProperty( TextStyleKeys.STRIKETHROUGH );
  this.textColor = (Color) styleSheet.getStyleProperty( ElementStyleKeys.PAINT );
  this.backgroundColor = (Color) styleSheet.getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR );
}
 
Example #5
Source File: RTFTextExtractor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TextElementArray getTarget() {
  return target;
}
 
Example #6
Source File: RTFTextExtractor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void compute( final RenderBox box, final TextElementArray cell, final RTFImageCache imageCache ) {
  this.context.clear();
  this.context.push( new StyleContext( cell, box.getStyleSheet(), metaData ) );
  this.imageCache = imageCache;
  super.compute( box );
}