List of usage examples for com.itextpdf.text Paragraph setSpacingBefore
public void setSpacingBefore(float spacing)
From source file:control.listaEquiposUsua.java
private boolean generapdf(String path) throws DocumentException, FileNotFoundException { boolean estado = false; Document document = new Document(); //OutputStreamWriter destino = new OutputStreamWriter(fos,"ISO-8859-1"); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();//from w w w . j a v a2 s .c o m Paragraph paragraph1 = new Paragraph("Equipos"); document.add(paragraph1); Paragraph paragraph2 = new Paragraph(""); paragraph2.setSpacingBefore(38f); document.add(paragraph2); PdfPTable table = new PdfPTable(7); table.addCell("Id "); table.addCell("Nombre"); table.addCell("categoria"); table.addCell("Accesorios"); table.addCell("Descripcion"); table.addCell("Marca"); table.addCell("Estado"); Object[][] tabla = this.getTableData(tabEquipo); for (Object[] o : tabla) { int i = 0; for (Object e : o) { if (i <= 6) { if (e != null) table.addCell((String) e.toString()); else table.addCell(""); } i++; } } document.add(table); document.close(); return true; }
From source file:control.listaReporte.java
private boolean generapdf(String path) throws DocumentException, FileNotFoundException { boolean estado = false; Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();// www .ja v a2 s.c om Paragraph paragraph1 = new Paragraph("Prestamos"); document.add(paragraph1); Paragraph paragraph2 = new Paragraph(""); paragraph2.setSpacingBefore(38f); document.add(paragraph2); PdfPTable table = new PdfPTable(7); table.addCell("Id reporte"); table.addCell("Solicitante"); table.addCell("Proyecto"); table.addCell("Fecha prestamo"); table.addCell("Fecha devolucion"); table.addCell("Fecha real"); table.addCell("prestador"); Object[][] tabla = this.getTableData(reportes); for (Object[] o : tabla) for (Object e : o) { if (e != null) table.addCell((String) e.toString()); else table.addCell(""); } document.add(table); document.close(); return true; }
From source file:control.ModificaPrestamo.java
public boolean generapdf(String path) throws DocumentException, FileNotFoundException { boolean estado = false; Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();//from ww w.j a va2 s . co m Image img = null; try { img = Image.getInstance("src/img/imgen.jpg"); img.scaleAbsolute(80f, 50f); img.setAbsolutePosition(470f, 750f); document.add(img); } catch (BadElementException ex) { Logger.getLogger(nuevoReporte.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(nuevoReporte.class.getName()).log(Level.SEVERE, null, ex); } Paragraph paragraph1 = new Paragraph("Solicitante: " + Solicitante.getText()); Paragraph paragraph2 = new Paragraph("Proyecto: " + Proyecto.getText()); Paragraph paragraph3 = new Paragraph( "Fecha y hora del prestamo: " + fecha.getText() + " " + hora.getText()); Paragraph paragraph4 = new Paragraph("Fecha de entrega: " + fecha1.getText()); document.add(paragraph1); document.add(paragraph2); document.add(paragraph3); document.add(paragraph4); Paragraph tmp = new Paragraph(""); tmp.setSpacingBefore(10); document.add(tmp); PdfPTable table = new PdfPTable(4); table.addCell("Id Equipo"); table.addCell("Equipo"); table.addCell("Accesorios"); table.addCell("Descripcion"); Object[][] tabla = this.getTableData(tabReporte); for (Object[] o : tabla) for (Object e : o) { table.addCell((String) e); } document.add(table); System.out.println(clausula1.getText() + " " + clausula2.getText()); Paragraph paragraph5 = new Paragraph("Clausula 1: " + clausula1.getText()); Paragraph paragraph6 = new Paragraph("Clausula 2: " + clausula2.getText()); document.add(paragraph5); document.add(paragraph6); tmp = new Paragraph(""); tmp.setSpacingBefore(10); document.add(tmp); Paragraph p = new Paragraph("Firma del solicitante: "); p.add(new Chunk(new DottedLineSeparator())); p.add(" Firma del prestador: "); p.add(new Chunk(new DottedLineSeparator())); document.add(p); //PdfPTable firma = new PdfPTable(1); //firma.addCell("Firma"); //document.add(new Paragraph("")); //document.add(firma); document.close(); return true; }
From source file:de.beimax.talenttree.PageGeneratorSimple.java
License:Open Source License
/** * add general descriptive text//from ww w .j a v a 2s . c o m * @throws Exception */ protected void addDescriptiveText() throws Exception { Object key = data.get("descriptiveText"); // generic description if (key != null) { Paragraph p = new Paragraph(parseTextProperty((String) key, 10f, false)); p.setSpacingBefore(5f); // add some space before to make it look nicer document.add(p); } }
From source file:edu.harvard.mcz.precapture.ui.ContainerLabel.java
License:Open Source License
/** * /*from www . j a v a2s. co m*/ * @return a PDF paragraph cell containing a text encoding of the fields in this set. */ public PdfPCell toPDFCell(LabelDefinitionType printDefinition) { PdfPCell cell = new PdfPCell(); ; if (printDefinition.getTextOrentation().toString().toLowerCase() .equals(TextOrentationType.VERTICAL.toString().toLowerCase())) { log.debug("Print orientation of text is Vertical"); cell.setRotation(90); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); } cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.disableBorderSide(PdfPCell.RIGHT); cell.setPaddingLeft(3); cell.setNoWrap(false); int leading = (int) (fields.get(0).getField().getFontSize() + printDefinition.getFontDelta()) - 1; Paragraph higher = new Paragraph(leading, "", new Font(Font.FontFamily.TIMES_ROMAN, fields.get(0).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL)); higher.setSpacingBefore(0); higher.setSpacingAfter(0); boolean added = false; boolean hasContent = false; for (int i = 0; i < fields.size(); i++) { log.debug(i); if (fields.get(i).getField().isNewLine() || (i == fields.size() - 1)) { if (!higher.isEmpty()) { log.debug(higher.getContent()); cell.addElement(higher); } leading = (int) (fields.get(i).getField().getFontSize() + printDefinition.getFontDelta()) - 1; higher = new Paragraph(leading, "", new Font(Font.FontFamily.TIMES_ROMAN, fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL)); higher.setSpacingBefore(0); higher.setSpacingAfter(0); added = false; hasContent = false; } log.debug(fields.get(i).getTextField().getText().trim()); Chunk chunk = new Chunk(fields.get(i).getTextField().getText().trim()); if (fields.get(i).getField().isUseItalic()) { chunk.setFont(new Font(Font.FontFamily.TIMES_ROMAN, fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.ITALIC)); } else { chunk.setFont(new Font(Font.FontFamily.TIMES_ROMAN, fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL)); } if (!chunk.isEmpty()) { hasContent = true; higher.add(chunk); log.debug(fields.get(i).getField().getSuffix()); if (fields.get(i).getField().getSuffix() != null && fields.get(i).getField().getSuffix().length() > 0) { higher.add(new Chunk(fields.get(i).getField().getSuffix())); } if (fields.get(i).getTextField().getText().trim().length() > 0) { // add a trailing space as a separator if there was something to separate. higher.add(new Chunk(" ")); } } } if (!added) { log.debug(higher.getContent()); cell.addElement(higher); } String extraText = PreCaptureSingleton.getInstance().getProperties().getProperties() .getProperty(PreCaptureProperties.KEY_EXTRAHUMANTEXT); if (extraText != null && extraText.length() > 0) { log.debug(extraText); cell.addElement(new Chunk(extraText)); } return cell; }
From source file:essencialles.modelos.relatorio.tipos.MaisVendidos.java
@Override public void run() { try {/*from w ww . ja va 2s . c o m*/ //criao do PDF Document doc = new Document(PageSize.A4, 72, 72, 72, 72); OutputStream saida = new FileOutputStream(this.caminho); PdfWriter.getInstance(doc, saida); doc.open(); try { //logomarca Image img = Image.getInstance("src/views/img/logomarca.png"); img.setAlignment(Element.ALIGN_CENTER); doc.add(img); } catch (BadElementException | IOException ex) { throw new RuntimeException(ex); } //paragrafo Paragraph paragrafo = new Paragraph("Relatrio de Produtos Mais Vendidos"); paragrafo.setSpacingAfter(50); paragrafo.setSpacingBefore(15); paragrafo.setFont(new Font(Font.FontFamily.COURIER, Font.BOLD)); paragrafo.setAlignment(Element.ALIGN_CENTER); doc.add(paragrafo); /*tabela PdfPTable tabela = new PdfPTable(9); tabela.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell header = new PdfPCell(new Paragraph("Todos os Produtos")); header.setColspan(9); tabela.addCell(header); tabela.addCell("Codigo"); tabela.addCell("Nome"); tabela.addCell("Marca"); tabela.addCell("Preo"); tabela.addCell("Custo"); tabela.addCell("Cor"); tabela.addCell("Descrio"); tabela.addCell("Peso"); tabela.addCell("Disponibilidade"); tabela.addCell("Validade"); adicionar linhas da tabela. for (Produto p : produtos) { String cod = p.getCod_produto() + ""; String nome = p.getNome(); String marca = p.getMarca(); String preco = p.getPreco() + ""; String custo = p.getCusto() + ""; String cor = p.getCor(); String descricao = p.getDescricao(); String peso = p.getPeso(); String disponibilidade = p.getDisponibilidade(); String validade = p.getValidade() + ""; }*/ try { saida.flush(); } catch (IOException ex) { throw new RuntimeException(ex); } doc.close(); try { saida.close(); } catch (IOException ex) { throw new RuntimeException(ex); } } catch (FileNotFoundException | DocumentException ex) { throw new RuntimeException(ex); } }
From source file:essencialles.modelos.relatorio.tipos.ProdutosTodos.java
@Override public void run() { try {/* w w w .j a v a 2 s . c om*/ //criao do PDF Document doc = new Document(PageSize.A4, 72, 72, 72, 72); OutputStream saida = new FileOutputStream(this.caminho); PdfWriter.getInstance(doc, saida); doc.open(); try { //logomarca Image img = Image.getInstance("src/views/img/logomarca.png"); img.setAlignment(Element.ALIGN_CENTER); doc.add(img); } catch (BadElementException | IOException ex) { throw new RuntimeException(ex); } //paragrafo Paragraph paragrafo = new Paragraph("Relatrio de Produtos"); paragrafo.setSpacingAfter(50); paragrafo.setSpacingBefore(15); paragrafo.setFont(new Font(Font.FontFamily.COURIER, Font.BOLD)); paragrafo.setAlignment(Element.ALIGN_CENTER); doc.add(paragrafo); /*tabela PdfPTable tabela = new PdfPTable(9); tabela.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell header = new PdfPCell(new Paragraph("Todos os Produtos")); header.setColspan(9); tabela.addCell(header); tabela.addCell("Codigo"); tabela.addCell("Nome"); tabela.addCell("Marca"); tabela.addCell("Preo"); tabela.addCell("Custo"); tabela.addCell("Cor"); tabela.addCell("Descrio"); tabela.addCell("Peso"); tabela.addCell("Disponibilidade"); tabela.addCell("Validade"); adicionar linhas da tabela. for (ProdutoModelo p : produtos) { String cod = p.getCod_produto() + ""; String nome = p.getNome(); String marca = p.getMarca(); String preco = p.getPreco() + ""; String custo = p.getCusto() + ""; String cor = p.getCor(); String descricao = p.getDescricao(); String peso = p.getPeso(); String disponibilidade = p.getDisponibilidade(); String validade = p.getValidade() + ""; }*/ try { saida.flush(); } catch (IOException ex) { throw new RuntimeException(ex); } doc.close(); try { saida.close(); } catch (IOException ex) { throw new RuntimeException(ex); } } catch (FileNotFoundException | DocumentException ex) { throw new RuntimeException(ex); } }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java
License:Open Source License
protected Paragraph getSectionTitleParagraph(String title) { Paragraph result = new Paragraph(title, SECTION); result.setSpacingAfter(15);//from ww w . j a v a 2s. c om result.setSpacingBefore(10); return result; }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java
License:Open Source License
protected Paragraph listParagraphs(List<Paragraph> paragraphs) { Paragraph pList = getDefaultParagraph(); com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); list.setListSymbol("\u2022" + " "); list.setSymbolIndent(30f);/*www . j a v a 2 s .co m*/ pList.add(list); pList.setSpacingBefore(0f); pList.setSpacingAfter(0f); for (Paragraph p : paragraphs) { list.add(new ListItem(p)); } return pList; }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildAppendixCChapter(Chapter c, Document d) { c.setTitle(getChapterTitleParagraph("Appendix C")); c.setNumberDepth(0);/*ww w . j ava2 s .co m*/ c.setTriggerNewPage(true); String sectionIntro = "STS-ml allows for the specification of security needs over actors interactions. It currently supports a non-exhaustive set of security needs and organisational constraints, namely non-repudiation, redundancy, no-delegation, non-usage, non-modification, non-production, non-disclosure and need-to-know. The purpose of security analysis is to verify whether there are any violations of security needs. As such, it includes defining the rules necessary to detect violations. In the following are provided the details for all the checks performed during security analysis."; c.add(createParagraph(sectionIntro)); List<Paragraph> plist = new ArrayList<Paragraph>(); int kk = 0; for (kk = kk; kk < 4; kk++) { plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } c.add(listParagraphs(plist)); plist.clear(); Paragraph parList = getDefaultParagraph(); com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); list.setListSymbol("\u2022" + " "); list.setSymbolIndent(30f); parList.add(list); parList.setSpacingBefore(0f); parList.setSpacingAfter(0f); list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++]))); com.itextpdf.text.List subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); subList.setListSymbol("\u2022" + " "); subList.setSymbolIndent(15f); for (kk = kk; kk < 10; kk++) { subList.add( new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]))); // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } list.add(subList); c.add(parList); /* * Paragraph actorName = createParagraph(type + "%b" + a.getName() + * "%:"); actorName.setSpacingAfter(5); * * com.itextpdf.text.List list = new * com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); * list.setListSymbol("\u2022" + " "); list.setSymbolIndent(10f); * list.add(new ListItem(actorName)); * * if (sbOut.length() > 0) { com.itextpdf.text.List sublist = new * com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); * sublist.setListSymbol("- "); sublist.setSymbolIndent(30f); * //Paragraph p=createParagraph("%b" + a.getName() + "% " + * sbOut.toString() + "."); Paragraph p = * createParagraph(sbOut.toString() + "."); * * if (sbInc.length() > 0) { p.setSpacingAfter(10); } * * sublist.add(new ListItem(p)); list.add(sublist); */ String text = "Apart from the verification of violations of security needs, security analysis performs checks to verify that actors comply with their authorities. For this, it searches for eventual unauthorised passages of rights. For the time being, the following violations are detected:"; c.add(createParagraph(text)); parList = getDefaultParagraph(); list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); list.setListSymbol("\u2022" + " "); list.setSymbolIndent(30f); parList.add(list); parList.setSpacingBefore(0f); parList.setSpacingAfter(0f); list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++]))); subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); subList.setListSymbol("\u2022" + " "); subList.setSymbolIndent(15f); for (kk = kk; kk < 16; kk++) { subList.add( new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]))); // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } list.add(subList); c.add(parList); text = "As far as organisational constraints are concerned, security analysis verifies that the specification of SoD and BoD constraints can be satisfied in the given model. The satisfaction of role-based SoD and BoD are already covered by the consistency analysis, security analysis deals with goal-based SoD and BoD instead."; c.add(createParagraph(text)); for (kk = kk; kk < SecurityAnalysisTasksNames.ALL_TASKS_NAMES.length; kk++) { plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } c.add(listParagraphs(plist)); c.setComplete(true); }