List of usage examples for com.lowagie.text Paragraph add
public boolean add(Object o)
Object
to the Paragraph
. From source file:Agenda.java
public void preparaPDF(Object document) throws IOException, BadElementException, DocumentException { //criando novo pdf Document pdf = (Document) document; //abrindo documento pdf.open();//from w ww . j ava2s .c om //modificando caracteristicas do documento pdf.setPageSize(PageSize.A4); // //VERSAO FUNCIONAL // //criando paragrafo no texto // Paragraph p = new Paragraph("Relatrio Contatos", // //editando configuracoes de fontes do texto // FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255,150,255))); // // //definindo alinhamento // p.setAlignment(Element.ALIGN_CENTER); // // //adiciona as modificaes ao documento // pdf.add(p); //VERSAO CORRETA Paragraph p = new Paragraph(); p.setFont(FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255, 255, 0))); p.add(new Phrase("Relatrio Contatos")); p.setAlignment(Element.ALIGN_CENTER); pdf.add(p); }
From source file:EmailWithPdf.java
/** * Writes the content of a PDF file (using iText API) * to the {@link OutputStream}./*from w w w .j a v a 2 s . co m*/ * @param outputStream {@link OutputStream}. * @throws Exception */ public void writePdf(OutputStream outputStream) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, outputStream); document.open(); document.addTitle("Test PDF"); document.addSubject("Testing email PDF"); document.addKeywords("iText, email"); document.addAuthor("Jee Vang"); document.addCreator("Jee Vang"); Paragraph paragraph = new Paragraph(); paragraph.add(new Chunk("hello!")); paragraph.add(new Chunk("hello!")); paragraph.add(new Chunk("hello!")); paragraph.add(new Chunk("hello!")); paragraph.add(new Chunk("hello!")); paragraph.add(new Chunk("hello!")); paragraph.add(new Chunk("hello!")); paragraph.add(new Chunk("hello!")); paragraph.add(new Chunk("hello!")); document.add(paragraph); document.close(); }
From source file:FirstPdf.java
private static void addTitlePage(Document document) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);/*w w w . j a v a 2s .c o m*/ // Lets write a big header preface.add(new Paragraph("Title of the document", catFont)); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(preface, 3); preface.add(new Paragraph("This document describes something which is very important ", smallBold)); addEmptyLine(preface, 8); preface.add(new Paragraph( "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.de ;-).", redFont)); document.add(preface); // Start a new page document.newPage(); }
From source file:FirstPdf.java
private static void addEmptyLine(Paragraph paragraph, int number) { for (int i = 0; i < number; i++) { paragraph.add(new Paragraph(" ")); }/*from w w w .j av a2s . co m*/ }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private Paragraph createTinyParagraph(String title, String data) { Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 2); p.add(new Chunk(title, new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL))); p.add(new Chunk(data, new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 10, com.lowagie.text.Font.BOLD))); return p;/*from ww w .j av a2s . c om*/ }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsAddSvg(Airport airport, PdfWriter writer, Document document, String imageFileName) { // FREQs Nearest Navaid notifyAction("createSheetsAddSvg"); PdfPTable table = new PdfPTable(1); {/*from ww w . j av a 2 s . c o m*/ PdfPCell cell = new PdfPCell(); cell.setMinimumHeight(height); { Paragraph p = new Paragraph(); com.lowagie.text.Font fontWarning = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.BOLD); p.add(new Chunk(" ", fontWarning)); cell.addElement(p); } cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsFakeShops(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsFakeShops"); PdfPTable table = new PdfPTable(1); {//from w ww .ja v a 2 s . c om PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setMinimumHeight(20); boolean addWorker = false; for (final Runway runway : airport.getRunways()) { if (runway.getLength() > 1200 / FEET_PER_METER) { addWorker = true; } } boolean addFork = (airport.hasTower()); Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 4); if (addWorker) { try { p.add(new Chunk(" ")); p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "avail_work.png")), 0, -3)); } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } } if (addFork) { try { p.add(new Chunk(" ")); p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "avail_fork.png")), 0, -3)); } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } } cell.addElement(p); //cell.setBorder(com.lowagie.text.Rectangle.NO_BORDER); cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsLights(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsLights"); PdfPTable table = new PdfPTable(1); {/*ww w .j a v a 2s . co m*/ PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setMinimumHeight(20); Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 4); com.lowagie.text.Font font = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 10, com.lowagie.text.Font.NORMAL); oneLightDone = false; try { p.add(new Chunk(" ", font)); p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "light.png")), 0, 0)); p.add(new Chunk(" ", font)); } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } boolean addABN = airport.hasBeacon(); if (addABN) { p.add(addOneLight("ABN", font)); } boolean addALS = false; boolean addPAPI = false; for (final Runway runway : airport.getRunways()) { if ((runway.hasALSF_I(false) || runway.hasALSF_I(true)) || (runway.hasALSF_II(false) || runway.hasALSF_II(true))) { addALS = true; } if ((runway.hasPapi(false) || runway.hasPapi(true))) { addPAPI = true; } } if (addALS) { p.add(addOneLight("ALS", font)); } if (addPAPI) { p.add(addOneLight("PAPI ", font)); String separ = ""; for (final Runway runway : airport.getRunways()) { if (runway.hasPapi(false)) { p.add(new Chunk(separ + runway.getNumber() + " (3.5)" + degrees + " ", font)); separ = ", "; } if (runway.hasPapi(true)) { p.add(new Chunk(separ + runway.getOppositeNumber() + " (3.5)" + degrees + " ", font)); separ = ", "; } } } cell.addElement(p); //cell.setBorder(com.lowagie.text.Rectangle.NO_BORDER); cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsRunways(Airport airport, Document document) { notifyAction("createSheetsRunways"); PdfPTable table = new PdfPTable(6); // titles/*from w w w.ja v a 2 s. c om*/ com.lowagie.text.Font fontTitle = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL); { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidth); Paragraph p = new Paragraph("RWY N" + degrees, fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("Dimension (ft) - Surface", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("TORA (ft)", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("LDA (ft)", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("Strength", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(borderWidth); cell.setBorderWidthBottom(borderWidthThin); cell.setBorderWidthRight(borderWidth); cell.setBorderWidthLeft(borderWidthThin); Paragraph p = new Paragraph("Lights", fontTitle); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } // data com.lowagie.text.Font fontData = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 10, com.lowagie.text.Font.NORMAL); int rc = 0; for (final Runway runway : airport.getRunways()) { { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidth); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); Paragraph p = new Paragraph(runway.getNumber() + "\r\n" + runway.getOppositeNumber(), fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); String runwayLength = new Integer(runway.getLength()).toString() + " x " + new Integer(runway.getWidth()).toString() + " " + runway.getSurfaceName(); Paragraph p = new Paragraph(runwayLength, fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); Paragraph p = new Paragraph(runway.getLength() + "\r\n" + runway.getLength(), fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); Paragraph p = new Paragraph((runway.getLength() - runway.getDisplacement()) + "\r\n" + (runway.getLength() - runway.getDisplacementOpposite()), fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } cell.setBorderWidthRight(borderWidthThin); Paragraph p = new Paragraph("to do...", fontData); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthLeft(borderWidthThin); cell.setBorderWidthRight(borderWidth); if (rc < airport.getRunways().size() - 1) { // thin bottom if not last runway cell.setBorderWidthBottom(borderWidthThin); } else { cell.setBorderWidthBottom(borderWidth); } Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 2); p.setAlignment(Element.ALIGN_CENTER); try { if (runway.hasALSF_I(true) || runway.hasALSF_I(false) || runway.hasALSF_II(true) || runway.hasALSF_II(false) || runway.hasPapi(true) || runway.hasPapi(false) || runway.hasSALSF(true) || runway.hasSALSF(false) || runway.hasSSLP(true) || runway.hasSSLP(false) || runway.hasVasi(true) || runway.hasVasi(false)) { p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "light.png")), 0, 0)); } else { p.add(new Chunk("--", fontData)); } } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } cell.addElement(p); table.addCell(cell); } rc++; } float[] widths2 = { 1f, 2f, 1f, 1f, 2f, 1f }; try { table.setWidths(widths2); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsNotes(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsNotes"); PdfPTable table = new PdfPTable(1); {/*from w ww.jav a2 s .c o m*/ PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); { Paragraph p = new Paragraph(); com.lowagie.text.Font fontWarning = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.BOLD); p.add(new Chunk("Warning !", fontWarning)); cell.addElement(p); } { Paragraph p = new Paragraph(); com.lowagie.text.Font fontText = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.NORMAL); p.add(new Chunk( "Do not use this chart in real life, this is a chart suitable to be used only for FlightGear !!!", fontText)); cell.addElement(p); } cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }