com.lowagie.text.ListItem Java Examples

The following examples show how to use com.lowagie.text.ListItem. 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: PdfCell.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void addList(List list, float left, float right, int alignment) {
	PdfChunk chunk;
	PdfChunk overflow;
	ArrayList allActions = new ArrayList();
	processActions(list, null, allActions);
	int aCounter = 0;
	for (Iterator it = list.getItems().iterator(); it.hasNext();) {
		Element ele = (Element) it.next();
		switch (ele.type()) {
			case Element.LISTITEM:
				ListItem item = (ListItem) ele;
				line = new PdfLine(left + item.getIndentationLeft(), right, alignment, item.getLeading());
				line.setListItem(item);
				for (Iterator j = item.getChunks().iterator(); j.hasNext();) {
					chunk = new PdfChunk((Chunk) j.next(), (PdfAction) allActions.get(aCounter++));
					while ((overflow = line.add(chunk)) != null) {
						addLine(line);
						line = new PdfLine(left + item.getIndentationLeft(), right, alignment, item.getLeading());
						chunk = overflow;
					}
					line.resetAlignment();
					addLine(line);
					line = new PdfLine(left + item.getIndentationLeft(), right, alignment, leading);
				}
				break;
			case Element.LIST:
				List sublist = (List) ele;
				addList(sublist, left + sublist.getIndentationLeft(), right, alignment);
				break;
		}
	}
}
 
Example #2
Source File: PdfCell.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addList(List list, float left, float right, int alignment) {
    PdfChunk chunk;
    PdfChunk overflow;
    ArrayList allActions = new ArrayList();
    processActions(list, null, allActions);
    int aCounter = 0;
    for (Iterator it = list.getItems().iterator(); it.hasNext();) {
        Element ele = (Element)it.next();
        switch (ele.type()) {
            case Element.LISTITEM:
                ListItem item = (ListItem)ele;
                line = new PdfLine(left + item.getIndentationLeft(), right, alignment, item.getLeading());
                line.setListItem(item);
                for (Iterator j = item.getChunks().iterator(); j.hasNext();) {
                    chunk = new PdfChunk((Chunk) j.next(), (PdfAction) (allActions.get(aCounter++)));
                    while ((overflow = line.add(chunk)) != null) {
                        addLine(line);
                        line = new PdfLine(left + item.getIndentationLeft(), right, alignment, item.getLeading());
                        chunk = overflow;
                    }
                    line.resetAlignment();
                    addLine(line);
                    line = new PdfLine(left + item.getIndentationLeft(), right, alignment, leading);
                }
                break;
            case Element.LIST:
                List sublist = (List)ele;
                addList(sublist, left + sublist.getIndentationLeft(), right, alignment);
                break;
        }
    }
}
 
Example #3
Source File: FactoryProperties.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
public static ListItem createListItem(ChainedProperties props) {
	ListItem p = new ListItem();
	createParagraph(p, props);
	return p;
}
 
Example #4
Source File: FactoryProperties.java    From itext2 with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static ListItem createListItem(ChainedProperties props) {
	ListItem p = new ListItem();
	createParagraph(p, props);
	return p;
}
 
