Example usage for com.itextpdf.text List getFirstItem

List of usage examples for com.itextpdf.text List getFirstItem

Introduction

In this page you can find the example usage for com.itextpdf.text List getFirstItem.

Prototype

public ListItem getFirstItem() 

Source Link

Usage

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * //from ww  w  .  j a v  a  2s.c  o  m
 *  list 
 *
 * @param section list  section ?
 * @param e list   element
 * @throws Exception
 */
public static void setList(Section section, Element e) throws Exception {
    List list = new List(false, 15);
    list.setIndentationLeft(23);
    for (Element e1 : e.getChildren()) {
        ListItem item = new ListItem(e1.getText(), fnNormal);

        if (e1.getChild("url") != null) {
            item.add(getUrl(e1.getChild("url")));
        }

        item.setMultipliedLeading(1.8F);
        list.add(item);
    }
    list.getFirstItem().setSpacingBefore(-14);
    list.getLastItem().setSpacingAfter(14);

    section.add(list);
}

From source file:fenix.planner.pdf.PDFGenerator.java

License:Open Source License

private void parseAndAddFreeText(String text) throws DocumentException {
    List currentList = null;
    for (String line : text.split("\n")) {
        if (line.startsWith("- ")) {
            if (currentList == null) {
                currentList = new List(false, 10f);
                currentList.setListSymbol("\u2022");
            }/* w ww .  j a va  2  s . c o m*/
            ListItem item = new ListItem();
            currentList.add(item);
            parseAndAddBodyTextLineToParagraph(item, line.substring(2), freeTextFont);
        } else {
            if (currentList != null && !currentList.isEmpty()) {
                currentList.getLastItem().setSpacingAfter(5);
                currentList.getFirstItem().setSpacingBefore(5);
                document.add(currentList);
                currentList = null;
            }
            Paragraph p = new Paragraph();
            p.setSpacingAfter(5);
            p.setSpacingBefore(5);
            parseAndAddBodyTextLineToParagraph(p, line, freeTextFont);
            document.add(p);
        }
    }
}