List of usage examples for com.lowagie.text Paragraph setSpacingAfter
public void setSpacingAfter(float spacing)
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeTitle(Document document, String title) throws Exception { Paragraph titleParagraph = new Paragraph(title, titleFont); titleParagraph.setAlignment(Element.ALIGN_LEFT); titleParagraph.setLeading(30);/* w w w .j a va 2 s. co m*/ titleParagraph.setSpacingAfter(2); document.add(titleParagraph); }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeSubTitle(Document document, String title) throws Exception { Paragraph titleParagraph = new Paragraph(title, subTitleFont); titleParagraph.setAlignment(Element.ALIGN_LEFT); titleParagraph.setLeading(20);/*from w w w .ja v a 2 s.c o m*/ titleParagraph.setSpacingAfter(2); document.add(titleParagraph); }
From source file:com.kahlon.guard.controller.DocumentManager.java
/** * * @param document//from www .j a va2 s.co m */ public void preProcessPDF(Object document) { try { BaseFont bf_courier = BaseFont.createFont(BaseFont.COURIER, "Cp1252", false); Document pdf = (Document) document; pdf.setPageSize(PageSize.A4); pdf.setMargins(5f, 5f, 10f, 5f); // headers and footers must be added before the document is opened HeaderFooter footer = new HeaderFooter(new Phrase("page: ", new Font(bf_courier)), true); footer.setBorder(Rectangle.NO_BORDER); footer.setAlignment(Element.ALIGN_CENTER); pdf.setFooter(footer); // HeaderFooter header = new HeaderFooter( // new Phrase("This is a header without a page number", new Font(bf_courier)), false); // header.setAlignment(Element.ALIGN_CENTER); // pdf.setHeader(header); pdf.open(); String logoPath = "/resources/image/logo.png"; ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext(); String logo = servletContext.getRealPath(logoPath); pdf.add(Image.getInstance(logo)); Person person = context.getSelectedPerson().getDisplayPerson(); String name = FacesMessageUtil.getMessage("person.name") + " : " + person.getName(); String age = FacesMessageUtil.getMessage("person.age") + " : " + Integer.toString(person.getAge()); String gender = FacesMessageUtil.getMessage("person.gender") + " : " + person.getGender().getDescription(); String race = FacesMessageUtil.getMessage("person.ethnicity") + " : " + person.getEthnicity().getDescription(); Person rootPerson = person.getRootPerson(); PersonImage imgp = imageService.getLastestPersonImage(rootPerson.getId()); Image imgb = Image.getInstance(imgp.getContent()); imgb.scaleToFit(100, 120); PdfPTable headerTable = new PdfPTable(2); PdfPTable personTable = new PdfPTable(1); personTable.setWidthPercentage(100); PdfPCell cell; cell = new PdfPCell(new Phrase(name)); cell.setBorder(Rectangle.NO_BORDER); personTable.addCell(cell); cell = new PdfPCell(new Phrase(age)); cell.setBorder(Rectangle.NO_BORDER); personTable.addCell(cell); cell = new PdfPCell(new Phrase(gender)); cell.setBorder(Rectangle.NO_BORDER); personTable.addCell(cell); cell = new PdfPCell(new Phrase(race)); cell.setBorder(Rectangle.NO_BORDER); personTable.addCell(cell); BarcodePDF417 pdf417 = new BarcodePDF417(); pdf417.setText(Integer.toString(person.getId())); Image img = pdf417.getImage(); img.scalePercent(150, 60 * pdf417.getYHeight()); cell = new PdfPCell(img); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(15); personTable.addCell(cell); cell.addElement(personTable); headerTable.addCell(cell); cell = new PdfPCell(imgb); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(cell); headerTable.setSpacingAfter(15); pdf.add(headerTable); LineSeparator lineSeparator = new LineSeparator(); lineSeparator.setPercentage(82); pdf.add(lineSeparator); Paragraph space = new Paragraph(); space.add(""); space.setSpacingAfter(15); pdf.add(space); } catch (IOException e) { logger.log(Level.INFO, e.getMessage()); } catch (BadElementException e) { logger.log(Level.INFO, e.getMessage()); } catch (DocumentException e) { logger.log(Level.INFO, e.getMessage()); } catch (Exception e) { logger.log(Level.INFO, e.getMessage()); } }
From source file:com.nokia.s60tools.swmtanalyser.wizards.ReportCreationJob.java
License:Open Source License
private void addSelectedIssuesReport(Document document) throws DocumentException, BadElementException { Paragraph selected_title = new Paragraph("Selected issues", fontHeading1); selected_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT); document.add(selected_title);//from w w w. ja va 2 s . c o m Display.getDefault().syncExec(new Runnable() { public void run() { table = getTableForTheSelectedIssues(all_tree_items); } }); document.add(table); document.add(Chunk.NEWLINE); Paragraph graph_title = new Paragraph("Graph for the selected issues", fontHeading1); //Using chapter, so title stays together with image Chapter chapter = new Chapter(graph_title, 0); //Chapter with out number, when depth is 0 chapter.setNumberDepth(0); com.lowagie.text.Image img = null; try { img = com.lowagie.text.Image .getInstance(SwmtAnalyserPlugin.getPluginInstallPath() + "\\swmt_graph.bmp"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } img.scalePercent(50f); img.setBorder(Rectangle.BOX); img.setBorderWidth(1f); img.setBorderColor(new GrayColor(0.5f)); //Adding image to chapter chapter.add(img); //Adding chapter to document document.add(chapter); }
From source file:com.nokia.s60tools.swmtanalyser.wizards.ReportCreationJob.java
License:Open Source License
private void addOverviewReport(Document document) throws DocumentException { Paragraph res_title = new Paragraph("Overview Of Analysis Results", fontHeading1); res_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT); document.add(res_title);// w ww . jav a 2s .co m Display.getDefault().syncExec(new Runnable() { public void run() { table = getTableForOverallIssues(all_tree_items); } }); document.add(table); document.add(Chunk.NEWLINE); res_title = new Paragraph("Details", fontHeading1); document.add(res_title); res_title = new Paragraph("Critical Severity Issues", fontHeading2); res_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT); Display.getDefault().syncExec(new Runnable() { public void run() { table = getTableForIssues(all_tree_items, AnalyserConstants.Priority.CRITICAL); ; } }); if (table != null) { document.add(res_title); document.add(table); document.add(Chunk.NEWLINE); } res_title = new Paragraph("High Severity Issues", fontHeading2); res_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT); Display.getDefault().syncExec(new Runnable() { public void run() { table = getTableForIssues(all_tree_items, AnalyserConstants.Priority.HIGH); } }); if (table != null) { document.add(res_title); document.add(table); document.add(Chunk.NEWLINE); } res_title = new Paragraph("Normal Severity Issues", fontHeading2); res_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT); Display.getDefault().syncExec(new Runnable() { public void run() { table = getTableForIssues(all_tree_items, AnalyserConstants.Priority.NORMAL); } }); if (table != null) { document.add(res_title); document.add(table); } }
From source file:com.preparatic.archivos.PdfGenerator.java
License:Apache License
/** * Ade una pregunta al test.//www . j ava 2 s.c om * * @param resultados * @throws Exception */ private void agregarPregunta(PreguntaTest pregunta, boolean isLast) { // Creamos una lista para las respuestas. listaRespuestas = new com.lowagie.text.List(true, true); listaRespuestas.add(new ListItem(pregunta.getRespuesta_a(), miFuentePregs)); listaRespuestas.add(new ListItem(pregunta.getRespuesta_b(), miFuentePregs)); listaRespuestas.add(new ListItem(pregunta.getRespuesta_c(), miFuentePregs)); listaRespuestas.add(new ListItem(pregunta.getRespuesta_d(), miFuentePregs)); // Incorporamos la lista de respuestas en un nico Prrafo Paragraph parrafoPregunta = new Paragraph(pregunta.getPregunta(), miFuentePregs); parrafoPregunta.setKeepTogether(true); parrafoPregunta.add(listaRespuestas); if (!isLast) parrafoPregunta.setSpacingAfter(distanciaInterPregunta); // Metemos la pregunta como un Li en ListaPreguntas. ListItem li = new ListItem(parrafoPregunta); li.setKeepTogether(true); listaPreguntas.add(li); String cadenaSolucion = pregunta.getRespuesta_correcta().toUpperCase(); if (pregunta.getTemas() != null) cadenaSolucion += " (T" + pregunta.getTemas() + ")"; listaSoluciones.add(new ListItem(cadenaSolucion, miFuenteSols)); }
From source file:com.preparatic.archivos.PdfGenerator.java
License:Apache License
private void agregarPregunta(ResultSet resultados) throws Exception { // Creamos una lista para las respuestas. listaRespuestas = new com.lowagie.text.List(true, true); listaRespuestas.add(new ListItem(resultados.getString("RESPUESTA_A"), miFuentePregs)); listaRespuestas.add(new ListItem(resultados.getString("RESPUESTA_B"), miFuentePregs)); listaRespuestas.add(new ListItem(resultados.getString("RESPUESTA_C"), miFuentePregs)); listaRespuestas.add(new ListItem(resultados.getString("RESPUESTA_D"), miFuentePregs)); // Incorporamos la lista de respuestas en un nico Prrafo Paragraph parrafoPregunta = new Paragraph(resultados.getString("PREGUNTA"), miFuentePregs); parrafoPregunta.setKeepTogether(true); parrafoPregunta.add(listaRespuestas); if (!resultados.isLast()) parrafoPregunta.setSpacingAfter(distanciaInterPregunta); // Metemos la pregunta como un Li en ListaPreguntas. ListItem li = new ListItem(parrafoPregunta); li.setKeepTogether(true);//from ww w .j ava 2 s .co m listaPreguntas.add(li); String cadenaSolucion = resultados.getString("RESPUESTA_CORRECTA").toUpperCase(); if (resultados.getString(7) != null) cadenaSolucion += " (T" + resultados.getString("TEMAS") + ")"; listaSoluciones.add(new ListItem(cadenaSolucion, miFuenteSols)); }
From source file:com.qcadoo.report.api.pdf.elements.Headers.java
License:Open Source License
private static Paragraph paragraph(final String text, final Font font, final float marginTop, final float marginBottom) { Paragraph paragraph = new Paragraph(text, font); paragraph.setSpacingBefore(marginTop); paragraph.setSpacingAfter(marginBottom); return paragraph; }
From source file:com.qcadoo.report.internal.PdfHelperImpl.java
License:Open Source License
@Override public void addDocumentHeader(final Document document, final String name, final String documenTitle, final String documentAuthor, final Date date, final String username) throws DocumentException { SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale()); LineSeparator line = new LineSeparator(3, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0); document.add(Chunk.NEWLINE);//from w ww .java 2 s .c om Paragraph title = new Paragraph(new Phrase(documenTitle, FontUtils.getDejavuBold17Light())); title.add(new Phrase(" " + name, FontUtils.getDejavuBold17Dark())); title.setSpacingAfter(7f); document.add(title); document.add(line); PdfPTable userAndDate = new PdfPTable(2); userAndDate.setWidthPercentage(100f); userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT); userAndDate.getDefaultCell().setBorderWidth(0); Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light())); userParagraph.add(new Phrase(" " + username, FontUtils.getDejavuRegular9Dark())); Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light()); userAndDate.addCell(userParagraph); userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); userAndDate.addCell(dateParagraph); userAndDate.setSpacingAfter(14f); document.add(userAndDate); }
From source file:com.qcadoo.report.internal.PdfHelperImpl.java
License:Open Source License
@Override public void addDocumentHeader(final Document document, final String name, final String documenTitle, final String documentAuthor, final Date date) throws DocumentException { SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale()); LineSeparator line = new LineSeparator(2, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0); document.add(Chunk.NEWLINE);//from ww w. j a va 2 s . com Paragraph title = new Paragraph(new Phrase(documenTitle, FontUtils.getDejavuBold17Light())); title.add(new Phrase(" " + name, FontUtils.getDejavuBold17Dark())); title.setSpacingAfter(7f); document.add(title); document.add(line); PdfPTable userAndDate = new PdfPTable(2); userAndDate.setWidthPercentage(100f); userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT); userAndDate.getDefaultCell().setBorderWidth(0); Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light())); userParagraph.add(new Phrase(" " + getDocumentAuthor(), FontUtils.getDejavuRegular9Dark())); Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light()); userAndDate.addCell(userParagraph); userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); userAndDate.addCell(dateParagraph); userAndDate.setSpacingAfter(14f); document.add(userAndDate); }