Example #5
Source File: FancyListsTest.java    From itext2 with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Demonstrates some List functionality.
 * 
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document();
	// step 2:
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("fancylists.pdf"));

	// step 3: we open the document
	document.open();

	// step 4:

	// RomanList
	RomanList roman = new RomanList(35);
	roman.setLowercase(true);
	roman.add(new ListItem("first item"));
	roman.add(new ListItem(
			"second item blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah"));
	for (int i = 3; i < 151; i++) {
		roman.add(i + "th item");
	}
	document.add(roman);
	document.newPage();
	RomanList roman2 = new RomanList(35);
	roman2.add(new ListItem("first item"));
	roman2.add(new ListItem("second item"));
	for (int i = 3; i < 11; i++) {
		roman2.add(i + "th item");
	}
	document.add(roman2);
	document.newPage();

	// GreekList
	GreekList greek = new GreekList(15);
	greek.setLowercase(true);
	greek.add(new ListItem("first item"));
	greek.add(new ListItem("second item"));
	for (int i = 3; i < 20; i++) {
		greek.add(i + "th item");
	}
	document.add(greek);
	document.newPage();

	// GreekList
	GreekList greek2 = new GreekList(15);
	greek2.setLowercase(false);
	greek2.add(new ListItem("first item"));
	greek2.add(new ListItem("second item"));
	for (int i = 3; i < 20; i++) {
		greek2.add(i + "th item");
	}
	document.add(greek2);

	// ZapfDingbatsList
	ZapfDingbatsList z = new ZapfDingbatsList(42, 15);
	z.add(new ListItem("first item"));
	z.add(new ListItem("second item"));
	for (int i = 3; i < 20; i++) {
		z.add(i + "th item");
	}
	document.add(z);
	document.newPage();

	// ZapfDingbatsNumberList
	ZapfDingbatsNumberList z0 = new ZapfDingbatsNumberList(0, 15);
	z0.add(new ListItem("first item"));
	z0.add(new ListItem("second item"));
	for (int i = 3; i < 11; i++) {
		z0.add(i + "th item");
	}
	document.add(z0);
	ZapfDingbatsNumberList z1 = new ZapfDingbatsNumberList(1, 15);
	z1.add(new ListItem("first item"));
	z1.add(new ListItem("second item"));
	for (int i = 3; i < 11; i++) {
		z1.add(i + "th item");
	}
	document.add(z1);
	ZapfDingbatsNumberList z2 = new ZapfDingbatsNumberList(2, 15);
	z2.add(new ListItem("first item"));
	z2.add(new ListItem("second item"));
	for (int i = 3; i < 11; i++) {
		z2.add(i + "th item");
	}
	document.add(z2);
	ZapfDingbatsNumberList z3 = new ZapfDingbatsNumberList(3, 15);
	z3.add(new ListItem("first item"));
	z3.add(new ListItem("second item"));
	for (int i = 3; i < 11; i++) {
		z3.add(i + "th item");
	}
	document.add(z3);

	// step 5: we close the document
	document.close();
}
 
Example #6
Source File: PatchRtfDocument.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public RtfBasicElement[] mapElement( Element element ) throws DocumentException {
  ArrayList<RtfBasicElement> rtfElements = new ArrayList<RtfBasicElement>();
  if ( element instanceof RtfBasicElement ) {
    RtfBasicElement rtfElement = (RtfBasicElement) element;
    rtfElement.setRtfDocument( rtfDoc );
    return new RtfBasicElement[] { rtfElement };
  }
  switch ( element.type() ) {
    case Element.CHUNK:
      Chunk chunk = (Chunk) element;
      if ( chunk.hasAttributes() ) {
        if ( chunk.getAttributes().containsKey( Chunk.IMAGE ) ) {
          rtfElements.add( new RtfImage( rtfDoc, chunk.getImage() ) );
        } else if ( chunk.getAttributes().containsKey( Chunk.NEWPAGE ) ) {
          rtfElements.add( new RtfNewPage( rtfDoc ) );
        } else if ( chunk.getAttributes().containsKey( Chunk.TAB ) ) {
          Float tabPos = (Float) ( (Object[]) chunk.getAttributes().get( Chunk.TAB ) )[1];
          RtfTab tab = new RtfTab( tabPos.floatValue(), RtfTab.TAB_LEFT_ALIGN );
          tab.setRtfDocument( rtfDoc );
          rtfElements.add( tab );
          rtfElements.add( new RtfChunk( rtfDoc, new Chunk( "\t" ) ) );
        } else {
          rtfElements.add( new RtfChunk( rtfDoc, (Chunk) element ) );
        }
      } else {
        rtfElements.add( new RtfChunk( rtfDoc, (Chunk) element ) );
      }
      break;
    case Element.PHRASE:
      rtfElements.add( new RtfPhrase( rtfDoc, (Phrase) element ) );
      break;
    case Element.PARAGRAPH:
      rtfElements.add( new RtfParagraph( rtfDoc, (Paragraph) element ) );
      break;
    case Element.ANCHOR:
      rtfElements.add( new RtfAnchor( rtfDoc, (Anchor) element ) );
      break;
    case Element.ANNOTATION:
      rtfElements.add( new RtfAnnotation( rtfDoc, (Annotation) element ) );
      break;
    case Element.IMGRAW:
    case Element.IMGTEMPLATE:
    case Element.JPEG:
      rtfElements.add( new RtfImage( rtfDoc, (Image) element ) );
      break;
    case Element.AUTHOR:
    case Element.SUBJECT:
    case Element.KEYWORDS:
    case Element.TITLE:
    case Element.PRODUCER:
    case Element.CREATIONDATE:
      rtfElements.add( new RtfInfoElement( rtfDoc, (Meta) element ) );
      break;
    case Element.LIST:
      rtfElements.add( new RtfList( rtfDoc, (List) element ) ); // TODO: Testing
      break;
    case Element.LISTITEM:
      rtfElements.add( new RtfListItem( rtfDoc, (ListItem) element ) ); // TODO: Testing
      break;
    case Element.SECTION:
      rtfElements.add( new RtfSection( rtfDoc, (Section) element ) );
      break;
    case Element.CHAPTER:
      rtfElements.add( new RtfChapter( rtfDoc, (Chapter) element ) );
      break;
    case Element.TABLE:
      if ( element instanceof Table ) {
        rtfElements.add( new PatchRtfTable( rtfDoc, (Table) element ) );
      } else {
        rtfElements.add( new PatchRtfTable( rtfDoc, ( (SimpleTable) element ).createTable() ) );
      }
      break;
    case Element.PTABLE:
      if ( element instanceof PdfPTable ) {
        rtfElements.add( new PatchRtfTable( rtfDoc, (PdfPTable) element ) );
      } else {
        rtfElements.add( new PatchRtfTable( rtfDoc, ( (SimpleTable) element ).createTable() ) );
      }
      break;
  }

  return rtfElements.toArray( new RtfBasicElement[rtfElements.size()] );
}
 
