concept List in category itext

appears as: List, The List, List
iText in Action, Second Edition

This is an excerpt from Manning's book iText in Action, Second Edition.

There are different ways to add content. Up until now, you’ve been adding one or more high-level objects of type Paragraph to the Document. In the next chapter, you’ll learn about other objects, such as Chunk, Phrase, Anchor, and List. You can also add content to a page using low-level methods.

We’ll discuss a first series of objects in section 2.2: Chunk, Phrase, Paragraph, and List. In section 2.3, we’ll cover a second series: Anchor, Chapter, Section, and Image. But before starting to build documents using these building blocks, let’s have a look at the database you’ll publish to different PDF files in the upcoming examples.

To achieve this, you’ll use the List object and a number of ListItem objects. As you can see in the UML diagram (figure 2.1), ListItem extends Paragraph. The main difference is that every ListItem has an extra Chunk variable that acts as a list symbol.

Figure 2.7. List and ListItem variations
Listing 15.17. StructureParser.java
public class StructureParser extends DefaultHandler { protected PdfStructureElement top; protected List elements; public StructureParser( PdfStructureElement top, List<PdfStructureElement> elements) { this.top = top; this.elements = elements; } public void startElement( String uri, String localName, String qName, Attributes attributes) throws SAXException { if ("chapter".equals(qName)) return; elements.add(new PdfStructureElement(top, new PdfName(qName))); } }