@Override public void process(int level, Node node, InvocationContext context) { List<Element> subs = context.collectChildren(level, node); com.itextpdf.text.List orderedList = new com.itextpdf.text.List(com.itextpdf.text.List.ORDERED); for (Element sub : subs) { if (!orderedList.add(sub)) { // wrap it ListItem listItem = new ListItem(); listItem.add(sub); orderedList.add(listItem); } } KeyValues kvs = context.iTextContext().keyValues(); Float spacingBefore = kvs.<Float>getNullable(ORDERED_LIST_SPACING_BEFORE).or(5f); Float spacingAfter = kvs.<Float>getNullable(ORDERED_LIST_SPACING_AFTER).or(5f); Paragraph p = new Paragraph(); p.add(orderedList); p.setSpacingBefore(spacingBefore); p.setSpacingAfter(spacingAfter); context.append(p); }
private static void createList(Section subCatPart) { List list = new List(true, false, 10); list.add(new ListItem("First point")); list.add(new ListItem("Second point")); list.add(new ListItem("Third point")); subCatPart.add(list); }
@Override public void buildComponent(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EvaluatedHtmlPresentationNode pEvalNode) { ListItem lListItem = pSerialiser.getElementFactory().getListItem(); pSerialiser.startContainer(ElementContainerFactory.getContainer(lListItem)); processChildren(pSerialisationContext, pSerialiser, pEvalNode); pSerialiser.endContainer(); pSerialiser.add(lListItem); }
@Override public void process(int level, Node node, InvocationContext context) { List<Element> subs = context.collectChildren(level, node); com.itextpdf.text.List orderedList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); orderedList.setListSymbol(context.bulletSymbol()); for (Element sub : subs) { if (!orderedList.add(sub)) { // wrap it ListItem listItem = new ListItem(); listItem.add(sub); orderedList.add(listItem); } } KeyValues kvs = context.iTextContext().keyValues(); Float spacingBefore = kvs.<Float>getNullable(BULLET_LIST_SPACING_BEFORE).or(5f); Float spacingAfter = kvs.<Float>getNullable(BULLET_LIST_SPACING_AFTER).or(5f); Paragraph p = new Paragraph(); p.add(orderedList); p.setSpacingBefore(spacingBefore); p.setSpacingAfter(spacingAfter); context.append(p); }
public void learnIText() throws FileNotFoundException, DocumentException { final Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("/tmp/test.pdf")); document.open(); Paragraph p = new Paragraph(); for(int i = 0; i < 100; i++) { ZapfDingbatsList zapfdingbatslist = new ZapfDingbatsList(i); zapfdingbatslist.add(new ListItem(i)); zapfdingbatslist.add(new ListItem("test2")); p.add(zapfdingbatslist); } document.add(p); /* for(int i = 0; i < 100; i++) { Paragraph p = new Paragraph(); p.add("This is a test 2"); // document.newPage(); document.add(p); } */ document.close(); }
/** * Create a list item with the factory element attributes applied * @return A list item with the element attributes applied */ public ListItem getListItem() { ListItem lListItem = new ListItem(); return lListItem; }