List of usage examples for com.itextpdf.text Phrase Phrase
private Phrase(final boolean dummy)
From source file:fr.ensicaen.yousign.GenerePDF.java
private Paragraph addEntete() { Paragraph paragraph = new Paragraph(); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100);/*from w w w . ja va 2s . co m*/ try { // // Affichage du logo // PdfPCell logoCell = new PdfPCell(Image.getInstance(YousignConfig.LOGO), false); // false: le logo ne remplit pas toute la cellule logoCell.setBorder(Rectangle.NO_BORDER); table.addCell(logoCell); // // Affichage de la date et du titre // Date date = new Date(); DateFormat format_fr = DateFormat.getDateInstance(DateFormat.FULL, Locale.FRENCH); PdfPCell titleCell = new PdfPCell(new Phrase( new Chunk(format_fr.format(date) + "\n\n" + title + util.getOrdreMission().getNumeroMission() + "\n" + util.getOrdreMission().getFrais(), fontItemTitleSection))); titleCell.setBorder(Rectangle.NO_BORDER); titleCell.setHorizontalAlignment(Element.ALIGN_CENTER); titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(titleCell); } catch (BadElementException | IOException ex) { Logger.getLogger(GenerePDF.class.getName()).log(Level.SEVERE, null, ex); } paragraph.add(table); return paragraph; }
From source file:fr.pigouchet.gestion.util.GeneratePdf.java
public static PdfPTable oneCategory(Categorie category) throws DocumentException { PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100);// ww w. ja v a 2 s . com table.setWidths(new int[] { 1, 2, 1, 1, 1 }); dataSubCate = Connection.listCategoryToSubCategory(category); for (SubCategorie subcategorie : dataSubCate) { PdfPCell cell; if (passed == true) { cell = new PdfPCell(new Phrase(" ")); cell.setColspan(5); table.addCell(cell); } cell = new PdfPCell(new Phrase(category.getNom(), subFont)); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase(subcategorie.getNom(), subFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Code", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Nom", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Achat", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Artisant", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Detail", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); data = Connection.listSubCategoryToProduit(subcategorie); for (Produit produit1 : data) { cell = new PdfPCell(new Phrase(produit1.getCode(), smallFont)); table.addCell(cell); cell = new PdfPCell(new Phrase(produit1.getNom(), smallFont)); table.addCell(cell); cell = new PdfPCell(new Phrase(produit1.getPriceAchat(), smallFont)); table.addCell(cell); cell = new PdfPCell(new Phrase(produit1.getPriceArtisant(), smallFont)); table.addCell(cell); cell = new PdfPCell(new Phrase(produit1.getPriceDetail(), smallFont)); table.addCell(cell); } passed = true; } return table; }
From source file:fr.pigouchet.gestion.util.GeneratePdf.java
public static PdfPTable allSubCategory(Categorie categorie, Document document) throws DocumentException { PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100);/*ww w .j av a 2 s . co m*/ table.setWidths(new int[] { 1, 2, 1, 1, 1 }); dataSubCate = Connection.listCategoryToSubCategory(categorie); for (SubCategorie subcategorie : dataSubCate) { PdfPCell cell; if (passed == true) { cell = new PdfPCell(new Phrase(" ")); cell.setColspan(5); table.addCell(cell); } cell = new PdfPCell(new Phrase(categorie.getNom(), subFont)); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase(subcategorie.getNom(), subFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Code", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Nom", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Achat", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Artisant", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Detail", smallFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); data = Connection.listSubCategoryToProduit(subcategorie); for (Produit produit1 : data) { cell = new PdfPCell(new Phrase(produit1.getCode(), smallFont)); table.addCell(cell); cell = new PdfPCell(new Phrase(produit1.getNom(), smallFont)); table.addCell(cell); cell = new PdfPCell(new Phrase(produit1.getPriceAchat(), smallFont)); table.addCell(cell); cell = new PdfPCell(new Phrase(produit1.getPriceArtisant(), smallFont)); table.addCell(cell); cell = new PdfPCell(new Phrase(produit1.getPriceDetail(), smallFont)); table.addCell(cell); } passed = true; } return table; }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
public void render() throws DocumentException, IOException { // Footer/*from ww w. java2 s. c o m*/ pdfWriter.setPageEvent(new PdfPageEventHelper() { @Override public void onEndPage(PdfWriter writer, Document document) { if (writer.getPageNumber() > 1) { Rectangle rect = document.getPageSize(); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase("BreizhCamp 2014"), (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() + 18, 0); } } }); createFirstPage(); List<Talk> talksToExplain = createProgrammePages(); createTalksPages(talksToExplain); }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private PdfPCell createHeaderCell(String content) { Paragraph paragraph = new Paragraph(); Font font = new Font(); font.setColor(BaseColor.WHITE);/*from w ww. ja v a2 s . c om*/ paragraph.setFont(font); paragraph.add(new Phrase(content)); PdfPCell cell = new PdfPCell(paragraph); cell.setPaddingBottom(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.GRAY); return cell; }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private PdfPTable createBeginningOfPage(Font font, String date) throws DocumentException { Paragraph titre;/* w ww.j a v a 2 s. c o m*/ document.newPage(); titre = new Paragraph(); titre.setFont(font); titre.setAlignment(Paragraph.ALIGN_CENTER); titre.add(new Phrase("Programme du " + date)); document.add(titre); float[] relativeWidth = new float[service.getRooms(date).size() + 1]; Arrays.fill(relativeWidth, 1f); relativeWidth[0] = 0.5f; PdfPTable table = new PdfPTable(relativeWidth); table.setWidthPercentage(100); table.setSpacingBefore(10); table.setSpacingAfter(20); table.addCell(createHeaderCell("Heure")); for (String room : service.getRooms(date)) { table.addCell(createHeaderCell(room)); } return table; }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private void createTalksPages(List<Talk> talksToExplain) throws DocumentException, IOException { document.setPageSize(PageSize.A4);/* w w w. j a v a2 s . co m*/ document.newPage(); Paragraph paragraph = new Paragraph("Liste des talks"); paragraph.setSpacingAfter(25); paragraph.getFont().setSize(25); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); for (TalkDetail talk : Lists.transform(talksToExplain, new Function<Talk, TalkDetail>() { @Override public TalkDetail apply(Talk input) { return TalkService.INSTANCE.getTalkDetail(input); } })) { if (talk == null) { continue; } Paragraph empty = new Paragraph(" "); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); table.setKeepTogether(true); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); PdfPCell cell; Chunk titleTalk = new Chunk(talk.getTitle(), talkFontTitle); titleTalk.setLocalDestination("talk" + talk.getId()); float[] withTitle = { 0.05f, 0.95f }; PdfPTable titleWithFormat = new PdfPTable(withTitle); titleWithFormat.getDefaultCell().setBorder(Rectangle.NO_BORDER); titleWithFormat.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); Image image = AvatarService.INSTANCE.getImage(PdfRenderer.class .getResource("/formats/" + talk.getTalk().getFormat().replaceAll(" ", "") + ".png")); titleWithFormat.addCell(image); titleWithFormat.addCell(new Paragraph(titleTalk)); table.addCell(titleWithFormat); table.addCell(empty); table.addCell(new Paragraph("Salle " + talk.getTalk().getRoom() + " de " + talk.getTalk().getStart() + " " + talk.getTalk().getEnd(), presentFont)); table.addCell(empty); cell = new PdfPCell(); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); for (Element element : HTMLWorker .parseToList(new StringReader(markdownProcessor.markdown(talk.getDescription())), null)) { if (element instanceof Paragraph) { ((Paragraph) element).setAlignment(Element.ALIGN_JUSTIFIED); } cell.addElement(element); } table.addCell(cell); table.addCell(empty); table.addCell(new Paragraph("Prsent par :", presentFont)); float[] widthSpeaker = { 0.05f, 0.95f }; for (Speaker speaker : talk.getSpeakers()) { PdfPTable speakerWithAvatar = new PdfPTable(widthSpeaker); speakerWithAvatar.getDefaultCell().setBorder(Rectangle.NO_BORDER); speakerWithAvatar.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); speakerWithAvatar.addCell(AvatarService.INSTANCE.getImage(speaker.getAvatar())); speakerWithAvatar.addCell(new Phrase(speaker.getFullname())); table.addCell(speakerWithAvatar); } table.addCell(empty); table.addCell(empty); document.add(table); } }
From source file:fr.ybonnel.breizhcamppdf.RoomPdfRenderer.java
License:Apache License
private PdfPTable createBeginningOfPage(Font font, String date, String room) throws DocumentException { Paragraph titre;/* w ww . jav a2 s . c o m*/ document.newPage(); titre = new Paragraph(); titre.setFont(font); titre.setAlignment(Paragraph.ALIGN_CENTER); titre.add(new Phrase("Programme du " + date + " - " + room)); titre.setSpacingAfter(20); document.add(titre); float[] relativeWidth = new float[2]; Arrays.fill(relativeWidth, 1f); relativeWidth[0] = 0.2f; PdfPTable table = new PdfPTable(relativeWidth); table.setWidthPercentage(100); table.setSpacingBefore(10); table.setSpacingAfter(20); table.addCell(createHeaderCell("Heure")); table.addCell(createHeaderCell("")); return table; }