List of usage examples for com.lowagie.text Rectangle BOTTOM
int BOTTOM
To view the source code for com.lowagie.text Rectangle BOTTOM.
Click Source Link
Rectangle
. From source file:dinamica.AbstractPDFOutput.java
License:LGPL
/** * Receives a byte buffer that should be filled with resulting PDF. * @param data Data module that provides recordsets to this output module * @param buf Buffer to print PDF, then used to send to browser * @throws Throwable//w w w .jav a2 s . c o m */ protected void createPDF(GenericTransaction data, ByteArrayOutputStream buf) throws Throwable { //pdf objects Document doc = new Document(); PdfWriter docWriter = PdfWriter.getInstance(doc, buf); //header HeaderFooter header = new HeaderFooter(new Phrase(getHeader()), false); header.setBorder(Rectangle.BOTTOM); header.setAlignment(Rectangle.ALIGN_CENTER); doc.setHeader(header); //footer HeaderFooter footer = new HeaderFooter(new Phrase(getFooter()), true); footer.setBorder(Rectangle.TOP); footer.setAlignment(Rectangle.ALIGN_RIGHT); doc.setFooter(footer); //pagesize doc.setPageSize(PageSize.LETTER); doc.open(); //title Paragraph t = new Paragraph(getReportTitle(), new Font(Font.HELVETICA, 18f)); t.setAlignment(Rectangle.ALIGN_CENTER); doc.add(t); //paragraph Paragraph p = new Paragraph("Hello World"); p.setAlignment(Rectangle.ALIGN_CENTER); doc.add(p); doc.close(); docWriter.close(); }
From source file:etc.Exporter.java
License:Open Source License
public static void saveAsPDF(File file, Task task) { try {/*from w w w . j ava 2 s . co m*/ Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); Paragraph taskid = new Paragraph("ID e Detyres: " + task.getIdentifier(), FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)); document.add(taskid); Paragraph creator = new Paragraph("Krijuar nga " + task.getCreator().toString() + "[" + task.getCreationTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy - HH.mm")) + "]", FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)); document.add(creator); Paragraph executor = new Paragraph("Per zbatim prej: " + task.getExecutor().toString(), FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)); document.add(executor); Paragraph title = new Paragraph(task.getTitle().toUpperCase(), FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD)); document.add(title); Paragraph description = new Paragraph(task.getDescription(), FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)); document.add(description); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.BOTTOM); PdfPTable table = new PdfPTable(1); table.addCell(cell); table.setWidthPercentage(100f); document.add(table); if (task instanceof dc.CompletedTask) { document.add(new Paragraph( "Gjendja: Perfunduar [" + ((dc.CompletedTask) task).getCompletitionTime() .format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm")) + "]", FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC))); document.add(new Paragraph("Shenimet e Zbatuesit".toUpperCase(), FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD))); document.add(new Paragraph(((dc.CompletedTask) task).getAnnotations(), FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL))); } else if (task instanceof dc.RejectedTask) { document.add(new Paragraph( "Gjendja: Refuzuar [" + ((dc.RejectedTask) task).getRejectionTime() .format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm")) + "]", FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC))); document.add(new Paragraph("Shenimet e Zbatuesit".toUpperCase(), FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD))); document.add(new Paragraph(((dc.RejectedTask) task).getAnnotations(), FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL))); } else { document.add(new Paragraph("Gjendja: Ne Pritje", FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC))); } document.close(); Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file.getAbsolutePath()); p.waitFor(); } catch (DocumentException | InterruptedException | IOException ex) { Logger.getLogger(Exporter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableParagraphWrapper.java
License:Open Source License
public void applyStyles(Style style) { this.lastStyleApplied = style; StyleParagraphProperties paragraphProperties = style.getParagraphProperties(); if (paragraphProperties != null) { // margins Float margin = paragraphProperties.getMargin(); if (margin != null && margin > 0.0f) { super.setIndentationLeft(margin); super.setIndentationRight(margin); super.setSpacingBefore(margin); super.setSpacingAfter(margin); }//w w w . j a v a2s. c om Float marginLeft = paragraphProperties.getMarginLeft(); if (marginLeft != null && marginLeft > 0.0f) { super.setIndentationLeft(marginLeft); } Float marginRight = paragraphProperties.getMarginRight(); if (marginRight != null && marginRight > 0.0f) { super.setIndentationRight(marginRight); } Float marginTop = paragraphProperties.getMarginTop(); if (marginTop != null && marginTop > 0.0f) { super.setSpacingBefore(marginTop); } Float marginBottom = paragraphProperties.getMarginBottom(); if (marginBottom != null && marginBottom > 0.0f) { super.setSpacingAfter(marginBottom); } // background color Color backgroundColor = paragraphProperties.getBackgroundColor(); if (backgroundColor != null && !TRANSPARENT_COLOR.equals(backgroundColor)) { getWrapperCell().setBackgroundColor(backgroundColor); } // borders StyleBorder border = paragraphProperties.getBorder(); if (border != null && !border.isNoBorder()) { StyleUtils.applyStyles(border, getWrapperCell()); } StyleBorder borderLeft = paragraphProperties.getBorderLeft(); if (borderLeft != null && !borderLeft.isNoBorder()) { StyleUtils.applyStyles(borderLeft, getWrapperCell()); } StyleBorder borderRight = paragraphProperties.getBorderRight(); if (borderRight != null && !borderRight.isNoBorder()) { StyleUtils.applyStyles(borderRight, getWrapperCell()); } StyleBorder borderTop = paragraphProperties.getBorderTop(); if (borderTop != null && !borderTop.isNoBorder()) { StyleUtils.applyStyles(borderTop, getWrapperCell()); } StyleBorder borderBottom = paragraphProperties.getBorderBottom(); if (borderBottom != null && !borderBottom.isNoBorder()) { StyleUtils.applyStyles(borderBottom, getWrapperCell()); } // padding Float padding = paragraphProperties.getPadding(); if (padding != null && padding > 0.0f) { if (getWrapperCell().hasBorder(Rectangle.LEFT)) { getWrapperCell().setPaddingLeft(padding); } if (getWrapperCell().hasBorder(Rectangle.RIGHT)) { getWrapperCell().setPaddingRight(padding); } if (getWrapperCell().hasBorder(Rectangle.TOP)) { getWrapperCell().setPaddingTop(padding); } if (getWrapperCell().hasBorder(Rectangle.BOTTOM)) { getWrapperCell().setPaddingBottom(padding); } } Float paddingLeft = paragraphProperties.getPaddingLeft(); if (paddingLeft != null && paddingLeft > 0.0f) { if (getWrapperCell().hasBorder(Rectangle.LEFT)) { getWrapperCell().setPaddingLeft(paddingLeft); } } Float paddingRight = paragraphProperties.getPaddingRight(); if (paddingRight != null && paddingRight > 0.0f) { if (getWrapperCell().hasBorder(Rectangle.RIGHT)) { getWrapperCell().setPaddingRight(paddingRight); } } Float paddingTop = paragraphProperties.getPaddingTop(); if (paddingTop != null && paddingTop > 0.0f) { if (getWrapperCell().hasBorder(Rectangle.TOP)) { getWrapperCell().setPaddingTop(paddingTop); } } Float paddingBottom = paragraphProperties.getPaddingBottom(); if (paddingBottom != null && paddingBottom > 0.0f) { if (getWrapperCell().hasBorder(Rectangle.BOTTOM)) { getWrapperCell().setPaddingBottom(paddingBottom); } } // join border Boolean joinBorder = paragraphProperties.getJoinBorder(); if (joinBorder != null) { this.joinBorder = joinBorder; } // keep together on the same page Boolean keepTogether = paragraphProperties.getKeepTogether(); if (keepTogether != null) { super.setKeepTogether(keepTogether); } } }
From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableParagraph.java
License:Open Source License
public void setBorder(CTBorder border, int borderSide) { if (border == null) { return;// ww w. j a va 2 s . c o m } boolean noBorder = (STBorder.NONE == border.getVal() || STBorder.NIL == border.getVal()); // No border if (noBorder) { return; } else { // border size float size = -1; BigInteger borderSize = border.getSz(); if (borderSize != null) { // http://officeopenxml.com/WPtableBorders.php // if w:sz="4" => 1/4 points size = borderSize.floatValue() / 8f; } // border color fr.opensagres.poi.xwpf.converter.core.Color bdColor = ColorHelper.getBorderColor(border); Color borderColor = Converter.toAwtColor(bdColor); // border padding Float space = null; BigInteger borderSpace = border.getSpace(); if (borderSpace != null) { // Specifies the spacing offset. Values are specified in points (1/72nd of an inch). space = borderSpace.floatValue(); } switch (borderSide) { case Rectangle.TOP: if (size != -1) { this.setBorderWidthTop(size); } if (borderColor != null) { super.setBorderColorTop(borderColor); } if (space != null) { super.setBorderPaddingTop(space); } break; case Rectangle.BOTTOM: if (size != -1) { this.setBorderWidthBottom(size); } if (borderColor != null) { super.setBorderColorBottom(borderColor); } if (space != null) { super.setBorderPaddingBottom(space); } break; case Rectangle.LEFT: if (size != -1) { this.setBorderWidthLeft(size); } if (borderColor != null) { super.setBorderColorLeft(borderColor); } if (space != null) { super.setBorderPaddingLeft(space); } break; case Rectangle.RIGHT: if (size != -1) { this.setBorderWidthRight(size); } if (borderColor != null) { super.setBorderColorRight(borderColor); } if (space != null) { super.setBorderPaddingRight(space); } break; } } }
From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableTableCell.java
License:Open Source License
public void setBorderBottom(TableCellBorder borderBottom, boolean inside) { setBorder(borderBottom, inside, Rectangle.BOTTOM); }
From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableTableCell.java
License:Open Source License
public void setBorder(TableCellBorder border, boolean inside, int borderSide) { if (border == null || !border.hasBorder()) { this.disableBorderSide(borderSide); return;// w w w. j a va2 s . co m } Float borderSize = border.getBorderSize(); if (inside) { // manage conflict border // divide the border side by 2 to avoid multiply with 2 the border // this code simplify the "Conflicts between adjacent cells" // http://officeopenxml.com/WPtableCellBorderConflicts.php //borderSize = borderSize / 2; } Color borderColor = Converter.toAwtColor(border.getBorderColor()); switch (borderSide) { case Rectangle.TOP: if (borderSize != null) { this.setBorderWidthTop(borderSize); } if (borderColor != null) { this.setBorderColorTop(borderColor); } break; case Rectangle.BOTTOM: if (borderSize != null) { this.setBorderWidthBottom(borderSize); } if (borderColor != null) { this.setBorderColorBottom(borderColor); } break; case Rectangle.LEFT: if (borderSize != null) { this.setBorderWidthLeft(borderSize); } if (borderColor != null) { this.setBorderColorLeft(borderColor); } break; case Rectangle.RIGHT: if (borderSize != null) { this.setBorderWidthRight(borderSize); } if (borderColor != null) { this.setBorderColorRight(borderColor); } break; } }
From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.PdfMapper.java
License:Open Source License
@Override protected IITextContainer startVisitParagraph(XWPFParagraph docxParagraph, ListItemContext itemContext, IITextContainer pdfParentContainer) throws Exception { this.currentRunX = null; // create PDF paragraph StylableParagraph pdfParagraph = pdfDocument.createParagraph(pdfParentContainer); // indentation left Float indentationLeft = stylesDocument.getIndentationLeft(docxParagraph); if (indentationLeft != null) { pdfParagraph.setIndentationLeft(indentationLeft); }//from ww w. ja v a 2 s . c o m // indentation right Float indentationRight = stylesDocument.getIndentationRight(docxParagraph); if (indentationRight != null) { pdfParagraph.setIndentationRight(indentationRight); } // indentation first line Float indentationFirstLine = stylesDocument.getIndentationFirstLine(docxParagraph); if (indentationFirstLine != null) { pdfParagraph.setFirstLineIndent(indentationFirstLine); } // indentation hanging (remove first line) Float indentationHanging = stylesDocument.getIndentationHanging(docxParagraph); if (indentationHanging != null) { pdfParagraph.setFirstLineIndent(-indentationHanging); } // // spacing before Float spacingBefore = stylesDocument.getSpacingBefore(docxParagraph); if (spacingBefore != null) { pdfParagraph.setSpacingBefore(spacingBefore); } // spacing after Float spacingAfter = stylesDocument.getSpacingAfter(docxParagraph); if (spacingAfter != null) { pdfParagraph.setSpacingAfter(spacingAfter); } ParagraphLineSpacing lineSpacing = stylesDocument.getParagraphSpacing(docxParagraph); if (lineSpacing != null) { if (lineSpacing.getLeading() != null && lineSpacing.getMultipleLeading() != null) { pdfParagraph.setLeading(lineSpacing.getLeading(), lineSpacing.getMultipleLeading()); } else { if (lineSpacing.getLeading() != null) { pdfParagraph.setLeading(lineSpacing.getLeading()); } if (lineSpacing.getMultipleLeading() != null) { pdfParagraph.setMultipliedLeading(lineSpacing.getMultipleLeading()); } } } // text-align ParagraphAlignment alignment = stylesDocument.getParagraphAlignment(docxParagraph); if (alignment != null) { switch (alignment) { case LEFT: pdfParagraph.setAlignment(Element.ALIGN_LEFT); break; case RIGHT: pdfParagraph.setAlignment(Element.ALIGN_RIGHT); break; case CENTER: pdfParagraph.setAlignment(Element.ALIGN_CENTER); break; case BOTH: pdfParagraph.setAlignment(Element.ALIGN_JUSTIFIED); break; default: break; } } // background-color Color backgroundColor = stylesDocument.getBackgroundColor(docxParagraph); if (backgroundColor != null) { pdfParagraph.setBackgroundColor(Converter.toAwtColor(backgroundColor)); } // border CTBorder borderTop = stylesDocument.getBorderTop(docxParagraph); pdfParagraph.setBorder(borderTop, Rectangle.TOP); CTBorder borderBottom = stylesDocument.getBorderBottom(docxParagraph); pdfParagraph.setBorder(borderBottom, Rectangle.BOTTOM); CTBorder borderLeft = stylesDocument.getBorderLeft(docxParagraph); pdfParagraph.setBorder(borderLeft, Rectangle.LEFT); CTBorder borderRight = stylesDocument.getBorderRight(docxParagraph); pdfParagraph.setBorder(borderRight, Rectangle.RIGHT); if (itemContext != null) { CTLvl lvl = itemContext.getLvl(); CTPPr lvlPPr = lvl.getPPr(); if (lvlPPr != null) { if (ParagraphIndentationLeftValueProvider.INSTANCE .getValue(docxParagraph.getCTP().getPPr()) == null) { // search the indentation from the level properties only if // paragraph has not override it // see // https://code.google.com/p/xdocreport/issues/detail?id=239 Float indLeft = ParagraphIndentationLeftValueProvider.INSTANCE.getValue(lvlPPr); if (indLeft != null) { pdfParagraph.setIndentationLeft(indLeft); } } if (ParagraphIndentationHangingValueProvider.INSTANCE .getValue(docxParagraph.getCTP().getPPr()) == null) { // search the hanging from the level properties only if // paragraph has not override it // see // https://code.google.com/p/xdocreport/issues/detail?id=239 Float hanging = stylesDocument.getIndentationHanging(lvlPPr); if (hanging != null) { pdfParagraph.setFirstLineIndent(-hanging); } } } CTRPr lvlRPr = lvl.getRPr(); if (lvlRPr != null) { // Font family String listItemFontFamily = stylesDocument.getFontFamilyAscii(lvlRPr); // Get font size Float listItemFontSize = stylesDocument.getFontSize(lvlRPr); // Get font style int listItemFontStyle = Font.NORMAL; Boolean bold = stylesDocument.getFontStyleBold(lvlRPr); if (bold != null && bold) { listItemFontStyle |= Font.BOLD; } Boolean italic = stylesDocument.getFontStyleItalic(lvlRPr); if (italic != null && italic) { listItemFontStyle |= Font.ITALIC; } Boolean strike = stylesDocument.getFontStyleStrike(lvlRPr); if (strike != null && strike) { listItemFontStyle |= Font.STRIKETHRU; } // Font color Color listItemFontColor = stylesDocument.getFontColor(lvlRPr); pdfParagraph.setListItemFontFamily(listItemFontFamily); pdfParagraph.setListItemFontSize(listItemFontSize); pdfParagraph.setListItemFontStyle(listItemFontStyle); pdfParagraph.setListItemFontColor(Converter.toAwtColor(listItemFontColor)); } pdfParagraph.setListItemText(itemContext.getText()); } return pdfParagraph; }
From source file:fr.univlorraine.mondossierweb.controllers.CalendrierController.java
License:Apache License
/** * //www.j a v a2s . c o m * @param document pdf */ public void creerPdfCalendrier(final Document document, Etudiant etudiant) { //configuration des fonts Font normal = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL); Font normalbig = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLD); Font legerita = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.ITALIC); Font headerbig = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD); Font header = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD); //pieds de pages: Date d = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); String date = dateFormat.format(d); //alignement des libells du pied de page: String partie1 = applicationContext.getMessage("pdf.calendrier.title", null, Locale.getDefault()); String partie2 = applicationContext.getMessage("pdf.edition.date", null, Locale.getDefault()) + " : " + date; if (partie1.length() < ECARTEMENT_PIED_PAGE_PDF) { int diff = ECARTEMENT_PIED_PAGE_PDF - partie1.length(); for (int i = 0; i < diff; i++) { partie1 = partie1 + " "; } } if (partie2.length() < ECARTEMENT_PIED_PAGE_PDF) { int diff = ECARTEMENT_PIED_PAGE_PDF - partie2.length(); for (int i = 0; i < diff; i++) { partie2 = " " + partie2; } } //cration du pied de page: Phrase phra = new Phrase( partie1 + " -" + applicationContext.getMessage("pdf.page", null, Locale.getDefault()), legerita); Phrase phra2 = new Phrase("- " + partie2, legerita); HeaderFooter hf = new HeaderFooter(phra, phra2); hf.setAlignment(HeaderFooter.ALIGN_CENTER); document.setFooter(hf); //ouverte du document. document.open(); try { //ajout image test if (configController.getLogoUniversitePdf() != null && !configController.getLogoUniversitePdf().equals("")) { Image image1 = Image.getInstance(configController.getLogoUniversitePdf()); float scaleRatio = 40 / image1.getHeight(); float newWidth = scaleRatio * image1.getWidth(); image1.scaleAbsolute(newWidth, 40); image1.setAbsolutePosition(800 - newWidth, 528); document.add(image1); } //nouveau paragraphe Paragraph p = new Paragraph( applicationContext.getMessage("pdf.calendrier.title", null, Locale.getDefault()).toUpperCase() + "\n\n", headerbig); p.setIndentationLeft(15); document.add(p); if (etudiant.getNom() != null) { Paragraph p0 = new Paragraph(etudiant.getNom(), normal); p0.setIndentationLeft(15); document.add(p0); } if (etudiant.getCod_etu() != null) { Paragraph p01 = new Paragraph(applicationContext.getMessage("pdf.folder", null, Locale.getDefault()) + " : " + etudiant.getCod_etu(), normal); p01.setIndentationLeft(15); document.add(p01); } if (etudiant.getCod_nne() != null) { Paragraph p02 = new Paragraph(applicationContext.getMessage("pdf.nne", null, Locale.getDefault()) + " : " + etudiant.getCod_nne(), normal); p02.setIndentationLeft(15); document.add(p02); } if (etudiant.getEmail() != null) { Paragraph p03 = new Paragraph(applicationContext.getMessage("pdf.mail", null, Locale.getDefault()) + " : " + etudiant.getEmail(), normal); p03.setIndentationLeft(15); document.add(p03); } Paragraph p03 = new Paragraph( applicationContext.getMessage("pdf.edition.date", null, Locale.getDefault()) + " : " + date, normal); p03.setIndentationLeft(15); document.add(p03); document.add(new Paragraph("\n")); //Partie Calendrier PdfPTable table = new PdfPTable(1); table.setWidthPercentage(98); PdfPCell cell = new PdfPCell(new Paragraph(applicationContext .getMessage("pdf.calendrier.subtitle", null, Locale.getDefault()).toUpperCase() + " ", header)); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(new Color(153, 153, 255)); table.addCell(cell); PdfPTable table2; boolean affNumPlaceExamen = configController.isAffNumPlaceExamen(); if (affNumPlaceExamen) { table2 = new PdfPTable(7); table2.setWidthPercentage(98); int[] tabWidth = { 15, 10, 10, 40, 30, 10, 60 }; table2.setWidths(tabWidth); } else { table2 = new PdfPTable(6); table2.setWidthPercentage(98); int[] tabWidth = { 15, 10, 10, 45, 30, 65 }; table2.setWidths(tabWidth); } Paragraph p1 = new Paragraph(applicationContext.getMessage("pdf.date", null, Locale.getDefault()), normalbig); Paragraph p2 = new Paragraph(applicationContext.getMessage("pdf.heure", null, Locale.getDefault()), normalbig); Paragraph p3 = new Paragraph(applicationContext.getMessage("pdf.duree", null, Locale.getDefault()), normalbig); Paragraph p4 = new Paragraph(applicationContext.getMessage("pdf.batiment", null, Locale.getDefault()), normalbig); Paragraph p5 = new Paragraph(applicationContext.getMessage("pdf.salle", null, Locale.getDefault()), normalbig); Paragraph p6 = new Paragraph(applicationContext.getMessage("pdf.place", null, Locale.getDefault()), normalbig); Paragraph p7 = new Paragraph(applicationContext.getMessage("pdf.examen", null, Locale.getDefault()), normalbig); PdfPCell ct1 = new PdfPCell(p1); PdfPCell ct2 = new PdfPCell(p2); PdfPCell ct3 = new PdfPCell(p3); PdfPCell ct4 = new PdfPCell(p4); PdfPCell ct5 = new PdfPCell(p5); PdfPCell ct6 = new PdfPCell(p6); PdfPCell ct7 = new PdfPCell(p7); ct1.setBorder(Rectangle.BOTTOM); ct1.setBorderColorBottom(Color.black); ct2.setBorder(Rectangle.BOTTOM); ct2.setBorderColorBottom(Color.black); ct3.setBorder(Rectangle.BOTTOM); ct2.setBorderColorBottom(Color.black); ct4.setBorder(Rectangle.BOTTOM); ct1.setBorderColorBottom(Color.black); ct5.setBorder(Rectangle.BOTTOM); ct2.setBorderColorBottom(Color.black); ct6.setBorder(Rectangle.BOTTOM); ct2.setBorderColorBottom(Color.black); ct7.setBorder(Rectangle.BOTTOM); ct2.setBorderColorBottom(Color.black); table2.addCell(ct1); table2.addCell(ct2); table2.addCell(ct3); table2.addCell(ct4); table2.addCell(ct5); if (affNumPlaceExamen) table2.addCell(ct6); table2.addCell(ct7); for (int i = 0; i < etudiant.getCalendrier().size(); i++) { Paragraph pa = new Paragraph(etudiant.getCalendrier().get(i).getDatedeb(), normal); PdfPCell celltext = new PdfPCell(pa); celltext.setBorder(Rectangle.NO_BORDER); Paragraph pa2 = new Paragraph(etudiant.getCalendrier().get(i).getHeure(), normal); PdfPCell celltext2 = new PdfPCell(pa2); celltext2.setBorder(Rectangle.NO_BORDER); Paragraph pa3 = new Paragraph(etudiant.getCalendrier().get(i).getDuree(), normal); PdfPCell celltext3 = new PdfPCell(pa3); celltext3.setBorder(Rectangle.NO_BORDER); Paragraph pa4 = new Paragraph(etudiant.getCalendrier().get(i).getBatiment(), normal); PdfPCell celltext4 = new PdfPCell(pa4); celltext4.setBorder(Rectangle.NO_BORDER); Paragraph pa5 = new Paragraph(etudiant.getCalendrier().get(i).getSalle(), normal); PdfPCell celltext5 = new PdfPCell(pa5); celltext5.setBorder(Rectangle.NO_BORDER); Paragraph pa6 = new Paragraph(etudiant.getCalendrier().get(i).getPlace(), normal); PdfPCell celltext6 = new PdfPCell(pa6); celltext6.setBorder(Rectangle.NO_BORDER); Paragraph pa7 = new Paragraph(etudiant.getCalendrier().get(i).getEpreuve(), normal); PdfPCell celltext7 = new PdfPCell(pa7); celltext7.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext); table2.addCell(celltext2); table2.addCell(celltext3); table2.addCell(celltext4); table2.addCell(celltext5); if (affNumPlaceExamen) table2.addCell(celltext6); table2.addCell(celltext7); /*PdfPCell celltext4 = new PdfPCell(table3); celltext4.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext4);*/ } document.add(table); document.add(table2); document.add(new Paragraph("\n")); } catch (BadElementException e) { LOG.error("Erreur la gnration du calendrier des examens : BadElementException ", e); } catch (MalformedURLException e) { LOG.error("Erreur la gnration du calendrier des examens : MalformedURLException ", e); } catch (IOException e) { LOG.error("Erreur la gnration du calendrier des examens : IOException ", e); } catch (DocumentException e) { LOG.error("Erreur la gnration du calendrier des examens : DocumentException ", e); } // step 6: fermeture du document. document.close(); }
From source file:fr.univlorraine.mondossierweb.controllers.NoteController.java
License:Apache License
/** * // w w w . j a va 2s . com * @param document pdf */ public void creerPdfResume(final Document document, Etudiant etudiant) { //configuration des fonts Font normal = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL); Font normalbig = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLD); Font legerita = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.ITALIC); Font headerbig = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD); Font header = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD); //pieds de pages: Date d = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); String date = dateFormat.format(d); //alignement des libell du pied de page: String partie1 = applicationContext.getMessage("pdf.notes.title", null, Locale.getDefault()); String partie2 = applicationContext.getMessage("pdf.edition.date", null, Locale.getDefault()) + " : " + date; if (partie1.length() < ECARTEMENT_PIED_PAGE_PDF) { int diff = ECARTEMENT_PIED_PAGE_PDF - partie1.length(); for (int i = 0; i < diff; i++) { partie1 = partie1 + " "; } } if (partie2.length() < ECARTEMENT_PIED_PAGE_PDF) { int diff = ECARTEMENT_PIED_PAGE_PDF - partie2.length(); for (int i = 0; i < diff; i++) { partie2 = " " + partie2; } } //creation du pied de page: Phrase phra = new Phrase( partie1 + " -" + applicationContext.getMessage("pdf.page", null, Locale.getDefault()), legerita); Phrase phra2 = new Phrase("- " + partie2, legerita); HeaderFooter hf = new HeaderFooter(phra, phra2); hf.setAlignment(HeaderFooter.ALIGN_CENTER); document.setFooter(hf); //ouverte du document. document.open(); try { //ajout image test if (configController.getLogoUniversitePdf() != null && !configController.getLogoUniversitePdf().equals("")) { Image image1 = Image.getInstance(configController.getLogoUniversitePdf()); float scaleRatio = 40 / image1.getHeight(); float newWidth = scaleRatio * image1.getWidth(); image1.scaleAbsolute(newWidth, 40); image1.setAbsolutePosition(800 - newWidth, 528); document.add(image1); } boolean affMentionEtudiant = configController.isAffMentionEtudiant(); //nouveau paragraphe Paragraph p = new Paragraph(applicationContext.getMessage("pdf.notes.title", null, Locale.getDefault()) .toUpperCase(Locale.getDefault()) + "\n\n", headerbig); p.setIndentationLeft(15); document.add(p); if (etudiant.getNom() != null) { Paragraph p0 = new Paragraph(etudiant.getNom(), normal); p0.setIndentationLeft(15); document.add(p0); } if (etudiant.getCod_etu() != null) { Paragraph p01 = new Paragraph(applicationContext.getMessage("pdf.folder", null, Locale.getDefault()) + " : " + etudiant.getCod_etu(), normal); p01.setIndentationLeft(15); document.add(p01); } if (etudiant.getCod_nne() != null) { Paragraph p02 = new Paragraph(applicationContext.getMessage("pdf.nne", null, Locale.getDefault()) + " : " + etudiant.getCod_nne(), normal); p02.setIndentationLeft(15); document.add(p02); } if (etudiant.getEmail() != null) { Paragraph p03 = new Paragraph(applicationContext.getMessage("pdf.mail", null, Locale.getDefault()) + " : " + etudiant.getEmail(), normal); p03.setIndentationLeft(15); document.add(p03); } Paragraph p03 = new Paragraph( applicationContext.getMessage("pdf.edition.date", null, Locale.getDefault()) + " : " + date, normal); p03.setIndentationLeft(15); document.add(p03); document.add(new Paragraph("\n")); //Partie DIPLOMES PdfPTable table = new PdfPTable(1); table.setWidthPercentage(98); PdfPCell cell = new PdfPCell( new Paragraph(applicationContext.getMessage("pdf.diplomes", null, Locale.getDefault()) .toUpperCase(Locale.getDefault()) + " ", header)); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(new Color(153, 153, 255)); table.addCell(cell); PdfPTable table2; //if(!config.isAffRangEtudiant()){ if (!etudiant.isAfficherRang()) { table2 = new PdfPTable(4); } else { table2 = new PdfPTable(5); } table2.setWidthPercentage(98); int tailleColonneLib = 110; if (affMentionEtudiant) tailleColonneLib = 90; //if(!config.isAffRangEtudiant()){ if (!etudiant.isAfficherRang()) { int[] tabWidth = { 26, 35, tailleColonneLib, 70 }; table2.setWidths(tabWidth); } else { int[] tabWidth = { 26, 35, tailleColonneLib - 5, 70, 15 }; table2.setWidths(tabWidth); } Paragraph p1 = new Paragraph(applicationContext.getMessage("pdf.year", null, Locale.getDefault()), normalbig); Paragraph p2 = new Paragraph(applicationContext.getMessage("pdf.code.vers", null, Locale.getDefault()), normalbig); Paragraph p3 = new Paragraph(applicationContext.getMessage("pdf.diplome", null, Locale.getDefault()), normalbig); PdfPCell ct1 = new PdfPCell(p1); PdfPCell ct2 = new PdfPCell(p2); PdfPCell ct3 = new PdfPCell(p3); ct1.setBorder(Rectangle.BOTTOM); ct1.setBorderColorBottom(Color.black); ct2.setBorder(Rectangle.BOTTOM); ct2.setBorderColorBottom(Color.black); ct3.setBorder(Rectangle.BOTTOM); ct3.setBorderColorBottom(Color.black); table2.addCell(ct1); table2.addCell(ct2); table2.addCell(ct3); PdfPTable table21; if (!affMentionEtudiant) { table21 = new PdfPTable(3); int[] tabWidth21 = { 25, 20, 25 }; table21.setWidths(tabWidth21); } else { table21 = new PdfPTable(4); int[] tabWidth21 = { 25, 20, 25, 20 }; table21.setWidths(tabWidth21); } PdfPCell ct4 = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.session", null, Locale.getDefault()), normalbig)); PdfPCell ct5 = new PdfPCell( new Paragraph(applicationContext.getMessage("pdf.note", null, Locale.getDefault()), normalbig)); PdfPCell ct6 = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.resultat", null, Locale.getDefault()), normalbig)); PdfPCell ctmention = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.mention", null, Locale.getDefault()), normalbig)); ct4.setBorder(Rectangle.BOTTOM); ct4.setBorderColorBottom(Color.black); ct5.setBorder(Rectangle.BOTTOM); ct5.setBorderColorBottom(Color.black); ct6.setBorder(Rectangle.BOTTOM); ct6.setBorderColorBottom(Color.black); ctmention.setBorder(Rectangle.BOTTOM); ctmention.setBorderColorBottom(Color.black); table21.addCell(ct4); table21.addCell(ct5); table21.addCell(ct6); if (affMentionEtudiant) { table21.addCell(ctmention); } PdfPCell ct7 = new PdfPCell(table21); ct7.setBorder(Rectangle.BOTTOM); table2.addCell(ct7); PdfPCell ctrang = new PdfPCell( new Paragraph(applicationContext.getMessage("pdf.rank", null, Locale.getDefault()), normalbig)); ctrang.setBorder(Rectangle.BOTTOM); ctrang.setBorderColorBottom(Color.black); //if(config.isAffRangEtudiant()){ if (etudiant.isAfficherRang()) { table2.addCell(ctrang); } for (int i = 0; i < etudiant.getDiplomes().size(); i++) { Paragraph pa = new Paragraph(etudiant.getDiplomes().get(i).getAnnee(), normal); PdfPCell celltext = new PdfPCell(pa); celltext.setBorder(Rectangle.NO_BORDER); Paragraph pa2 = new Paragraph(etudiant.getDiplomes().get(i).getCod_dip() + "/" + etudiant.getDiplomes().get(i).getCod_vrs_vdi(), normal); PdfPCell celltext2 = new PdfPCell(pa2); celltext2.setBorder(Rectangle.NO_BORDER); Paragraph pa3 = new Paragraph(etudiant.getDiplomes().get(i).getLib_web_vdi(), normal); PdfPCell celltext3 = new PdfPCell(pa3); celltext3.setBorder(Rectangle.NO_BORDER); Paragraph parang = new Paragraph(etudiant.getDiplomes().get(i).getRang(), normal); PdfPCell cellrang = new PdfPCell(parang); cellrang.setBorder(Rectangle.NO_BORDER); PdfPCell cellvide = new PdfPCell(); cellvide.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext); table2.addCell(celltext2); table2.addCell(celltext3); PdfPTable table3; if (!affMentionEtudiant) { table3 = new PdfPTable(3); int[] tabWidth2 = { 25, 20, 25 }; table3.setWidths(tabWidth2); } else { table3 = new PdfPTable(4); int[] tabWidth2 = { 25, 20, 25, 8 }; table3.setWidths(tabWidth2); } int j = 0; List<Resultat> lres = etudiant.getDiplomes().get(i).getResultats(); while (j < lres.size()) { Paragraph pa5 = new Paragraph(lres.get(j).getSession(), normal); PdfPCell celltext5 = new PdfPCell(pa5); celltext5.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext5); if (lres.get(j).getNote() != null) { Paragraph pa6 = new Paragraph(lres.get(j).getNote().toString(), normal); PdfPCell celltext6 = new PdfPCell(pa6); celltext6.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext6); } else { Paragraph pa6 = new Paragraph("", normal); PdfPCell celltext6 = new PdfPCell(pa6); celltext6.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext6); } Paragraph pa7 = new Paragraph(lres.get(j).getAdmission(), normal); PdfPCell celltext7 = new PdfPCell(pa7); celltext7.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext7); if (affMentionEtudiant) { Paragraph pa8 = new Paragraph(lres.get(j).getCodMention(), normal); PdfPCell celltext8 = new PdfPCell(pa8); celltext8.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext8); } j++; } PdfPCell celltext4 = new PdfPCell(table3); celltext4.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext4); //if(config.isAffRangEtudiant()){ if (etudiant.getDiplomes().get(i).isAfficherRang()) { table2.addCell(cellrang); } else { //On insere une cellule vide si on affiche pas ce rang, alors que la colonne rang fait partie de la table if (etudiant.isAfficherRang()) { table2.addCell(cellvide); } } } document.add(table); document.add(table2); document.add(new Paragraph("\n")); //Partie ETAPES PdfPTable tabletape = new PdfPTable(1); tabletape.setWidthPercentage(98); PdfPCell celletape = new PdfPCell(new Paragraph(applicationContext .getMessage("pdf.etapes", null, Locale.getDefault()).toUpperCase(Locale.getDefault()), header)); celletape.setBorder(Rectangle.NO_BORDER); celletape.setBackgroundColor(new Color(153, 153, 255)); tabletape.addCell(celletape); PdfPTable tabletape2; //if(!config.isAffRangEtudiant()){ if (!etudiant.isAfficherRang()) { tabletape2 = new PdfPTable(4); tabletape2.setWidthPercentage(98); int[] tabWidthetape = { 26, 35, tailleColonneLib, 70 }; tabletape2.setWidths(tabWidthetape); } else { tabletape2 = new PdfPTable(5); tabletape2.setWidthPercentage(98); int[] tabWidthetape = { 26, 35, tailleColonneLib - 5, 70, 15 }; tabletape2.setWidths(tabWidthetape); } PdfPCell ct3etape = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.etape", null, Locale.getDefault()), normalbig)); ct3etape.setBorder(Rectangle.BOTTOM); ct3etape.setBorderColorBottom(Color.black); tabletape2.addCell(ct1); tabletape2.addCell(ct2); tabletape2.addCell(ct3etape); tabletape2.addCell(ct7); //if(!config.isAffRangEtudiant()){ if (etudiant.isAfficherRang()) { tabletape2.addCell(ctrang); } for (int i = 0; i < etudiant.getEtapes().size(); i++) { Paragraph pa = new Paragraph(etudiant.getEtapes().get(i).getAnnee(), normal); PdfPCell celltext = new PdfPCell(pa); celltext.setBorder(Rectangle.NO_BORDER); tabletape2.addCell(celltext); Paragraph pa2 = new Paragraph( etudiant.getEtapes().get(i).getCode() + "/" + etudiant.getEtapes().get(i).getVersion(), normal); PdfPCell celltext2 = new PdfPCell(pa2); celltext2.setBorder(Rectangle.NO_BORDER); tabletape2.addCell(celltext2); Paragraph pa3 = new Paragraph(etudiant.getEtapes().get(i).getLibelle(), normal); PdfPCell celltext3 = new PdfPCell(pa3); celltext3.setBorder(Rectangle.NO_BORDER); tabletape2.addCell(celltext3); Paragraph parEtapeRang = new Paragraph(etudiant.getEtapes().get(i).getRang(), normal); PdfPCell cellEtapeRang = new PdfPCell(parEtapeRang); cellEtapeRang.setBorder(Rectangle.NO_BORDER); PdfPCell cellvide = new PdfPCell(); cellvide.setBorder(Rectangle.NO_BORDER); PdfPTable table3; if (!affMentionEtudiant) { table3 = new PdfPTable(3); int[] tabWidth2 = { 25, 20, 25 }; table3.setWidths(tabWidth2); } else { table3 = new PdfPTable(4); int[] tabWidth2 = { 25, 20, 25, 8 }; table3.setWidths(tabWidth2); } int j = 0; List<Resultat> lres = etudiant.getEtapes().get(i).getResultats(); while (j < lres.size()) { Paragraph pa5 = new Paragraph(lres.get(j).getSession(), normal); PdfPCell celltext5 = new PdfPCell(pa5); celltext5.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext5); if (lres.get(j).getNote() != null) { Paragraph pa6 = new Paragraph(lres.get(j).getNote().toString(), normal); PdfPCell celltext6 = new PdfPCell(pa6); celltext6.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext6); } else { Paragraph pa6 = new Paragraph("", normal); PdfPCell celltext6 = new PdfPCell(pa6); celltext6.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext6); } Paragraph pa7 = new Paragraph(lres.get(j).getAdmission(), normal); PdfPCell celltext7 = new PdfPCell(pa7); celltext7.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext7); if (affMentionEtudiant) { Paragraph pa8 = new Paragraph(lres.get(j).getCodMention(), normal); PdfPCell celltext8 = new PdfPCell(pa8); celltext8.setBorder(Rectangle.NO_BORDER); table3.addCell(celltext8); } j++; } PdfPCell celltext4 = new PdfPCell(table3); celltext4.setBorder(Rectangle.NO_BORDER); tabletape2.addCell(celltext4); //if(config.isAffRangEtudiant()){ if (etudiant.getEtapes().get(i).isAfficherRang()) { tabletape2.addCell(cellEtapeRang); } else { if (etudiant.isAfficherRang()) { tabletape2.addCell(cellvide); } } } document.add(tabletape); document.add(tabletape2); document.add(new Paragraph("\n")); //Partie Informations if (etudiant.isSignificationResultatsUtilisee()) { PdfPTable tablequestions = new PdfPTable(1); tablequestions.setWidthPercentage(98); PdfPCell cellquestions = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.questions", null, Locale.getDefault()) + " ", header)); cellquestions.setBorder(Rectangle.NO_BORDER); cellquestions.setBackgroundColor(new Color(153, 153, 255)); tablequestions.addCell(cellquestions); String grilleSignficationResultats = ""; Set<String> ss = etudiant.getSignificationResultats().keySet(); for (String k : ss) { if (k != null && !k.equals("") && !k.equals(" ")) { grilleSignficationResultats = grilleSignficationResultats + k + " : " + etudiant.getSignificationResultats().get(k); grilleSignficationResultats = grilleSignficationResultats + " "; } } PdfPTable tablequestions2 = new PdfPTable(1); tablequestions2.setWidthPercentage(98); PdfPCell cellquestions2 = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.code.resultat.signification", null, Locale.getDefault()) + " : \n" + grilleSignficationResultats, normal)); cellquestions2.setBorder(Rectangle.NO_BORDER); tablequestions2.addCell(cellquestions2); document.add(tablequestions); document.add(tablequestions2); } } catch (BadElementException e) { LOG.error("Erreur la gnration du rsum des notes : BadElementException ", e); } catch (MalformedURLException e) { LOG.error("Erreur la gnration du rsum des notes : MalformedURLException ", e); } catch (IOException e) { LOG.error("Erreur la gnration du rsum des notes : IOException ", e); } catch (DocumentException e) { LOG.error("Erreur la gnration du rsum des notes : DocumentException ", e); } // step 6: fermeture du document. document.close(); }
From source file:fr.univlorraine.mondossierweb.controllers.NoteController.java
License:Apache License
/** * //from w w w. j a v a 2 s . c o m * @param document pdf */ public void creerPdfDetail(final Document document, Etudiant etudiant, Etape etape) { //configuration des fonts Font normal = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL); Font normalbig = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLD); Font legerita = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.ITALIC); Font headerbig = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD); Font header = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD); //pieds de pages: Date d = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); String date = dateFormat.format(d); //alignement des libells du pied de page: String partie1 = applicationContext.getMessage("pdf.notes.detail", null, Locale.getDefault()); String partie2 = applicationContext.getMessage("pdf.edition.date", null, Locale.getDefault()) + " : " + date; if (partie1.length() < ECARTEMENT_PIED_PAGE_PDF) { int diff = ECARTEMENT_PIED_PAGE_PDF - partie1.length(); for (int i = 0; i < diff; i++) { partie1 = partie1 + " "; } } if (partie2.length() < ECARTEMENT_PIED_PAGE_PDF) { int diff = ECARTEMENT_PIED_PAGE_PDF - partie2.length(); for (int i = 0; i < diff; i++) { partie2 = " " + partie2; } } //creation du pied de page: Phrase phra = new Phrase( partie1 + " -" + applicationContext.getMessage("pdf.page", null, Locale.getDefault()), legerita); Phrase phra2 = new Phrase("- " + partie2, legerita); HeaderFooter hf = new HeaderFooter(phra, phra2); hf.setAlignment(HeaderFooter.ALIGN_CENTER); document.setFooter(hf); document.setFooter(hf); //ouverte du document. document.open(); try { //ajout image test if (configController.getLogoUniversitePdf() != null && !configController.getLogoUniversitePdf().equals("")) { Image image1 = Image.getInstance(configController.getLogoUniversitePdf()); float scaleRatio = 40 / image1.getHeight(); float newWidth = scaleRatio * image1.getWidth(); image1.scaleAbsolute(newWidth, 40); image1.setAbsolutePosition(800 - newWidth, 528); document.add(image1); } //nouveau paragraphe Paragraph p = new Paragraph(applicationContext.getMessage("pdf.notes.title", null, Locale.getDefault()) .toUpperCase(Locale.getDefault()) + "\n\n", headerbig); p.setIndentationLeft(15); document.add(p); if (etudiant.getNom() != null) { Paragraph p0 = new Paragraph(etudiant.getNom(), normal); p0.setIndentationLeft(15); document.add(p0); } if (etudiant.getCod_etu() != null) { Paragraph p01 = new Paragraph(applicationContext.getMessage("pdf.folder", null, Locale.getDefault()) + " : " + etudiant.getCod_etu(), normal); p01.setIndentationLeft(15); document.add(p01); } if (etudiant.getCod_nne() != null) { Paragraph p02 = new Paragraph(applicationContext.getMessage("pdf.nne", null, Locale.getDefault()) + " : " + etudiant.getCod_nne(), normal); p02.setIndentationLeft(15); document.add(p02); } if (etudiant.getEmail() != null) { Paragraph p03 = new Paragraph(applicationContext.getMessage("pdf.mail", null, Locale.getDefault()) + " : " + etudiant.getEmail(), normal); p03.setIndentationLeft(15); document.add(p03); } Paragraph p03 = new Paragraph( applicationContext.getMessage("pdf.edition.date", null, Locale.getDefault()) + " : " + date, normal); p03.setIndentationLeft(15); document.add(p03); document.add(new Paragraph("\n")); //Partie des notes PdfPTable table = new PdfPTable(1); table.setWidthPercentage(98); //PdfPCell cell = new PdfPCell(new Paragraph(applicationContext.getMessage("pdf.elements.epreuves", null, Locale.getDefault()).toUpperCase(Locale.getDefault()) + " - "+applicationContext.getMessage("pdf.annee.universitaire", null, Locale.getDefault()) + " : " + etape.getAnnee(), header)); PdfPCell cell = new PdfPCell(new Paragraph(etape.getLibelle() + " - " + applicationContext.getMessage("pdf.annee.universitaire", null, Locale.getDefault()) + " : " + etape.getAnnee(), header)); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(new Color(153, 153, 255)); table.addCell(cell); PdfPTable table2; boolean afficherRangElpEpr = etudiantController.isAfficherRangElpEpr(); boolean affRangEtudiant = configController.isAffRangEtudiant(); boolean affECTSEtudiant = configController.isAffECTSEtudiant(); if ((!affRangEtudiant && !afficherRangElpEpr) && !affECTSEtudiant) { //NI isAffRangEtudiant NI isAffECTSEtudiant table2 = new PdfPTable(6); table2.setWidthPercentage(98); int[] tabWidth = { 35, 110, 25, 25, 25, 25 }; table2.setWidths(tabWidth); } else { if (((affRangEtudiant || afficherRangElpEpr) && !affECTSEtudiant) || ((!affRangEtudiant && !afficherRangElpEpr) && affECTSEtudiant)) { //isAffRangEtudiant OU isAffECTSEtudiant table2 = new PdfPTable(7); table2.setWidthPercentage(98); int[] tabWidth = { 33, 110, 22, 22, 22, 22, 15 }; table2.setWidths(tabWidth); } else { //isAffRangEtudiant ET isAffECTSEtudiant table2 = new PdfPTable(8); table2.setWidthPercentage(98); int[] tabWidth = { 33, 110, 22, 22, 22, 22, 15, 15 }; table2.setWidths(tabWidth); } } //Paragraph p1 = new Paragraph(applicationContext.getMessage("pdf.year", null, Locale.getDefault()),normalbig); Paragraph p2 = new Paragraph(applicationContext.getMessage("pdf.code", null, Locale.getDefault()), normalbig); Paragraph p3 = new Paragraph(applicationContext.getMessage("pdf.label", null, Locale.getDefault()), normalbig); Paragraph parRang = new Paragraph(applicationContext.getMessage("pdf.rank", null, Locale.getDefault()), normalbig); Paragraph parEcts = new Paragraph(applicationContext.getMessage("pdf.ects", null, Locale.getDefault()), normalbig); PdfPCell ct4 = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.session", null, Locale.getDefault()) + " 1", normalbig)); PdfPCell ct5 = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.resultat", null, Locale.getDefault()), normalbig)); PdfPCell ct6 = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.session", null, Locale.getDefault()) + " 2", normalbig)); PdfPCell ct7 = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.resultat", null, Locale.getDefault()), normalbig)); //PdfPCell ct1 = new PdfPCell(p1); PdfPCell ct2 = new PdfPCell(p2); PdfPCell ct3 = new PdfPCell(p3); PdfPCell cellRang = new PdfPCell(parRang); PdfPCell cellEcts = new PdfPCell(parEcts); //ct1.setBorder(Rectangle.BOTTOM); ct1.setBorderColorBottom(Color.black); ct2.setBorder(Rectangle.BOTTOM); ct2.setBorderColorBottom(Color.black); ct3.setBorder(Rectangle.BOTTOM); ct3.setBorderColorBottom(Color.black); ct4.setBorder(Rectangle.BOTTOM); ct4.setBorderColorBottom(Color.black); ct5.setBorder(Rectangle.BOTTOM); ct5.setBorderColorBottom(Color.black); ct6.setBorder(Rectangle.BOTTOM); ct6.setBorderColorBottom(Color.black); ct7.setBorder(Rectangle.BOTTOM); ct7.setBorderColorBottom(Color.black); cellRang.setBorder(Rectangle.BOTTOM); cellRang.setBorderColorBottom(Color.black); cellEcts.setBorder(Rectangle.BOTTOM); cellEcts.setBorderColorBottom(Color.black); //table2.addCell(ct1); table2.addCell(ct2); table2.addCell(ct3); table2.addCell(ct4); table2.addCell(ct5); table2.addCell(ct6); table2.addCell(ct7); if ((affRangEtudiant || afficherRangElpEpr)) { table2.addCell(cellRang); } if (affRangEtudiant) { table2.addCell(cellEcts); } for (int i = 0; i < etudiant.getElementsPedagogiques().size(); i++) { /*String annee = etudiant.getElementsPedagogiques().get(i).getAnnee().replaceAll(applicationContext.getMessage("pdf.replace.ficm", null, Locale.getDefault()), ""); Paragraph pa = new Paragraph(annee, normal); PdfPCell celltext = new PdfPCell(pa); celltext.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext);*/ Paragraph pa2 = new Paragraph(etudiant.getElementsPedagogiques().get(i).getCode(), normal); PdfPCell celltext2 = new PdfPCell(pa2); celltext2.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext2); String indentation = ""; for (int j = 0; j < etudiant.getElementsPedagogiques().get(i).getLevel(); j++) { indentation = indentation + " "; } Paragraph pa3 = new Paragraph(indentation + etudiant.getElementsPedagogiques().get(i).getLibelle(), normal); PdfPCell celltext3 = new PdfPCell(pa3); celltext3.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext3); Paragraph pa5 = new Paragraph(getNote1(etudiant.getElementsPedagogiques().get(i)), normal); PdfPCell celltext5 = new PdfPCell(pa5); celltext5.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext5); Paragraph pa6 = new Paragraph(etudiant.getElementsPedagogiques().get(i).getRes1(), normal); PdfPCell celltext6 = new PdfPCell(pa6); celltext6.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext6); Paragraph pa7 = new Paragraph(getNote2(etudiant.getElementsPedagogiques().get(i)), normal); PdfPCell celltext7 = new PdfPCell(pa7); celltext7.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext7); Paragraph pa8 = new Paragraph(etudiant.getElementsPedagogiques().get(i).getRes2(), normal); PdfPCell celltext8 = new PdfPCell(pa8); celltext8.setBorder(Rectangle.NO_BORDER); table2.addCell(celltext8); if ((affRangEtudiant || afficherRangElpEpr)) { Paragraph parRang2 = new Paragraph(etudiant.getElementsPedagogiques().get(i).getRang(), normal); PdfPCell cellRang2 = new PdfPCell(parRang2); cellRang2.setBorder(Rectangle.NO_BORDER); table2.addCell(cellRang2); } if (affECTSEtudiant) { Paragraph parEcts2 = new Paragraph(etudiant.getElementsPedagogiques().get(i).getEcts(), normal); PdfPCell cellEcts2 = new PdfPCell(parEcts2); cellEcts2.setBorder(Rectangle.NO_BORDER); table2.addCell(cellEcts2); } } document.add(table); document.add(table2); document.add(new Paragraph("\n")); //Partie QUESTIONS if (etudiant.isSignificationResultatsUtilisee()) { PdfPTable tablequestions = new PdfPTable(1); tablequestions.setWidthPercentage(98); PdfPCell cellquestions = new PdfPCell( new Paragraph(applicationContext.getMessage("pdf.questions", null, Locale.getDefault()) .toUpperCase(Locale.getDefault()) + " ", header)); cellquestions.setBorder(Rectangle.NO_BORDER); cellquestions.setBackgroundColor(new Color(153, 153, 255)); tablequestions.addCell(cellquestions); PdfPTable tablequestions2 = new PdfPTable(1); tablequestions2.setWidthPercentage(98); String grilleSignficationResultats = ""; Set<String> ss = etudiant.getSignificationResultats().keySet(); for (String k : ss) { if (k != null && !k.equals("") && !k.equals(" ")) { grilleSignficationResultats = grilleSignficationResultats + k + " : " + etudiant.getSignificationResultats().get(k); grilleSignficationResultats = grilleSignficationResultats + " "; } } PdfPCell cellquestions2 = new PdfPCell(new Paragraph( applicationContext.getMessage("pdf.code.resultat.signification", null, Locale.getDefault()) + " : \n" + grilleSignficationResultats, normal)); cellquestions2.setBorder(Rectangle.NO_BORDER); tablequestions2.addCell(cellquestions2); document.add(tablequestions); document.add(tablequestions2); } } catch (BadElementException e) { LOG.error("Erreur la gnration du detail des notes : BadElementException ", e); } catch (MalformedURLException e) { LOG.error("Erreur la gnration du detail des notes : MalformedURLException ", e); } catch (IOException e) { LOG.error("Erreur la gnration du detail des notes : IOException ", e); } catch (DocumentException e) { LOG.error("Erreur la gnration du detail des notes : DocumentException ", e); } // step 6: fermeture du document. document.close(); }