List of usage examples for com.itextpdf.text List List
public List()
List
. From source file:cl.preguntame.clases.ListadoPDF.java
public List getListado() { List listado = new List(); for (int i = 0; i < items.size(); i++) { listado.add(items.get(i));//from w w w . j a v a 2 s.c om } listado.setIndentationLeft(20); return listado; }
From source file:com.chaschev.itext.ListBuilder.java
License:Apache License
public ListBuilder withNew() { list = new List(); return this; }
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"; }/*from w ww.j a v a 2s. com*/ 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); }
From source file:org.smap.sdal.managers.PDFSurveyManager.java
License:Open Source License
private void processSelect(Parser parser, String remoteUser, PdfPCell cell, DisplayItem di, boolean generateBlank, GlobalVariables gv, int oId) throws Exception { Font f = null;//w w w . j ava 2s . co m boolean isRtl = false; // If generating blank template List list = new List(); list.setAutoindent(false); list.setSymbolIndent(24); String lang; boolean isSelectMultiple = di.type.equals("select") ? true : false; // Questions that append their values to this question ArrayList<String> deps = gv.addToList.get(di.fIdx + "_" + di.rec_number + "_" + di.name); /* * Add the value of this question unless * The form is not blank and the value is "other" and their are 1 or more dependent questions * In this case we assume that its only the values of the dependent questions that are needed */ if (generateBlank) { // TODO get real choices using choice manager Form form = survey.forms.get(di.fIdx); Question question = form.questions.get(di.qIdx); OptionList ol = survey.optionLists.get(question.list_name); for (Option o : ol.options) { String text = null; if (o.display_name != null && o.display_name.trim().length() > 0) { text = o.display_name; } else { text = o.labels.get(languageIdx).text; } lang = GeneralUtilityMethods.getLanguage(text); f = getFont(lang); isRtl = isRtl(lang); ListItem item = new ListItem(GeneralUtilityMethods.unesc(text), f); if (isSelectMultiple) { item.setListSymbol(new Chunk("\uf096", Symbols)); list.add(item); } else { item.setListSymbol(new Chunk("\uf10c", Symbols)); list.add(item); } } if (isRtl) { cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL); } cell.addElement(list); } else { if (deps == null || (di.value != null && !di.value.trim().toLowerCase().equals("other"))) { String value = di.value; if (di.type.equals("select1")) { Form form = survey.forms.get(di.fIdx); Question question = form.questions.get(di.qIdx); ArrayList<String> matches = new ArrayList<String>(); matches.add(di.value); value = choiceManager.getLabel(sd, cResults, user, oId, survey.id, question.id, question.l_id, question.external_choices, question.external_table, survey.languages.get(languageIdx).name, languageIdx, matches, survey.ident); } else if (di.type.equals("select")) { String nameValue = value; if (nameValue != null) { String vArray[] = nameValue.split(" "); ArrayList<String> matches = new ArrayList<String>(); if (vArray != null) { for (String v : vArray) { matches.add(v); } } Form form = survey.forms.get(di.fIdx); Question question = form.questions.get(di.qIdx); value = choiceManager.getLabel(sd, cResults, user, oId, survey.id, question.id, question.l_id, question.external_choices, question.external_table, survey.languages.get(languageIdx).name, languageIdx, matches, survey.ident); } } if (GeneralUtilityMethods.isRtlLanguage(di.value)) { cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL); } parser.elements.clear(); String html = getHtml(value, di, gv, deps); try { parser.xmlParser.parse(new StringReader(html)); } catch (Exception e) { log.info("Error parsing: " + html.toString() + " : " + e.getMessage()); lm.writeLog(sd, survey.getId(), remoteUser, LogManager.ERROR, e.getMessage() + " for: " + html.toString()); cell.addElement(getPara(html.toString(), di, gv, null, null)); } for (Element element : parser.elements) { cell.addElement(element); } //cell.addElement(getPara(value, di, gv, deps, null)); } } }
From source file:ro.ldir.chartpackage.GarbagePackageBuilder.java
License:Open Source License
public void writePDF(OutputStream out) throws DocumentException, MalformedURLException, XPathExpressionException, IOException { BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, "Cp1250", BaseFont.NOT_EMBEDDED); final Font hfFont = new Font(bf, 8, Font.NORMAL, BaseColor.GRAY); Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.getInstance(document, out); writer.setBoxSize("art", new Rectangle(36, 54, 559, 788)); writer.setPageEvent(new PdfPageEventHelper() { private int page = 0; @Override/*from w w w . j av a 2 s . c om*/ public void onEndPage(PdfWriter writer, Document arg1) { page++; Rectangle rect = writer.getBoxSize("art"); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase("Pachet mormane - \u00a9 Let's Do It, Romania!", hfFont), (rect.getLeft() + rect.getRight()) / 2, rect.getTop() + 18, 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase("- " + page + " -", hfFont), (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 18, 0); } }); document.open(); document.addAuthor("Let's Do It, Romania!"); document.addTitle("Pachet mormane"); document.addCreationDate(); Font titleFont = new Font(bf, 24, Font.BOLD); Font noteFont = new Font(bf, 12, Font.NORMAL, BaseColor.RED); Font headerFont = new Font(bf, 12, Font.BOLD); Font normalFont = new Font(bf, 11); Font defFont = new Font(bf, 11, Font.BOLD); Paragraph par; int page = 0; for (Garbage garbage : garbages) { par = new Paragraph(); par.setAlignment(Element.ALIGN_CENTER); par.add(new Chunk("Morman " + garbage.getGarbageId() + "\n", titleFont)); par.add(new Chunk("Citi\u0163i cu aten\u0163ie!", noteFont)); document.add(par); par = new Paragraph(); par.setSpacingBefore(20); par.add(new Chunk("1. Date generale\n", headerFont)); par.add(new Chunk("Jude\u0163ul: ", defFont)); par.add(new Chunk(garbage.getCounty().getName() + "\n", normalFont)); par.add(new Chunk("Comuna: ", defFont)); par.add(new Chunk(garbage.getTown().getName() + "\n", normalFont)); if (garbage.getChartedArea() != null) { par.add(new Chunk("Zona cartare: ", defFont)); par.add(new Chunk(garbage.getChartedArea().getName() + "\n", normalFont)); } par.add(new Chunk("Pozi\u0163ie: ", defFont)); par.add(new Chunk(garbage.getY() + ", " + garbage.getX() + "\n", normalFont)); par.add(new Chunk("Descriere:\n", defFont)); par.add(new Phrase(garbage.getDescription() + "\n", normalFont)); par.add(new Chunk("Componen\u0163\u0103 gunoi:\n", defFont)); List list = new List(); list.add(new ListItem( new Chunk("Procent plastic: " + garbage.getPercentagePlastic() + "%", normalFont))); list.add(new ListItem( new Chunk("Procent sticl\u0103: " + garbage.getPercentageGlass() + "%", normalFont))); list.add(new ListItem(new Chunk("Procent metale: " + garbage.getPercentageMetal() + "%", normalFont))); list.add(new ListItem( new Chunk("Procent nereciclabile: " + garbage.getPercentageWaste() + "%", normalFont))); par.add(list); document.add(par); par = new Paragraph(); par.setSpacingBefore(20); par.add(new Chunk("2. Indica\u0163ii rutiere\n", headerFont)); Image img = Image.getInstance(getImage(garbage)); img.scaleToFit((float) (PageSize.A4.getWidth() * .75), (float) (PageSize.A4.getHeight() * .75)); img.setAlignment(Element.ALIGN_CENTER); par.add(img); document.add(par); if (page < garbages.size() - 1) document.newPage(); page++; } document.close(); }