Example #7
Source File: PdfLine.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Sets the listsymbol of this line.
 * <P>
 * This is only necessary for the first line of a <CODE>ListItem</CODE>.
 *
 * @param listItem the list symbol
 */

public void setListItem(ListItem listItem) {
	listSymbol = listItem.getListSymbol();
	symbolIndent = listItem.getIndentationLeft();
}
 
Example #8
Source File: ElementFactory.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Creates a ListItem object based on a list of properties.
 * 
 * @param attributes
 * @return a ListItem
 */
public static ListItem getListItem(Properties attributes) {
	ListItem item = new ListItem(getParagraph(attributes));
	return item;
}
 
Example #9
Source File: PdfLine.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Sets the listsymbol of this line.
 * <P>
 * This is only necessary for the first line of a <CODE>ListItem</CODE>.
 *
 * @param listItem the list symbol
 */

public void setListItem(ListItem listItem) {
    this.listSymbol = listItem.getListSymbol();
    this.symbolIndent = listItem.getIndentationLeft();
}
 
Example #10
Source File: RtfListItem.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Constructs a RtfListItem for a ListItem belonging to a RtfDocument.
 * 
 * @param doc The RtfDocument this RtfListItem belongs to.
 * @param listItem The ListItem this RtfListItem is based on.
 */
public RtfListItem(RtfDocument doc, ListItem listItem) {
    super(doc, listItem);
}
 
Example #11
Source File: ElementFactory.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Creates a ListItem object based on a list of properties.
 * @param attributes
 * @return a ListItem
 */
public static ListItem getListItem(Properties attributes) {
	ListItem item = new ListItem(getParagraph(attributes));
	return item;
}
 
Example #12
Source File: PdfLine.java    From MesquiteCore with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Sets the listsymbol of this line.
 * <P>
 * This is only necessary for the first line of a <CODE>ListItem</CODE>.
 *
 * @param listItem the list symbol
 */

public void setListItem(ListItem listItem) {
    this.listSymbol = new PdfChunk(listItem.listSymbol(), null);
    this.symbolIndent = listItem.indentationLeft();
}