List of usage examples for com.lowagie.text Paragraph setIndentationLeft
public void setIndentationLeft(float indentation)
From source file:com.orange.atk.compModel.PDFGenerator.java
License:Apache License
/** * @see com.orange.atk.results.logger.documentGenerator.DocumentGenerator#dumpInStream(boolean, interpreter.logger.DocumentLogger) *//*from w w w . j a v a2s. c o m*/ public void dumpInStream(boolean isParseErrorHappened, /*DocumentLogger dl,*/ org.w3c.dom.Document xmlDoc, Model model3) { long endTime = new Date().getTime(); // step 1: creation of a document-object Document document = new Document(); PdfWriter writer = null; // step 2: // we create a writer that listens to the document // and directs a PDF-stream to the outputStream try { writer = PdfWriter.getInstance(document, outputStream); } catch (DocumentException e1) { e1.printStackTrace(); return; } writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); // step 3: we open the document document.open(); document.addTitle("REPORT"); document.addCreationDate(); HeaderFooter headerPage = new HeaderFooter(new Phrase("ScreenShot report"), false); HeaderFooter footerPage = new HeaderFooter(new Phrase(" - "), new Phrase(" - ")); headerPage.setAlignment(Element.ALIGN_CENTER); footerPage.setAlignment(Element.ALIGN_CENTER); document.setHeader(headerPage); document.setFooter(footerPage); // Chapter 1 : Summary // Section 1 : Informations Chunk c = new Chunk("Summary"); c.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c.setFont(FONT_PAR_TITLE); Paragraph title1 = new Paragraph(c); title1.setAlignment("CENTER"); title1.setLeading(20); Chapter chapter1 = new Chapter(title1, 1); chapter1.setNumberDepth(0); Paragraph title11 = new Paragraph("Informations"); Section section1 = chapter1.addSection(title11); Paragraph pSum = new Paragraph(); pSum.add("Author : " + author); pSum.add(Chunk.NEWLINE); pSum.add("Group : " + group); pSum.add(Chunk.NEWLINE); pSum.add("Script : " + script); pSum.add(Chunk.NEWLINE); pSum.add("Reference directory: " + model3.getRefDirectory()); pSum.add(Chunk.NEWLINE); pSum.add("Test directory: " + model3.getTestDirectory()); pSum.add(Chunk.NEWLINE); SimpleDateFormat formatter = new SimpleDateFormat("MMMMM dd, yyyy - hh:mm aaa"); String dateString = formatter.format(endTime); pSum.add("Date : " + dateString); pSum.add(Chunk.NEWLINE); pSum.add(Chunk.NEWLINE); if (model3.getNbFail() > 0) { pSum.add(model3.getNbFail() + "/" + model3.getNbImages() + " images didn't succeed the test."); } else { pSum.add("All images (" + model3.getNbImages() + ") have succeed this comparaison."); } pSum.add(Chunk.NEWLINE); pSum.setIndentationLeft(20); section1.add(pSum); section1.add(new Paragraph(Chunk.NEXTPAGE)); try { document.add(chapter1); } catch (DocumentException e) { e.printStackTrace(); } document.newPage(); if (isParseErrorHappened) { document.close(); return; } // Add generated pictures Chunk c3 = new Chunk("ScreenShots"); c3.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c3.setFont(FONT_PAR_TITLE); Paragraph p3 = new Paragraph(c3); p3.setAlignment("CENTER"); p3.setLeading(20); Chapter chapter3 = new Chapter(p3, 1); chapter3.setNumberDepth(0); NodeList imgs = xmlDoc.getElementsByTagName("img"); for (int i = 0; i < imgs.getLength(); i++) { org.w3c.dom.Element eImg = (org.w3c.dom.Element) imgs.item(i); if (eImg.getElementsByTagName("Pass").item(0).getTextContent().equals(Model.FAIL)) { org.w3c.dom.Element eRef = (org.w3c.dom.Element) eImg.getElementsByTagName("Ref").item(0); org.w3c.dom.Element eTest = (org.w3c.dom.Element) eImg.getElementsByTagName("Test").item(0); Paragraph pScreen = new Paragraph(eTest.getAttributes().getNamedItem("name").getNodeValue() + " " + eImg.getElementsByTagName("Pass").item(0).getTextContent()); Section section31 = chapter3.addSection(pScreen); PdfPTable scTable = null; scTable = new PdfPTable(2); scTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); scTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); scTable.getDefaultCell().setPadding(5); if (new File(eRef.getTextContent()).exists()) { Image refImg; try { refImg = Image.getInstance(eRef.getTextContent()); refImg.scaleToFit(310, 260); refImg.setAlignment(Element.ALIGN_BASELINE); scTable.addCell(refImg); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (DOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } if (new File(eTest.getTextContent()).exists()) { Image testImg; try { BufferedImage bi = ImageIO.read(new File(eTest.getTextContent())); Graphics2D g2d = (Graphics2D) bi.getGraphics(); g2d.setStroke(new BasicStroke(1.5f)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f)); Boolean2D dif = model3.getCouplesComparaison().get(i).getDifWithMask(); // if (squarable){ g2d.setColor(Color.red); int w = bi.getWidth(); int h = bi.getHeight(); //TODO: Gurvan, Maybe we need to have the list of masks in the report? Mask mask = model3.getCouplesComparaison().get(i).getMaskSum(); //g2d.drawRect(0, 0, mask.getWidth()*2*sampleWidth, mask.getHeight()*2*sampleHeight); for (int x = 0; x < mask.getWidth(); x++) { for (int y = 0; y < mask.getHeight(); y++) { if (mask.getCell(x, y)) { g2d.setColor(Color.blue); ////Logger.getLogger(this.getClass() ).debug("grise"); g2d.fillRect(x * 2 * Mask.getCELL_HALF_SIZE(), y * 2 * Mask.getCELL_HALF_SIZE(), 2 * Mask.getCELL_HALF_SIZE(), 2 * Mask.getCELL_HALF_SIZE()); } if (!dif.get(x, y)) { g2d.setColor(Color.green); g2d.fillRect(x * 2 * Mask.getCELL_HALF_SIZE(), y * 2 * Mask.getCELL_HALF_SIZE(), 2 * Mask.getCELL_HALF_SIZE(), 2 * Mask.getCELL_HALF_SIZE()); } } } testImg = Image.getInstance(bi, null); testImg.scaleToFit(310, 260); testImg.setAlignment(Element.ALIGN_BASELINE); scTable.addCell(testImg); section31.add(Chunk.NEWLINE); section31.add(scTable); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (DOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } section31.add(new Paragraph("Reference screenshot description : " + eImg.getElementsByTagName("RefDescription").item(0).getTextContent())); section31.add(Chunk.NEWLINE); section31 .add(new Paragraph("Mask : " + eImg.getElementsByTagName("Mask").item(0).getTextContent())); section31.add(Chunk.NEWLINE); section31.add(new Paragraph( "Comment : " + eImg.getElementsByTagName("Comment").item(0).getTextContent())); section31.add(new Paragraph(Chunk.NEXTPAGE)); } } try { document.add(chapter3); } catch (DocumentException e) { e.printStackTrace(); } document.newPage(); // step 5: we close the document document.close(); }
From source file:com.orange.atk.results.logger.documentGenerator.PDFGenerator.java
License:Apache License
/** * @see com.orange.atk.results.logger.documentGenerator.DocumentGenerator#dumpInStream(boolean, * com.orange.atk.results.logger.log.DocumentLogger) *///w w w . j a v a2 s . c o m public void dumpInStream(boolean isParseErrorHappened, DocumentLogger dl) { long endTime = new Date().getTime(); // step 1: creation of a document-object Document document = new Document(); PdfWriter writer = null; // step 2: // we create a writer that listens to the document // and directs a PDF-stream to the outputStream try { writer = PdfWriter.getInstance(document, outputStream); } catch (DocumentException e1) { e1.printStackTrace(); return; } writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); // step 3: we open the document document.open(); // step 4: we add a paragraph to the document List<Message> msgLogged = dl.getMsgsLogged(); Paragraph pLoggedMsg = new Paragraph(); // logged messages for (int i = 0; i < msgLogged.size(); i++) { Message msg = msgLogged.get(i); SimpleDateFormat formatter = new SimpleDateFormat("H:mm:ssSSS"); String dateString = formatter.format(msg.getTimestamp()); switch (msg.getType()) { case Message.INFO_MSG: pLoggedMsg.add("[" + dateString + "] " + msg.getMessage()); break; case Message.WARN_MSG: pLoggedMsg.add("[" + dateString + "] WARN : " + msg.getMessage() + " at line : " + msg.getLine()); break; case Message.ERROR_MSG: pLoggedMsg.add("[" + dateString + "] ERROR : " + msg.getMessage() + " at line : " + msg.getLine()); break; default: break; } pLoggedMsg.add(Chunk.NEWLINE); } Paragraph pLastLogguedLines = new Paragraph(); int startIndex = msgLogged.size() > 5 ? msgLogged.size() - 5 : 0; for (int i = startIndex; i < msgLogged.size(); i++) { Message m = msgLogged.get(i); switch (m.getType()) { case Message.INFO_MSG: pLastLogguedLines.add("INFO : " + m.getMessage()); break; case Message.WARN_MSG: pLastLogguedLines.add("WARN : " + m.getMessage()); break; case Message.ERROR_MSG: pLastLogguedLines.add("ERROR : " + m.getMessage()); break; default: break; } pLastLogguedLines.add(Chunk.NEWLINE); } // l.setIndentationLeft(40); // Min/Max/Ave values /* * PdfPTable table = new PdfPTable(4); table.addCell(""); * table.addCell("Min"); table.addCell("Max"); table.addCell("Avg"); * * * table.addCell("Battery in %"); table.addCell(String.valueOf(dl * .getMinValueFromList(dl.getplt("BATTERY")))); * table.addCell(String.valueOf(dl * .getMaxValueFromList(dl.getplt("BATTERY")))); * table.addCell(String.valueOf(dl * .getAveValueFromList(dl.getplt("BATTERY")))); * table.addCell("Storage in bytes"); table.addCell(String.valueOf(dl * .getMinValueFromList(dl.getplt("Storage")))); * table.addCell(String.valueOf(dl * .getMaxValueFromList(dl.getplt("Storage")))); * table.addCell(String.valueOf(dl * .getAveValueFromList(dl.getplt("Storage")))); */ document.addTitle("REPORT"); document.addCreationDate(); HeaderFooter headerPage = new HeaderFooter(new Phrase("Execution report"), false); HeaderFooter footerPage = new HeaderFooter(new Phrase(" - "), new Phrase(" - ")); headerPage.setAlignment(Element.ALIGN_CENTER); footerPage.setAlignment(Element.ALIGN_CENTER); document.setHeader(headerPage); document.setFooter(footerPage); // Chapter 1 : Summary // Section 1 : Informations Chunk c = new Chunk("Summary"); c.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c.setFont(FONT_PAR_TITLE); Paragraph title1 = new Paragraph(c); title1.setAlignment("CENTER"); title1.setLeading(20); Chapter chapter1 = new Chapter(title1, 1); chapter1.setNumberDepth(0); Paragraph title11 = new Paragraph("Informations"); Section section1 = chapter1.addSection(title11); Paragraph pSum = new Paragraph(); pSum.add("Author : " + author); pSum.add(Chunk.NEWLINE); pSum.add("Group : " + group); pSum.add(Chunk.NEWLINE); pSum.add("Script : " + script); pSum.add(Chunk.NEWLINE); SimpleDateFormat formatter = new SimpleDateFormat("MMM d, yyyy - hh:mm aaa"); String dateString = formatter.format(endTime); pSum.add("Date : " + dateString); pSum.add(Chunk.NEWLINE); pSum.setIndentationLeft(20); section1.add(pSum); section1.add(new Paragraph(Chunk.NEXTPAGE)); Chunk c11 = new Chunk("Executive summary"); c11.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c11.setFont(FONT_PAR_TITLE); Paragraph title12 = new Paragraph(c11); Section section12 = chapter1.addSection(title12); Paragraph pExecSum = new Paragraph(); // pExecSum.add("Value : "); // pExecSum.add(Chunk.NEWLINE); // pExecSum.add(table); pExecSum.add(Chunk.NEWLINE); pExecSum.add("Last logged lines : "); pExecSum.add(Chunk.NEWLINE); pExecSum.add(pLastLogguedLines); pExecSum.add(Chunk.NEWLINE); pExecSum.setIndentationLeft(20); section12.add(pExecSum); try { document.add(chapter1); } catch (DocumentException e) { e.printStackTrace(); } document.newPage(); // Chapter 2 : Log information Chunk c2 = new Chunk("Log information"); c2.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c2.setFont(FONT_PAR_TITLE); Paragraph title2 = new Paragraph(c2); title2.setAlignment("CENTER"); title2.setLeading(20); Chapter chapter2 = new Chapter(title2, 1); chapter2.setNumberDepth(0); Section section2 = chapter2.addSection("Log"); // Add log information section2.add(pLoggedMsg); section2.add(Chunk.NEWLINE); // section2.add(table); try { document.add(chapter2); } catch (DocumentException e) { e.printStackTrace(); } document.newPage(); if (isParseErrorHappened) { document.close(); return; } // Add generated pictures Chunk c3 = new Chunk("Graphics"); c3.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c3.setFont(FONT_PAR_TITLE); Paragraph p3 = new Paragraph(c3); p3.setAlignment("CENTER"); p3.setLeading(20); Chapter chapter3 = new Chapter(p3, 1); chapter3.setNumberDepth(0); // add current graph Map<String, PlotList> mapint = dl.getMapint(); Set<String> cles = mapint.keySet(); Iterator<String> it = cles.iterator(); while (it.hasNext()) { String cle = (String) it.next(); Paragraph pCPUimg = new Paragraph(cle); Section section31 = chapter3.addSection(pCPUimg); if (new File(dl.getPNGpath(cle)).exists()) { Image jpg1 = null; try { jpg1 = Image.getInstance(dl.getPNGpath(cle)); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (jpg1 == null) { Logger.getLogger(this.getClass()).warn("Error when Creating image jpg1 is null"); return; } // jpg1.setRotationDegrees(270); jpg1.scalePercent(75); jpg1.setAlignment(Element.ALIGN_CENTER); section31.add(jpg1); PlotList plotlist = mapint.get(cle); DecimalFormat df = new DecimalFormat("#,###.##"); if (plotlist.getType() == PlotList.TYPE_SUM) { section31.add(new Paragraph("Total : " + df.format(plotlist.getTotal() / plotlist.getScale()) + " " + plotlist.getunit())); } else { // PlotList.TYPE_AVG section31.add(new Paragraph("Average : " + df.format(plotlist.getAverage() / plotlist.getScale()) + " " + plotlist.getunit())); } } section31.add(new Paragraph(Chunk.NEXTPAGE)); } /* * // Section 3.1 : CPU data Paragraph pCPUimg = new * Paragraph("CPU data"); Section section31 = * chapter3.addSection(pCPUimg); if (new * File(dl.getPNGpath("CPU")).exists()) { Image jpg1 = null; try { jpg1 * = Image.getInstance(dl.getPNGpath("CPU")); } catch * (BadElementException e) { e.printStackTrace(); } catch * (MalformedURLException e) { e.printStackTrace(); } catch (IOException * e) { e.printStackTrace(); } //jpg1.setRotationDegrees(270); * jpg1.scalePercent(75); jpg1.setAlignment(Element.ALIGN_CENTER); * section31.add(jpg1); } section31.add(new Paragraph(Chunk.NEXTPAGE)); * * // Section 3.2 : BAT data Paragraph pBATimg = new * Paragraph("Battery data"); Section section32 = * chapter3.addSection(pBATimg); if (new * File(dl.getPNGpath("BATTERY")).exists()) { Image jpg2 = null; try { * jpg2 = Image.getInstance(dl.getPNGpath("BATTERY")); } catch * (BadElementException e) { e.printStackTrace(); } catch * (MalformedURLException e) { e.printStackTrace(); } catch (IOException * e) { e.printStackTrace(); } //jpg2.setRotationDegrees(270); * jpg2.scalePercent(75); jpg2.setAlignment(Element.ALIGN_CENTER); * section32.add(jpg2); } section32.add(new Paragraph(Chunk.NEXTPAGE)); * * // Section 3.3 : MEM data Paragraph pMEMimg = new * Paragraph("Memory data"); Section section33 = * chapter3.addSection(pMEMimg); if (new * File(dl.getPNGpath("MEMORY")).exists()) { * * Image jpg3 = null; try { jpg3 = * Image.getInstance(dl.getPNGpath("MEMORY")); } catch * (BadElementException e) { e.printStackTrace(); } catch * (MalformedURLException e) { e.printStackTrace(); } catch (IOException * e) { e.printStackTrace(); } //jpg3.setRotationDegrees(270); * jpg3.scalePercent(75); jpg3.setAlignment(Element.ALIGN_CENTER); * section33.add(jpg3); } section33.add(new Paragraph(Chunk.NEXTPAGE)); * * // Section 3.4 : STO data Paragraph pSTOimg = new * Paragraph("Storage data"); Section section34 = * chapter3.addSection(pSTOimg); if (new * File(dl.getPNGpath("Storage")).exists()) { * * Image jpg4 = null; try { jpg4 = * Image.getInstance(dl.getPNGpath("Storage")); } catch * (BadElementException e) { e.printStackTrace(); } catch * (MalformedURLException e) { e.printStackTrace(); } catch (IOException * e) { e.printStackTrace(); } //jpg4.setRotationDegrees(270); * jpg4.scalePercent(75); jpg4.setAlignment(Element.ALIGN_CENTER); * section34.add(jpg4); } * * * // Section 3.5 : Network connection //Paragraph pNetworkimg = new * Paragraph("Network QoS data"); //Section section35 = * chapter3.addSection(pNetworkimg); // if (new * File(dl.getNetworkPNGfile()).exists()) { * * // Image jpg5 = null; // try { // jpg5 = * Image.getInstance(dl.getNetworkPNGfile()); // } catch * (BadElementException e) { // e.printStackTrace(); // } catch * (MalformedURLException e) { // e.printStackTrace(); // } catch * (IOException e) { // e.printStackTrace(); // } * //jpg4.setRotationDegrees(270); // jpg5.scalePercent(75); // * jpg5.setAlignment(Element.ALIGN_CENTER); // section35.add(jpg5); //} */ try { document.add(chapter3); } catch (DocumentException e) { e.printStackTrace(); } document.newPage(); // if (isTableEnabled) { // // Add tables filled with measurement // // Chapter 4 : Measurement tables // Chunk c4 = new Chunk("Statistics tables"); // c4.setBackground(new Color(0xFF, 0x66, 0x00), 200, 3f, 200f, 3f); // c4.setFont(FontFactory.getFont(BaseFont.HELVETICA, // BaseFont.WINANSI, BaseFont.NOT_EMBEDDED, 16)); // Paragraph title4 = new Paragraph(c4); // title4.setAlignment("CENTER"); // title4.setLeading(20); // Chapter chapter4 = new Chapter(title4, 1); // chapter4.setNumberDepth(0); // // // Section 4.1 : Battery value // Paragraph titleSection41 = new Paragraph("Battery value"); // Section section41 = chapter4.addSection(titleSection41); // Paragraph pBatList = new Paragraph(); // pBatList.add(Chunk.NEWLINE); // pBatList.add(createPDFTableFromList(dl // .getList(DocumentLogger.BATTERY), "Battery")); // pBatList.setAlignment("CENTER"); // section41.add(pBatList); // // // Section 4.2 : CPU value // Paragraph titleSection42 = new Paragraph("CPU value"); // Section section42 = chapter4.addSection(titleSection42); // Paragraph pCPUList = new Paragraph(); // pCPUList.add(Chunk.NEWLINE); // pCPUList.add(createPDFTableFromList(dl.getList(DocumentLogger.CPU), // "CPU")); // pCPUList.setAlignment("CENTER"); // section42.add(pCPUList); // // // Section 4.3 : Memory value // Paragraph titleSection43 = new Paragraph("Memory value"); // Section section43 = chapter4.addSection(titleSection43); // Paragraph pMemList = new Paragraph(); // pMemList.add(Chunk.NEWLINE); // pMemList.add(createPDFTableFromList(dl // .getList(DocumentLogger.MEMORY), "Memory")); // pMemList.setAlignment("CENTER"); // section43.add(pMemList); // // // Section 4.4 : Storage value // Paragraph titleSection44 = new Paragraph("Storage value"); // Section section44 = chapter4.addSection(titleSection44); // Paragraph pStoList = new Paragraph(); // pStoList.add(Chunk.NEWLINE); // pStoList.add(createPDFTableFromList(dl // .getList(DocumentLogger.STORAGE), "Storage")); // pStoList.setAlignment("CENTER"); // section44.add(pStoList); // // try { // document.add(chapter4); // } catch (DocumentException e) { // e.printStackTrace(); // } // } // step 5: we close the document document.close(); createHTMLFile(dl); }
From source file:com.orange.atk.results.logger.documentGenerator.PDFGenerator.java
License:Apache License
public void dumpInStreamactionlogger(boolean isParseErrorHappened, ActionsLogger actionlog, DocumentLogger dl) { long endTime = new Date().getTime(); // step 1: creation of a document-object Document document = new Document(); PdfWriter writer = null;//ww w . ja v a2 s .com Vector VectAction = actionlog.getActions(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to the outputStream try { writer = PdfWriter.getInstance(document, outputStream); } catch (DocumentException e1) { e1.printStackTrace(); return; } writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); // step 3: we open the document document.open(); // step 4: we add a paragraph to the document Paragraph pLoggedMsg = new Paragraph(); // logged messages for (int i = 0; i < VectAction.size(); i++) { Action action = (Action) VectAction.get(i); SimpleDateFormat formatter = new SimpleDateFormat("H:mm:ssSSS"); SimpleDateFormat spf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss SSS"); String dateString = spf.format(action.getStartTime()); pLoggedMsg.add("[" + dateString + "] : " + action.getActionName()); pLoggedMsg.add(Chunk.NEWLINE); } Paragraph pLastLogguedLines = new Paragraph(); int startIndex = VectAction.size() > 5 ? VectAction.size() - 5 : 0; for (int i = startIndex; i < VectAction.size(); i++) { Action action = (Action) VectAction.get(i); // SimpleDateFormat formatter = new SimpleDateFormat("H:mm:ssSSS"); SimpleDateFormat spf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss SSS"); String dateString = spf.format(action.getStartTime()); pLastLogguedLines.add("[" + dateString + "] : " + action.getActionName()); pLastLogguedLines.add(Chunk.NEWLINE); } document.addTitle("REPORT"); document.addCreationDate(); HeaderFooter headerPage = new HeaderFooter(new Phrase("Execution report"), false); HeaderFooter footerPage = new HeaderFooter(new Phrase(" - "), new Phrase(" - ")); headerPage.setAlignment(Element.ALIGN_CENTER); footerPage.setAlignment(Element.ALIGN_CENTER); document.setHeader(headerPage); document.setFooter(footerPage); // Chapter 1 : Summary // Section 1 : Informations Chunk c = new Chunk("Summary"); c.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c.setFont(FONT_PAR_TITLE); Paragraph title1 = new Paragraph(c); title1.setAlignment("CENTER"); title1.setLeading(20); Chapter chapter1 = new Chapter(title1, 1); chapter1.setNumberDepth(0); Paragraph title11 = new Paragraph("Informations"); Section section1 = chapter1.addSection(title11); Paragraph pSum = new Paragraph(); pSum.add("Author : " + author); pSum.add(Chunk.NEWLINE); pSum.add("Group : " + group); pSum.add(Chunk.NEWLINE); pSum.add("Script : " + script); pSum.add(Chunk.NEWLINE); SimpleDateFormat formatter = new SimpleDateFormat("MMM d, yyyy - hh:mm aaa"); String dateString = formatter.format(endTime); pSum.add("Date : " + dateString); pSum.add(Chunk.NEWLINE); pSum.setIndentationLeft(20); section1.add(pSum); section1.add(new Paragraph(Chunk.NEXTPAGE)); Chunk c11 = new Chunk("Executive summary"); c11.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c11.setFont(FONT_PAR_TITLE); Paragraph title12 = new Paragraph(c11); Section section12 = chapter1.addSection(title12); Paragraph pExecSum = new Paragraph(); // pExecSum.add("Value : "); // pExecSum.add(Chunk.NEWLINE); // pExecSum.add(table); pExecSum.add(Chunk.NEWLINE); pExecSum.add("Last logged lines : "); pExecSum.add(Chunk.NEWLINE); pExecSum.add(pLastLogguedLines); pExecSum.add(Chunk.NEWLINE); pExecSum.setIndentationLeft(20); section12.add(pExecSum); try { document.add(chapter1); } catch (DocumentException e) { e.printStackTrace(); } document.newPage(); // Chapter 2 : Log information Chunk c2 = new Chunk("Log information"); c2.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c2.setFont(FONT_PAR_TITLE); Paragraph title2 = new Paragraph(c2); title2.setAlignment("CENTER"); title2.setLeading(20); Chapter chapter2 = new Chapter(title2, 1); chapter2.setNumberDepth(0); Section section2 = chapter2.addSection("Log"); // Add log information section2.add(pLoggedMsg); section2.add(Chunk.NEWLINE); // section2.add(table); try { document.add(chapter2); } catch (DocumentException e) { e.printStackTrace(); } document.newPage(); if (isParseErrorHappened) { document.close(); return; } // Add generated pictures Chunk c3 = new Chunk("Graphics"); c3.setBackground(ORANGE_COLOR, 200, 3f, 200f, 3f); c3.setFont(FONT_PAR_TITLE); Paragraph p3 = new Paragraph(c3); p3.setAlignment("CENTER"); p3.setLeading(20); Chapter chapter3 = new Chapter(p3, 1); chapter3.setNumberDepth(0); // add current graph Map<String, PlotList> mapint = dl.getMapint(); Set<String> cles = mapint.keySet(); Iterator<String> it = cles.iterator(); while (it.hasNext()) { String cle = (String) it.next(); Paragraph pCPUimg = new Paragraph(cle); Section section31 = chapter3.addSection(pCPUimg); if (new File(dl.getPNGpath(cle)).exists()) { Image jpg1 = null; try { jpg1 = Image.getInstance(dl.getPNGpath(cle)); } catch (BadElementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (jpg1 == null) { Logger.getLogger(this.getClass()).warn("Error when Creating image jpg1 is null"); return; } // jpg1.setRotationDegrees(270); jpg1.scalePercent(75); jpg1.setAlignment(Element.ALIGN_CENTER); section31.add(jpg1); } section31.add(new Paragraph(Chunk.NEXTPAGE)); } try { document.add(chapter3); } catch (DocumentException e) { e.printStackTrace(); } document.newPage(); document.close(); createHTMLFileactionlog(actionlog, dl); }
From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java
License:Open Source License
private void addMainOrders(Document document, List<OrderOperationComponent> orderOperationComponents, Locale locale) throws DocumentException { List<Entity> orders = getMainOrdersForOperationComponents(orderOperationComponents); for (Entity order : orders) { Entity product = order.getBelongsToField(OrderFields.PRODUCT); Paragraph mainOrder = new Paragraph( new Phrase(prepareMainOrderSummary(order, product, locale), FontUtils.getDejavuBold9Dark())); mainOrder.setIndentationLeft(3f); document.add(mainOrder);/* w w w . j av a 2s . c o m*/ } }
From source file:Controleur.CtrlImprimerOrdonnance.java
public void RemplirOrdonnance() { ResultSet res;// w w w . j a v a2 s . com String nomEtablissement = ""; String adresseEtablissement = ""; int telEtablissement = 0; String nomPatient = ""; String prenomPatient = ""; String dateNaissPatient = null; String traitement = ""; Etablissement etab = new Etablissement(); try { res = etab.getEtablissement(); nomEtablissement = res.getString("nomEtab"); adresseEtablissement = res.getString("adresseEtab"); telEtablissement = res.getInt("telEtab"); } catch (SQLException e) { JOptionPane.showMessageDialog(null, "erreur \n" + e.getMessage()); } Medecin med1 = new Medecin(); Medecin med2 = med1.getMedecinById(Fen.getIdm()); String nomMedecin = med2.getNomMedecin(); String prenomMedecin = med2.getPrenomMedecin(); String specialiteMedecin = med2.getSpecialite(); Patient patient = new Patient(); res = patient.getPatient(Fen.getIdp()); try { res.next(); nomPatient = res.getString("nomPatient"); prenomPatient = res.getString("prenomPatient"); dateNaissPatient = res.getString("dateNaissance"); } catch (SQLException e) { JOptionPane.showMessageDialog(null, "erreur \n" + e.getMessage()); } traitement = Fen.getTxtTraitement().getText(); Document document = new Document(PageSize.A4); try { PdfWriter.getInstance(document, new FileOutputStream("./ordonnance.pdf")); document.open(); Date d = new Date(); Paragraph paragraph = new Paragraph(d.toLocaleString(), FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD)); paragraph.setAlignment(Element.ALIGN_RIGHT); paragraph.setIndentationRight(50f); document.add(paragraph); paragraph = new Paragraph("Dr " + nomMedecin + " " + prenomMedecin, FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD)); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph("SPECIALISTE EN " + specialiteMedecin); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(nomEtablissement); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(adresseEtablissement); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph("Tl : " + telEtablissement); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(" "); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph("nom & prenom :" + nomPatient + " " + prenomPatient, FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD)); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph("Ne(e) le :" + dateNaissPatient); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(" "); paragraph.setIndentationLeft(50f); document.add(paragraph); Chunk chunk = new Chunk("Ordonnance", FontFactory.getFont(FontFactory.COURIER, 30, Font.BOLD)); chunk.setUnderline(Color.BLACK, 3.0f, 0.0f, 0.0f, -0.2f, PdfContentByte.LINE_CAP_BUTT); paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.add(chunk); document.add(paragraph); paragraph = new Paragraph(" "); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(traitement); paragraph.setIndentationLeft(50f); document.add(paragraph); Runtime r = Runtime.getRuntime(); r.exec("cmd /C ./ordonnance.pdf"); } catch (DocumentException de) { de.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } document.close(); }
From source file:datasoul.servicelist.ServiceListExporterDocument.java
License:Open Source License
public void addServicePlan() throws DocumentException { ServiceListTable slt = ServiceListTable.getActiveInstance(); Paragraph p = new Paragraph( java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("SERVICE PLAN"), FontFactory.getFont(FontFactory.HELVETICA, 12)); p.setAlignment(Element.ALIGN_CENTER); document.add(p);//from w w w . j a v a 2s .c o m p = new Paragraph(slt.getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16)); p.setAlignment(Element.ALIGN_CENTER); document.add(p); Table t = new Table(4); t.setWidths(new int[] { 10, 5, 50, 35 }); t.setPadding(2.0f); t.setWidth(100.0f); t.addCell(createHeaderCell( java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("TIME"))); t.addCell( createHeaderCell(java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("MIN"))); t.addCell(createHeaderCell( java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("TITLE"))); t.addCell(createHeaderCell( java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("NOTES"))); for (int i = 0; i < slt.getRowCount(); i++) { ServiceItem si = (ServiceItem) slt.getServiceItem(i); Cell c; // Start time c = new Cell(si.getStartTime()); c.setMaxLines(1); c.setVerticalAlignment(Cell.ALIGN_MIDDLE); c.setHorizontalAlignment(Cell.ALIGN_CENTER); t.addCell(c); // Duration c = new Cell(Integer.toString(si.getDuration())); c.setMaxLines(1); c.setVerticalAlignment(Cell.ALIGN_MIDDLE); c.setHorizontalAlignment(Cell.ALIGN_RIGHT); t.addCell(c); // Title c = new Cell(si.getTitle()); c.setVerticalAlignment(Cell.ALIGN_MIDDLE); t.addCell(c); // Notes c = new Cell(si.getNotes()); c.setVerticalAlignment(Cell.ALIGN_MIDDLE); t.addCell(c); } document.add(t); p = new Paragraph(java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("NOTES"), FontFactory.getFont(FontFactory.HELVETICA_BOLD)); document.add(p); p = new Paragraph(slt.getNotes(), FontFactory.getFont(FontFactory.HELVETICA)); p.setIndentationLeft(10.0f); document.add(p); document.newPage(); }
From source file:EplanPrinter.RTFWrite.java
License:Open Source License
public String addItem(String comment, String category, String group) throws DocumentException, IOException { if (cg.compareTo(group) != 0) { count = 1;/* w ww . j av a 2 s .c o m*/ cg = group; cc = category; Font groupContent = new Font(); groupContent.setStyle("bold"); groupContent.setStyle("underline"); groupContent.setSize(12); Paragraph g = new Paragraph(group, groupContent); Font catContent = new Font(); catContent.setSize(12); Paragraph c = new Paragraph(category, catContent); c.setIndentationLeft(30); document.add(g); document.add(c); } else if (cc.compareTo(category) != 0) { count = 1; cc = category; Paragraph c = new Paragraph(category); c.setIndentationLeft(30); document.add(c); } Paragraph p = new Paragraph(); //document.add(p); String test = count + ". " + comment; test = test.replaceAll("<p>", " "); test = test.replaceAll("</p>", " "); if (test.indexOf("<ol>") != -1) { test = test.replaceAll("<ol>", ""); test = test.replaceAll("</ol>", ""); test = test.replaceAll("</li>", "<br />"); int subCount = 1; while (test.indexOf("<li>") != -1) { test = test.replaceFirst("<li>", subCount + ". "); subCount++; } int marker = test.lastIndexOf("<br />"); String sub1 = test.substring(0, marker); String sub2 = test.substring(marker); sub2 = sub2.replaceAll("<br />", ""); test = sub1 + sub2; } if (test.indexOf("<ul>") != -1) { test = test.replaceAll("<ul>", ""); test = test.replaceAll("</ul>", ""); test = test.replaceAll("</li>", "<br />"); int c = 149; char ch = (char) 149; test = test.replaceAll("<li>", "•"); int marker = test.lastIndexOf("<br />"); String sub1 = test.substring(0, marker); String sub2 = test.substring(marker); sub2 = sub2.replaceAll("<br />", ""); test = sub1 + sub2; } StringReader str = new StringReader(test); List<Element> e = HTMLWorker.parseToList(str, null); for (int k = 0; k < e.size(); ++k) { p.add((com.lowagie.text.Element) e.get(k)); } p.setIndentationLeft(40); p.setFirstLineIndent(30); document.add(p); count = count + 1; return ""; }
From source file:fr.aliasource.webmail.server.export.ConversationExporter.java
License:GNU General Public License
@SuppressWarnings("unchecked") private void exportMessage(Set<ClientMessage> cm, Document d, boolean isForward) throws DocumentException { LineSeparator hr = new LineSeparator(); StyleSheet styles = new StyleSheet(); Font fnormal = new Font(Font.HELVETICA, 9, Font.NORMAL); Font fbold = new Font(Font.HELVETICA, 9, Font.BOLD); Iterator<ClientMessage> it = cm.iterator(); Cell c = null;/*from w w w.j av a 2 s .co m*/ while (it.hasNext()) { ClientMessage fwdCm = it.next(); if (isForward) { c = new Cell(); } // Subject (only if isForward) if (isForward) { String subjectText = fwdCm.getSubject(); String dateText = formatDate(fwdCm.getDate()); Chunk subject = new Chunk(subjectText, fbold); Chunk date = new Chunk(dateText, fbold); Paragraph subjectPar = new Paragraph(subject + ", " + date); subjectPar.setIndentationLeft(5.0f); c.add(subjectPar); c.add(Chunk.NEWLINE); } else { String dateText = formatDate(fwdCm.getDate()); Chunk date = new Chunk(dateText, fbold); Paragraph datePar = new Paragraph(date); datePar.setAlignment(Element.ALIGN_RIGHT); d.add(datePar); } // Sender String senderText = formatAddress(fwdCm.getSender()); Chunk sender = new Chunk(senderText, fbold); sender.setTextRise(10.0f); Paragraph senderPar = new Paragraph(sender); if (isForward) { senderPar.setIndentationLeft(5.0f); c.add(senderPar); } else { d.add(senderPar); } appendRecipients(d, c, isForward, "To:", fwdCm.getTo()); appendRecipients(d, c, isForward, "Cc:", fwdCm.getCc()); appendRecipients(d, c, isForward, "Bcc:", fwdCm.getBcc()); if (isForward) { c.add(Chunk.NEWLINE); } // Body String bodyText = fwdCm.getBody().getCleanHtml(); Paragraph bodyPar = new Paragraph(); bodyPar.setFont(fnormal); if (bodyText != null && !bodyText.isEmpty()) { try { List<Element> objects = HTMLWorker.parseToList(new StringReader(bodyText), styles); for (Iterator<Element> iterator = objects.iterator(); iterator.hasNext();) { Element el = iterator.next(); if (!(el instanceof Image)) { // bodyPar.add(el); if (isForward) { c.add(el); } else { bodyPar.add(el); } } } } catch (Exception e) { logger.warn("Cannot generate pdf from html body use plain text instead", e); // bodyPar.add(fwdCm.getBody().getPlain()); if (isForward) { Chunk t = new Chunk(fwdCm.getBody().getPlain()); t.setFont(fnormal); c.add(t); } else { bodyPar.add(fwdCm.getBody().getPlain()); } } } else { if (isForward) { Chunk t = new Chunk(fwdCm.getBody().getPlain()); t.setFont(fnormal); c.add(t); } else { bodyPar.add(fwdCm.getBody().getPlain()); } } if (isForward) { // c.add(bodyPar); Table t = new Table(1); t.setPadding(5); t.setBackgroundColor(new Color(242, 242, 242)); t.addCell(c); d.add(t); } else { bodyPar.setIndentationLeft(15.0f); d.add(bodyPar); } if (fwdCm.getFwdMessages() != null) { this.exportMessage(fwdCm.getFwdMessages(), d, true); } d.add(hr); } }
From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.utils.PDFUtils.java
License:Open Source License
/** * method to builder PDF with directory entry * @param document document pdf//from www . j av a2s . c o m * @param plugin plugin * @param nIdRecord id record * @param listEntry list of entry * @param listIdEntryConfig list of config id entry * @param locale the locale * @param bExtractNotFilledField if true, extract empty fields, false */ private static void builderPDFWithEntry(Document document, Plugin plugin, int nIdRecord, List<IEntry> listEntry, List<Integer> listIdEntryConfig, Locale locale, Boolean bExtractNotFilledField) { Map<String, List<RecordField>> mapIdEntryListRecordField = DirectoryUtils .getMapIdEntryListRecordField(listEntry, nIdRecord, plugin); for (IEntry entry : listEntry) { if (entry.getEntryType().getGroup() && (listIdEntryConfig.isEmpty() || listIdEntryConfig.contains(Integer.valueOf(entry.getIdEntry())))) { Font fontEntryTitleGroup = new Font( DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)), DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_ENTRY_GROUP)), DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_ENTRY_GROUP))); Paragraph paragraphTitleGroup = new Paragraph(new Phrase(entry.getTitle(), fontEntryTitleGroup)); paragraphTitleGroup.setAlignment(Element.ALIGN_LEFT); paragraphTitleGroup.setIndentationLeft(DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty(PROPERTY_POLICE_MARGIN_LEFT_ENTRY_GROUP))); paragraphTitleGroup.setSpacingBefore(DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_BEFORE_ENTRY_GROUP))); paragraphTitleGroup.setSpacingAfter(DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_AFTER_ENTRY_GROUP))); try { document.add(paragraphTitleGroup); } catch (DocumentException e) { AppLogService.error(e); } if (entry.getChildren() != null) { for (IEntry child : entry.getChildren()) { if (listIdEntryConfig.isEmpty() || listIdEntryConfig.contains(Integer.valueOf(child.getIdEntry()))) { try { builFieldsInPDF(mapIdEntryListRecordField.get(Integer.toString(child.getIdEntry())), document, child, locale, bExtractNotFilledField); } catch (DocumentException e) { AppLogService.error(e); } } } } } else { if (listIdEntryConfig.isEmpty() || listIdEntryConfig.contains(Integer.valueOf(entry.getIdEntry()))) { try { builFieldsInPDF(mapIdEntryListRecordField.get(Integer.toString(entry.getIdEntry())), document, entry, locale, bExtractNotFilledField); } catch (DocumentException e) { AppLogService.error(e); } } } } }
From source file:fr.univlorraine.mondossierweb.controllers.CalendrierController.java
License:Apache License
/** * //from w w w. ja v a2s .c om * @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(); }