List of usage examples for com.itextpdf.text Paragraph add
@Override public boolean add(Element o)
Element
to the Paragraph
. From source file:pdf.CoverLetterUtility.java
License:Apache License
private void addWhyMe(Document document) { TitlePhrase title = new TitlePhrase("Why Me", LifetimeFonts.FONT_BOLD); ValuePhrase text = new ValuePhrase(letter.getWhyMe(), LifetimeFonts.FONT_DEFAULT); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED); //current.setSpacingBefore(10f); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE);/*from w w w. j av a 2s. c om*/ paragraph.add(title); paragraph.add(Chunk.NEWLINE); paragraph.add(text); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE); try { document.add(paragraph); } catch (DocumentException ex) { Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:pdf.CoverLetterUtility.java
License:Apache License
private void addWhyYou(Document document) { TitlePhrase title = new TitlePhrase("Why You", LifetimeFonts.FONT_BOLD); ValuePhrase text = new ValuePhrase(letter.getWhyYou(), LifetimeFonts.FONT_DEFAULT); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED); //current.setSpacingBefore(10f); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE);/* www . j a v a 2 s.com*/ paragraph.add(title); paragraph.add(Chunk.NEWLINE); paragraph.add(text); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE); try { document.add(paragraph); } catch (DocumentException ex) { Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:pdf.CoverLetterUtility.java
License:Apache License
private void addConclusion(Document document) { TitlePhrase title = new TitlePhrase("Conclusion", LifetimeFonts.FONT_BOLD); ValuePhrase text = new ValuePhrase(letter.getConclusion(), LifetimeFonts.FONT_DEFAULT); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED); //current.setSpacingBefore(10f); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE);/*from w ww . ja v a2s . c o m*/ paragraph.add(title); paragraph.add(Chunk.NEWLINE); paragraph.add(text); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE); try { document.add(paragraph); } catch (DocumentException ex) { Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:PDF.GenerateReportActivities.java
private void addEncabezado(Document document) throws DocumentException { Paragraph preface = new Paragraph(); addEmptyLine(preface, 4);// w ww .j a va 2 s .com preface.setAlignment(Element.ALIGN_CENTER); preface.add(new Paragraph("Instituto Politcnico Nacional", catFont)); preface.add(new Paragraph("Comisin de Operacin y Fomento de Actividades" + " Acadmicas (COFAA)\n Direccin de Especializacin Docente e Investigacin Cientfica y " + "Tecnolgica\nE-SIBE", smallBold)); addEmptyLine(preface, 2); document.add(preface); }
From source file:PDF.GenerateReportActivities.java
private void addResumenProf(Document document) throws DocumentException, Exception { Paragraph preface = new Paragraph(); preface.add(new Paragraph("Datos Generales del Profesor", smallBold)); preface.setAlignment(Element.ALIGN_CENTER); addEmptyLine(preface, 2);/*from ww w . j a v a 2 s.c o m*/ document.add(preface); document.add(TablaDatos()); }
From source file:PDF.GenerateReportActivities.java
private void addEmptyLine(Paragraph paragraph, int number) { for (int i = 0; i < number; i++) { paragraph.add(new Paragraph(" ")); }/*w w w.j av a 2 s .c om*/ }
From source file:pdf.PdfBuilder.java
/** * Creates an accessible PDF with images and text. * @param dest the path to the resulting PDF * @throws IOException/*from w ww.j av a 2s . c om*/ * @throws DocumentException */ public String createPdf(Invoice invoice) throws IOException, DocumentException { DEST = "C://temp/"; SimpleDateFormat sdf = new SimpleDateFormat("MM"); DEST += invoice.getCar().getId() + "month" + sdf.format(invoice.getSeriesOfLocationsOnRoad().get(0).getLocations().get(0).getDate()) + ".pdf"; File file = new File(DEST); file.getParentFile().mkdirs(); Document document = new Document(PageSize.A4.rotate()); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(DEST)); writer.setPdfVersion(PdfWriter.VERSION_1_7); //TAGGED PDF //Make document tagged writer.setTagged(); //=============== //PDF/UA //Set document metadata writer.setViewerPreferences(PdfWriter.DisplayDocTitle); document.addLanguage("en-US"); document.addTitle("Factuur voor auto " + invoice.getCar().getLicensePlate()); writer.createXmpMetadata(); //===================== document.open(); Font font = FontFactory.getFont(FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 20); double amountPaidForDistance = invoice.getTotalAmount(); double amountPaidForCordons = 0; for (Cordon c : invoice.getCordonOccurrences()) { amountPaidForDistance -= c.getAmount(); amountPaidForCordons += c.getAmount(); } Paragraph p = new Paragraph("\n", font); p.add(new Chunk("Aantal gereden kilometers:")); p.add(new Chunk("\n")); p.add(new Chunk(String.valueOf(invoice.getTotalDistance()) + " kilometer")); p.add(new Chunk("\n")); p.add(new Chunk("Met een gemiddeld tarief van " + (amountPaidForDistance / invoice.getTotalDistance() * 100) + " eurocent per kilometer")); p.add(new Chunk("\n")); p.add(new Chunk("Bedrag dat betaald dient te worden over de kilometers: ")); p.add(new Chunk("\n")); p.add(new Chunk(amountPaidForDistance + " euro")); document.add(p); p = new Paragraph("\n\n", font); p.add(new Chunk(invoice.cordonOccurrencesString())); p.add(new Chunk("\n")); p.add(new Chunk("Bedrag dat betaald dient te worden over de cordons: ")); p.add(new Chunk("\n")); p.add(new Chunk(amountPaidForCordons + " euro")); document.add(p); p = new Paragraph("\n\n", font); p.add(new Chunk("Totaal bedrag dat betaald dient te worden: ")); p.add(new Chunk("\n")); p.add(new Chunk(String.valueOf(invoice.getTotalAmount()) + " euro")); document.add(p); document.close(); return DEST; }
From source file:pdf.PdfCreator.java
public String createPdf(String path, String ingredients, String recipeTitle, String recipeDescription) throws DocumentException, IOException { path += "shoppingList.pdf"; Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();//from w w w .j a va 2s . c o m String[] ings = ingredients.split(";"); PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(); cb.beginText(); Paragraph p = new Paragraph("Ingredients you'll need to buy:", new Font(FontFamily.HELVETICA, 20, Font.BOLD, new BaseColor(38, 165, 154))); p.add(Chunk.NEWLINE); document.add(p); cb.moveText(36, 750); cb.setFontAndSize(bf, 15); cb.endText(); p = new Paragraph(); for (String str : ings) { p.add(" "); p.add(str); p.add(Chunk.NEWLINE); } p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); document.add(p); p = new Paragraph(recipeTitle, new Font(FontFamily.HELVETICA, 20, Font.BOLD, new BaseColor(38, 165, 154))); p.add(Chunk.NEWLINE); document.add(p); p = new Paragraph(recipeDescription, new Font(bf, 12)); p.add(Chunk.NEWLINE); document.add(p); document.close(); return path; }
From source file:pdf.PDFdescriptiva.java
private static void agregarTitulo(Document documento, String titulo) throws DocumentException { Paragraph preface = new Paragraph(); // Agregamos una linea vacia addEmptyLine(preface, 1);/* w w w .ja va2 s . c o m*/ // Escribimos el titulo preface.add(new Paragraph(titulo, catFont)); addEmptyLine(preface, 2); preface.add(new Paragraph( "A continuacion se presenta el desarrollo para la estadistica descriptiva, se muestra la tabla con las operaciones necesarias y algunas variables de gran importancia.", smallBold)); addEmptyLine(preface, 1); documento.add(preface); }
From source file:pdf.PDFDesign.java
public PdfPTable createPriceTable(List<Item> itemList) throws DocumentException, IOException { PdfPTable table = new PdfPTable(nColumns); table.setWidthPercentage(100.0f);// w ww. ja v a2 s. c o m //PdfContentByte cb = writer.getDirectContent(); for (int i = 0; i < itemList.size(); i++) { Item item = itemList.get(i); //cell.setBorder(0); //BarcodeEAN code = new BarcodeEAN(); //code.setCode(item.getBarCode()); //code.setGuardBars(false); //Image im = code.createImageWithBarcode(cb, BaseColor.BLACK, BaseColor.BLACK); //p.add(im);//new Chunk(im,0.5f,0.5f)); PdfPTable innerTable = new PdfPTable(1); Paragraph p1 = new Paragraph(); p1.setFont(titleLineFont); String t = item.getTitle(); String[] split = t.split("//"); //System.out.println(t); for (String split1 : split) { p1.add(split1 + "\n"); } PdfPCell innercCell1 = new PdfPCell(p1); innercCell1.setLeading(11f, 0f); innercCell1.setBorder(0); if (t.contains("//") && (size.equals("4x6") || size.equals("4x7") || size.equals("5x6") || size.equals("5x7"))) { innercCell1.setFixedHeight(titleLineFixedHeight); } else { innercCell1.setFixedHeight(15.0f); } //innercCell1.setFixedHeight(titleLineFixedHeight); innercCell1.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p2 = new Paragraph(); p2.setFont(amountAndPriceLabelLineFont); p2.add("Mnostv: " + item.getAmount() + item.getUnit() + "\n"); PdfPCell innercCell2 = new PdfPCell(p2); innercCell2.setLeading(5f + textFontInc, 0f); innercCell2.setBorder(0); innercCell2.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p3 = new Paragraph(); p3.setFont(bigPriceNumberFont); p3.add(item.getPrice().substring(0, item.getPrice().length() - 3)); p3.setFont(decimalPriceNumberFont); p3.add(item.getPrice().substring(item.getPrice().length() - 3, item.getPrice().length())); p3.setFont(unitPriceLineFont); p3.add(item.getCurrency()); PdfPCell innercCell3 = new PdfPCell(p3); if (styleName.equals("style6") /*&& (size.equals("4x7") || size.equals("4x6"))*/) { innercCell3 = new PdfPCell(createLine3Table(item, 45 + priceFontInc, 20, 15)); } innercCell3.setBorder(0); innercCell3.setLeading(bigPriceNumberLeading, 0f); innercCell3.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p4 = new Paragraph(); p4.setFont(unitPriceLineFont); p4.add("Cena za " + item.getXAmount() + item.getXUnit() + ": " + item.getUnitPrice() + " " + item.getCurrency()); PdfPCell innercCell4 = new PdfPCell(p4); innercCell4.setBorder(0); innercCell4.setLeading(5f + textFontInc, 0f); innercCell4.setHorizontalAlignment(Element.ALIGN_CENTER); innerTable.addCell(innercCell1); innerTable.addCell(innercCell2); innerTable.addCell(innercCell3); innerTable.addCell(innercCell4); PdfPCell cell = new PdfPCell(innerTable); cell.setFixedHeight(cellHeight); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderColor(BaseColor.GRAY); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } int remainder = itemList.size() % nColumns; if (remainder != 0) { remainder = nColumns - remainder; } for (int i = 0; i < remainder; i++) { PdfPCell c = new PdfPCell(new Phrase(" ")); c.setBorderColor(BaseColor.GRAY); table.addCell(c); } return table; }