List of usage examples for com.itextpdf.text ListItem ListItem
public ListItem()
ListItem
. From source file:com.masscustsoft.service.ToPdf.java
License:Open Source License
private com.itextpdf.text.List getList(Map row) throws Exception { String type = (String) row.get("type"); com.itextpdf.text.List list = null; if ("greek".equals(type)) list = new GreekList(); else if ("roman".equals(type)) list = new RomanList(); else if ("zd".equals(type)) list = new ZapfDingbatsList(1); else if ("zd#".equals(type)) list = new ZapfDingbatsNumberList(1); else//from w w w. ja va 2s .c o m list = new com.itextpdf.text.List(); Integer charNumber = (Integer) row.get("charNumber"); if (charNumber != null) { if (list instanceof ZapfDingbatsList) { ((ZapfDingbatsList) list).setCharNumber(charNumber); } if (list instanceof ZapfDingbatsNumberList) { ((ZapfDingbatsNumberList) list).setType(charNumber); } } Boolean lowercase = (Boolean) row.get("lowercase"); if (lowercase != null) list.setLowercase(lowercase); Boolean numbered = (Boolean) row.get("numbered"); if (numbered != null) list.setNumbered(numbered); Boolean lettered = (Boolean) row.get("lettered"); if (lettered != null) list.setLettered(lettered); Integer first = (Integer) row.get("first"); if (first != null) list.setFirst(first); String symbol = (String) row.get("symbol"); if (symbol != null) { Paragraph p = new Paragraph(); getChunks(p, row, symbol); if (p.size() > 0) { Object sym = p.get(0); if (sym instanceof Chunk) { list.setListSymbol((Chunk) sym); } } } Float ident = (Float) row.get("ident"); if (ident == null) ident = 10f; list.setSymbolIndent(ident); List<Map> lst = (List) row.get("items"); if (lst != null) { for (Map item : lst) { Element el = getElement(item); if (el != null) { ListItem li = new ListItem(); li.add(el); list.add(li); } } } if (list.size() > 0) { Object o = list.getItems().get(0); if (o instanceof Paragraph) { Paragraph p = (Paragraph) o; Float spaceBefore = (Float) row.get("spaceBefore"); if (spaceBefore != null) p.setSpacingBefore(spaceBefore); } o = list.getItems().get(list.getItems().size() - 1); if (o instanceof Paragraph) { Paragraph p = (Paragraph) o; Float spaceAfter = (Float) row.get("spaceAfter"); if (spaceAfter != null) p.setSpacingAfter(spaceAfter); } } return list; }
From source file:fenix.planner.pdf.PDFGenerator.java
License:Open Source License
private void parseAndAddFreeText(String text) throws DocumentException { List currentList = null;/*from w ww . j ava 2 s.co m*/ for (String line : text.split("\n")) { if (line.startsWith("- ")) { if (currentList == null) { currentList = new List(false, 10f); currentList.setListSymbol("\u2022"); } 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); } } }
From source file:net.sf.timecult.export.pdf.PdfTaskListExporter.java
License:Open Source License
private static void createTaskList(Document doc, TaskStatus taskStatus, Class<Task> taskSubtype) throws DocumentException, IOException { String tag = "tasklist." + taskStatus.toString(); if (taskStatus.getId() == TaskStatus.FLAGGED) { tag = taskStatus.getFlagColor().toString().toLowerCase() + "Flag"; }// w ww. j a v a2 s . c om String titleText = ResourceHelper.getString("button." + tag + ".tooltip"); Paragraph subTitle = new Paragraph(titleText, sectionFont); subTitle.setSpacingAfter(10); subTitle.setSpacingBefore(10); doc.add(subTitle); Task filteredTasks[] = TimeTracker.getInstance().getWorkspace().getTasksByStatus(taskStatus); TreeMap<String, Task> sortedItems = new TreeMap<String, Task>(); for (int i = 0; i < filteredTasks.length; i++) { sortedItems.put(filteredTasks[i].toString(), filteredTasks[i]); } Collection<Task> tasks = sortedItems.values(); com.itextpdf.text.List taskList = new List(); for (Task task : tasks) { // // Add flagged items regardless of their subtype (task or activity) // if ((taskStatus.getId() == TaskStatus.FLAGGED && task.getStatus().getId() == TaskStatus.FLAGGED) || task.getClass().equals(taskSubtype)) { Paragraph namePar = new Paragraph(task.getName(), textFont); ListItem taskItem = new ListItem(); taskItem.add(namePar); if (taskStatus.getId() == TaskStatus.WAITING) { Paragraph reasonPar = new Paragraph(task.getWaitReason().getText(), commentFont); taskItem.add(reasonPar); } taskList.add(taskItem); } } doc.add(taskList); }