List of usage examples for com.itextpdf.text Paragraph setSpacingAfter
public void setSpacingAfter(float spacing)
From source file:crs.Manager_Report_DailyController.java
@FXML private void onDownload(ActionEvent event) { if (report_datepicker.getValue() == null) return;//from w ww . j a v a 2s .c o m String filename = report_datepicker.getValue().toString() + "_DailyRental.pdf"; DirectoryChooserBuilder builder = DirectoryChooserBuilder.create(); builder.title("Hello World"); String cwd = System.getProperty("user.dir"); File file = new File(cwd); builder.initialDirectory(file); DirectoryChooser chooser = builder.build(); File chosenDir = chooser.showDialog(null); if (chosenDir != null) { System.out.println(chosenDir.getAbsolutePath()); } else { System.out.print("no directory chosen"); } Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(chosenDir.getAbsolutePath() + "/" + filename)); document.open(); Paragraph paragraph = new Paragraph(); paragraph.add("Daily Report of " + report_datepicker.getValue().toString()); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(40); document.add(paragraph); document.add(createPDFTableVehicle(Vlist)); paragraph.clear(); paragraph.add(" "); paragraph.setSpacingAfter(20); document.add(paragraph); document.add(createPDFTableByCategory(cdata)); paragraph.setSpacingAfter(20); document.add(paragraph); document.add(createPDFTableByBranch(bdata)); document.close(); label_result.setText("Download successfully"); label_result.setVisible(true); } catch (FileNotFoundException ex) { Logger.getLogger(Manager_ReportController.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(Manager_ReportController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:crs.Manager_ReturnbybranchController.java
@FXML private void onDownload(ActionEvent event) { if (report_datepicker.getValue() == null || combo_loc.getValue() == null) return;//from ww w .j av a 2s .com String date = report_datepicker.getValue().toString(); bid = getBranchid(combo_loc.getValue().toString()); Vlist = CRS.getDailyReturn(date, bid); cdata = getReturnByCategory(date); String filename = report_datepicker.getValue().toString() + "_DailyRental_" + combo_loc.getValue().toString() + ".pdf"; DirectoryChooserBuilder builder = DirectoryChooserBuilder.create(); builder.title("Hello World"); String cwd = System.getProperty("user.dir"); File file = new File(cwd); builder.initialDirectory(file); DirectoryChooser chooser = builder.build(); File chosenDir = chooser.showDialog(null); if (chosenDir != null) { System.out.println(chosenDir.getAbsolutePath()); } else { System.out.print("no directory chosen"); } Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(chosenDir.getAbsolutePath() + "/" + filename)); document.open(); Paragraph paragraph = new Paragraph(); paragraph.add("Daily Report of " + report_datepicker.getValue().toString() + " location: " + combo_loc.getValue().toString()); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(40); document.add(paragraph); document.add(createPDFTableVehicle(Vlist)); paragraph.clear(); paragraph.add(" "); paragraph.setSpacingAfter(20); document.add(paragraph); document.add(createPDFTableByCategory(cdata)); document.close(); label_result.setText("Download successfully"); label_result.setVisible(true); } catch (FileNotFoundException ex) { Logger.getLogger(Manager_ReportController.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(Manager_ReportController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:cz.zcu.kiv.eegdatabase.logic.pdf.PDFUtils.java
License:Apache License
public Paragraph setHeader(Document document, String title) throws IOException, BadElementException { Paragraph paragraph = new Paragraph(title, FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD, BaseColor.BLACK)); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = GetResizedAndCenteredImage(path + convertPath("/files/images/" + HEADERIMG)); float topMargin = img.getHeight() + 2 * PADDING[0]; img.setAbsolutePosition(PADDING[3], (PageSize.A4.getHeight() - img.getHeight()) - PADDING[0]); paragraph.add(img);// w w w .j a v a 2s.co m img = GetResizedAndCenteredImage(path + convertPath("/files/images/" + FOOTERIMG)); img.setAbsolutePosition((PageSize.A4.getWidth() - img.getWidth()) / 2, PADDING[2]); paragraph.add(img); float bottomMargin = img.getHeight() + 2 * PADDING[2]; document.setMargins(topMargin, PADDING[1], bottomMargin, PADDING[3]); paragraph.setSpacingAfter(1.5f * PADDING[0]); return paragraph; }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
public PDFDocument(String authorName, Map<String, Integer> yearToPublicationCount, Document document, PdfWriter pdfWriter) {/*from www .j a va 2s .c om*/ // setPreferredSize(new Dimension(600,400)); try { document.addTitle("PDF Pipeline iText Prototype"); document.addAuthor(authorName); document.addSubject("This example tests text, color, image, transparency & table functionality."); document.addKeywords("text, color, image, transparency, table"); document.addCreator("Standalone PDF Renderer using iText"); Paragraph header = new Paragraph(); Font pageHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLDITALIC | Font.UNDERLINE); Font featureHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, new BaseColor(Color.red)); header.add(new Chunk("PDF Pipeline Prototype v2 using iText\n", pageHeaderStyle)); header.setSpacingAfter(15f); document.add(header); Paragraph content = new Paragraph(); content.add(new Chunk("Publication Count - Author Name - " + authorName, featureHeaderStyle)); content.setSpacingAfter(15f); document.add(content); // step4 PdfPTable publicationCount = createTable(yearToPublicationCount); document.add(publicationCount); content = new Paragraph(); content.add(new Chunk("Transparency of Shapes", featureHeaderStyle)); content.setSpacingAfter(15f); document.add(content); createTransparencyShapes(document, pdfWriter); createImage(document, pdfWriter, featureHeaderStyle); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:edu.harvard.mcz.precapture.ui.ContainerLabel.java
License:Open Source License
/** * /* ww w . ja v a 2 s. c o 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 {// w w w . j a va2 s .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 {/*from ww w .jav a2 s .com*/ //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 getDefaultParagraph() { Paragraph result = new Paragraph(); result.setFont(CONTENT_NORMAL);//from w ww .j a v a 2 s . c om result.setAlignment(Element.ALIGN_JUSTIFIED); result.setSpacingAfter(result.getFont().getSize() * 1.5f); return result; }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java
License:Open Source License
protected Phrase getDefaultPhrase() { Paragraph result = new Paragraph(); result.setFont(CONTENT_NORMAL);/*from w ww. ja va 2 s .c o m*/ result.setAlignment(Element.ALIGN_JUSTIFIED); result.setSpacingAfter(result.getFont().getSize() * 1.5f); return result; }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java
License:Open Source License
protected Paragraph getChapterTitleParagraph(String title) { Paragraph result = new Paragraph(title, CHAPTER); result.setSpacingAfter(15); return result; }