List of usage examples for com.lowagie.text Paragraph setLeading
public void setLeading(float fixedLeading)
From source file:com.fcore.base.fileSystem.utils.FileUtil.java
/** * convert txt file to pdf //from w ww. j a v a 2 s . co m * @param originalPath * @param dirPath */ public static void txt2pdf(String originalPath, String dirPath) { com.lowagie.text.Document document = null; BufferedReader read = null; long old = System.currentTimeMillis(); try { document = new com.lowagie.text.Document(PageSize.A4, 80, 80, 60, 30); PdfWriter.getInstance(document, new FileOutputStream(dirPath)); document.open(); BaseFont bfChinese = BaseFont.createFont(ReadCreatePdf.class.getResource("/") + "/simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font FontChinese = new Font(bfChinese, 18, Font.NORMAL); FileInputStream fstream = new FileInputStream(originalPath); DataInputStream in = new DataInputStream(fstream); read = new BufferedReader(new InputStreamReader(in, "gb2312")); String line = null; while ((line = read.readLine()) != null) { Paragraph t = new Paragraph(line, FontChinese); t.setAlignment(Element.ALIGN_LEFT); t.setLeading(20.0f); document.add(t); } } catch (Exception e) { e.printStackTrace(); } finally { try { read.close(); document.close(); } catch (IOException e) { e.printStackTrace(); } } long now = System.currentTimeMillis(); System.out.println("" + ((now - old) / 1000.0) + "\n\n" + "?:" + dirPath); }
From source file:com.gtdfree.test.TableBorders.java
License:Open Source License
private static PdfPCell makeCell(String text, int vAlignment, int hAlignment, Font font, float leading, float padding, Rectangle borders, boolean ascender, boolean descender) { Paragraph p = new Paragraph(text, font); p.setLeading(leading); PdfPCell cell = new PdfPCell(p); cell.setLeading(leading, 0);/*from w w w. j a v a 2 s . c o m*/ cell.setVerticalAlignment(vAlignment); cell.setHorizontalAlignment(hAlignment); cell.cloneNonPositionParameters(borders); cell.setUseAscender(ascender); cell.setUseDescender(descender); cell.setUseBorderPadding(true); cell.setPadding(padding); return cell; }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeTitle(Document document, String title) throws Exception { Paragraph titleParagraph = new Paragraph(title, titleFont); titleParagraph.setAlignment(Element.ALIGN_LEFT); titleParagraph.setLeading(30); titleParagraph.setSpacingAfter(2);//from ww w . ja va 2s . c o m document.add(titleParagraph); }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeSubTitle(Document document, String title) throws Exception { Paragraph titleParagraph = new Paragraph(title, subTitleFont); titleParagraph.setAlignment(Element.ALIGN_LEFT); titleParagraph.setLeading(20); titleParagraph.setSpacingAfter(2);/*from w ww. j a v a 2s . c o m*/ document.add(titleParagraph); }
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) *//* ww w . j ava 2 s. co 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) *//*from ww w . j a v a 2 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;//from w w w .j a v a 2s. c om 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.sinkluge.reports.contracts.GenSubcontract.java
public void create(Info in, Image toplogo) throws Exception { //for the unchecked box Image checkbox = Image.getInstance(in.path + "/WEB-INF/images/unchecked.jpg"); Chunk ch2 = new Chunk(checkbox, -7, -7); Phrase checkboxPhrase = new Phrase(); checkboxPhrase.add(ch2);/*from w w w .j av a 2 s .c om*/ Font tnr8 = new Font(Font.TIMES_ROMAN, 8, Font.NORMAL); Image iBox = Image.getInstance(in.path + "/WEB-INF/images/initialsBox.jpg");//(in.path + "/jsp/dev/images/epcologo3.jpg"); Chunk ch3 = new Chunk(iBox, -3, -3); Phrase initialsBoxPhrase = new Phrase(); initialsBoxPhrase.add(ch3); Phrase footerPhrase = new Phrase( attr.get("full_name") + ", " + attr.get("address") + ", " + attr.get("city") + ", " + attr.get("state") + " " + attr.get("zip") + "\nPhone: " + attr.get("phone") + " Fax: " + attr.get("fax") + " " + attr.get("url") + " Page: ", new Font(Font.TIMES_ROMAN, 7, Font.BOLD | Font.ITALIC)); HeaderFooter footer = new HeaderFooter(footerPhrase, true); footer.setBorder(0); footer.setAlignment(Element.ALIGN_CENTER); init(40, 40, 40, 40, footer); Phrase underLinePhrase = new Phrase( " ___________________________________________________________________________________________ ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)); int[] twoC = { 30, 70 }; int[] twoD = { 5, 95 }; int[] twoF = { 10, 90 }; int[] twoE = { 25, 75 }; int[] twoG = { 40, 60 }; int[] threeD = { 4, 11, 85 }; int[] threeB = { 70, 15, 15 }; //int[] threeC = { 47, 5, 48 }; int[] five = { 18, 25, 14, 18, 25 }; //blank spacer for keeping tables apart Table spacer = new Table(1, 1); spacer.setBorderWidth(0); //spacer.setDefaultCellBorderWidth(0); spacer.setWidth(100); spacer.setPadding(0); spacer.setSpacing(0); Cell blank = new Cell(); blank.add(new Chunk("", new Font(Font.TIMES_ROMAN, 8, Font.BOLD, new Color(255, 255, 255)))); blank.setBorderWidth(0); //blank.setLeading(0); spacer.addCell(blank); //start of document //document.setFooter(footer); //document.setFooter(footer); //add image Phrase p1 = new Phrase(); Table table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(2); table1.setSpacing(2); toplogo.scalePercent(20); //Chunk ch1=new Chunk(toplogo, -36, -55); //p1.add(ch1); Cell cell = new Cell(toplogo); cell.setBorderWidth(0); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); table1.addCell(cell); document.add(table1); document.add(spacer); document.add(spacer); document.add(spacer); document.add(spacer); document.add(spacer); document.add(spacer); document.add(spacer); document.add(spacer); document.add(spacer); document.add(spacer); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setLeading(19); cell.add( new Phrase(title.toUpperCase() + " AGREEMENT BETWEEN CONTRACTOR AND " + cTitle.toUpperCase() + "\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD))); cell.setUseDescender(true); cell.setBackgroundColor(Color.lightGray); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setSpacing(0); cell = new Cell(); cell.add(underLinePhrase); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("\nDOCUMENTS CONTAINED HEREIN:\n", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(3, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setWidths(threeD); table1.setPadding(0); table1.setSpacing(0); table1.addCell(blank); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Page 1", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Agreement Declaration", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.add(new Phrase(" Initial boxes below to indicate complete review of this agreement.", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); table1.addCell(blank); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Page 2", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Articles of " + title + " Agreement and Standard Provisions", tnr8)); cell.add(new Phrase(" Sign the concluding page.", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); table1.addCell(blank); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Exhibit \"A\"", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("List of Contract Documents, Plans, Specifications, Etc.", tnr8)); cell.setBorder(0); //cell.add(new Phrase(" Read and initial each page.", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC))); table1.addCell(cell); table1.addCell(blank); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Exhibit \"B\"", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(cTitle + "'s Scope of Work", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); table1.addCell(blank); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Exhibit \"C\"", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(cTitle + "'s Special Provisions and Procedure Requirements", tnr8)); cell.add(new Phrase(" Read and complete \"Release Authorization\" information.", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); table1.addCell(blank); if (insure) { cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Exhibit \"D\"", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(cTitle + " Cost Breakdown", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.add(new Phrase(" Complete and return with signed contract", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); table1.addCell(blank); } cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.setColspan(2); cell.add(new Phrase("NOTE OTHERS HERE:", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(3); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setWidths(threeB); table1.addCell(blank); cell = new Cell(); cell.setColspan(2); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("(Initial) Entire agreement thoroughly reviewed:\n", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); table1.addCell(blank); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Contractor: ________", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(cTitle + ": ________", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setColspan(3); cell.add(underLinePhrase); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("AGREEMENT", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.add(new Phrase(" made as of " + agreementDate, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase("BETWEEN", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.add(new Phrase(" the Contractor: \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + attr.get("full_name") + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + attr.get("address") + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + attr.get("city") + ", " + attr.get("state") + " " + attr.get("zip"), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" (hereinafter known as \"Contractor\")\n", new Font(Font.TIMES_ROMAN, 6, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase("AND", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.add(new Phrase(" the " + cTitle + ": \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + subName + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + subAddress + "\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + subCityStateZip, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" (hereinafter known as \"" + cTitle + "\")\n", new Font(Font.TIMES_ROMAN, 6, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase("FOR", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.add(new Phrase(" the the fixed sum of " + DocHelper.numberAndText(amount) + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); //cell.add(new Phrase(" " + amountString + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase("FOR", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.add(new Phrase(" the Project known as:\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + projectName + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + projectAddress + "\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + projectCityStateZip, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" (hereinafter known as \"Project\")\n", new Font(Font.TIMES_ROMAN, 6, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase("BY", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.add(new Phrase(" the Architect:\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + architectName + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + architectAddress + "\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + architectCityStateZip, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" (hereinafter known as \"Architect\")\n", new Font(Font.TIMES_ROMAN, 6, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase("FOR", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.add(new Phrase(" the Project owner:\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + ownerName + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + ownerAddress + "\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" " + ownerCityStateZip, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase(" (hereinafter known as \"Owner\")\n", new Font(Font.TIMES_ROMAN, 6, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("WHEREFORE", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.add(new Phrase(" the Contractor and " + cTitle + " agree as follows:\n\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); document.add(table1); /* table1 = new Table(1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); //cell.add(new Phrase("\n", new Font(Font.TIMES_ROMAN, 6, Font.NORMAL))); cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP); cell.setBorderWidth(1.1f); cell.add(footerPhrase); cell.add(new Phrase(" 1\n ", new Font(Font.TIMES_ROMAN, 6, Font.NORMAL))); //cell.add(footerPhrase2); cell.setBorder(0); table1.addCell(cell); document.add(table1); */ document.newPage(); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(title.toUpperCase() + " AGREEMENT\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD))); cell.setBackgroundColor(Color.lightGray); cell.setLeading(19); cell.setUseDescender(true); cell.setBorder(0); table1.addCell(cell); document.add(table1); Paragraph para = new Paragraph(8, "\n\n" + text.toString(), tnr8); document.add(para); Phrase p; document.add(spacer); table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setWidths(twoC); table1.setPadding(0); p = new Phrase("Date:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(p); cell.setBorder(0); table1.addCell(cell); p = new Phrase("Signed:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(p); cell.setBorder(0); table1.addCell(cell); p = new Phrase("_______________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(p); cell.setBorder(0); table1.addCell(cell); p = new Phrase("_________________________________________________________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(p); cell.setBorder(0); table1.addCell(cell); table1.addCell(blank); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(" General Contractor Title\n", tnr8)); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setColspan(2); cell.add(new Phrase("\nThis " + title + " Agreement supercedes all other proposals, documents, and negotiations whether written or verbal\n\n", new Font(Font.TIMES_ROMAN, 8, Font.BOLDITALIC))); cell.setBorder(0); table1.addCell(cell); p = new Phrase("Date:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(p); cell.setBorder(0); table1.addCell(cell); p = new Phrase("Signed:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(p); cell.setBorder(0); table1.addCell(cell); p = new Phrase("_______________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(p); cell.setBorder(0); table1.addCell(cell); p = new Phrase("_________________________________________________________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(p); cell.setBorder(0); table1.addCell(cell); table1.addCell(blank); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase( " " + cTitle + " Title\n", tnr8)); cell.setBorder(0); table1.addCell(cell); table1.setCellsFitPage(true); table1.setTableFitsPage(true); document.add(table1); document.newPage(); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(cTitle.toUpperCase() + " INFORMATION\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD))); cell.setBackgroundColor(Color.lightGray); cell.setLeading(19); cell.setUseDescender(true); cell.setBorder(0); table1.addCell(cell); document.add(table1); document.add(new Phrase("\n")); table1 = new Table(5, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(1); table1.setWidths(five); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Federal I.D. : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setBorder(15); cell.add(new Phrase(federal_id, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setUseDescender(true); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("(Both Required)", new Font(Font.TIMES_ROMAN, 8, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("License Number : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setBorder(15); cell.add(new Phrase(license_number, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setUseDescender(true); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Contact : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setBorder(15); cell.setUseDescender(true); cell.add(new Phrase(contactName, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 8, Font.BOLD))); cell.setUseDescender(true); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Company : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setBorder(15); cell.add(new Phrase(subName, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setUseDescender(true); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Telephone : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setBorder(15); cell.setUseDescender(true); cell.add(new Phrase(telephone, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 8, Font.BOLD))); cell.setUseDescender(true); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Fax : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setBorder(15); cell.add(new Phrase(fax, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setUseDescender(true); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Mobile phone : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setBorder(15); cell.add(new Phrase(mobile, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setUseDescender(true); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 8, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("E-mail : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.setBorder(15); cell.add(new Phrase(email, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setUseDescender(true); table1.addCell(cell); document.add(table1); //document.add(spacer); table1 = new Table(1, 1); //table1.setBorderWidth(4); //table1.setBorderColor(Color.lightGray); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setBorder(0); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); if (insure) cell.add(new Phrase("Please attach a COPY of your current state license to this page:", new Font(Font.TIMES_ROMAN, 12, Font.NORMAL))); else cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 12, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); document.add(table1); document.add(spacer); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); if (insure) cell.add(new Phrase("\n\nAttach\nCopy of\nContractor's\nLicense\nHere\n(If Applicable)", new Font(Font.TIMES_ROMAN, 24, Font.NORMAL, Color.lightGray))); else cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 24, Font.NORMAL, Color.lightGray))); cell.setBorder(0); table1.addCell(cell); document.add(table1); //document.setMargins(72, 72, 36, 36); document.newPage(); table1 = new Table(1, 1); table1.setOffset(0); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setWidth(100); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(title.toUpperCase() + " EXHIBIT \"A\"\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD))); cell.setLeading(6); cell.setBorder(0); table1.addCell(cell); cell = new Cell(new Phrase("\n", new Font(Font.TIMES_ROMAN, 8))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("CONTRACT DOCUMENTS, PLANS,\nSPECIFICATIONS, ADDENDUMS, ETC.\n", new Font(Font.TIMES_ROMAN, 16, Font.BOLD))); cell.setUseDescender(true); cell.setLeading(17); cell.setBackgroundColor(Color.lightGray); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("\n" + subName + " is responsible to verify versions, dates, and completeness of documents that were used in the preparation of the " + cTitle + "'s bid proposal before signing this " + title + " Agreement\n", tnr8)); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("This " + title + " Agreement includes, but is not limited to the following items:", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setUseDescender(true); cell.setBorder(Rectangle.BOTTOM); cell.setBorderWidth(0.5f); table1.addCell(cell); document.add(table1); Paragraph prgh = new Paragraph("\n" + bidDocuments + "\n", tnr8); prgh.setLeading(10); document.add(prgh); document.add(spacer); /* p = new Phrase("\n"+bidDocuments, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p.setLeading(10); cell= new Cell(p); cell.setBorder(Rectangle.TOP | Rectangle.BOTTOM); cell.setBorderWidth(0.5f); //cell.setBorderColor(Color.lightGray); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.setUseDescender(true); table1.addCell(cell); */ table1 = new Table(1, 1); table1.setOffset(0); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setWidth(100); table1.setTableFitsPage(true); p = new Phrase("\nPlease note below all verbal conditions or instructions, if any, that the " + cTitle + " has received during the bid process which might affect the scope of work as required by the contract documents", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p.setLeading(10); cell = new Cell(p); cell.setBorder(Rectangle.TOP); cell.setBorderWidth(0.5f); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); table1.addCell(cell); document.add(table1); document.newPage(); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setOffset(0); table1.setWidth(100); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(title.toUpperCase() + " EXHIBIT \"B\"\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD))); cell.setLeading(6); cell.setBorder(0); table1.addCell(cell); cell = new Cell(new Phrase("\n", new Font(Font.TIMES_ROMAN, 8))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("SCOPE OF WORK\n", new Font(Font.TIMES_ROMAN, 16, Font.BOLD))); cell.setBackgroundColor(Color.lightGray); cell.setUseDescender(true); cell.setLeading(17); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase( "\nThis " + title + " Agreement includes, but is not limited to the following items:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.setBorder(Rectangle.BOTTOM); cell.setBorderWidth(0.5f); table1.addCell(cell); document.add(table1); prgh = new Paragraph("\n" + contractDescription + "\n", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)); prgh.setLeading(10); document.add(prgh); //cell= new Cell(prgh); //cell.setBorder(Rectangle.TOP | Rectangle.BOTTOM); //cell.setBorderWidth(0.5f); //cell.setBorderColor(Color.lightGray); //cell.setHorizontalAlignment("left"); //cell.setVerticalAlignment("middle"); //cell.setLeading(10); //cell.setUseDescender(true); //table1.addCell(cell); document.add(spacer); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setOffset(0); table1.setWidth(100); table1.setTableFitsPage(true); p = new Phrase("\nAll " + cTitle + " bid proposal conditions that are outside of, in addition to or are limiting of conditions contained in the Contract Documents are of no effect and are invalid to the " + title + " Agreement unless expressly included in the description above.", tnr8); p.setLeading(10); cell = new Cell(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.setBorder(Rectangle.TOP); cell.setBorderWidth(0.5f); table1.addCell(cell); document.add(table1); //document.setMargins(10, 10, 30, 30); document.newPage(); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setOffset(0); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(title.toUpperCase() + " EXHIBIT \"C\"\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD))); cell.setLeading(6); cell.setBorder(0); cell.setBorder(0); table1.addCell(cell); cell = new Cell(new Phrase("\n", new Font(Font.TIMES_ROMAN, 8))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(cTitle.toUpperCase() + " SPECIAL PROVISIONS AND REQUIREMENTS\n", new Font(Font.TIMES_ROMAN, 16, Font.BOLD))); cell.setBackgroundColor(Color.lightGray); cell.setUseDescender(true); cell.setLeading(17); cell.setBorder(0); table1.addCell(cell); document.add(table1); int count = 1; if (insure) { table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setOffset(4); cell = new Cell(); cell.add(new Phrase("1. Insurance Provisions (If Applicable)", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); //cell.setLeading(6); cell.setBorder(0); table1.addCell(cell); document.add(table1); count++; table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setWidths(twoD); table1.setOffset(0); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.setLeading(6); cell.add(new Phrase( "a. The " + cTitle + " is required to name the following as additional Primary-Insured:", tnr8)); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setWidths(twoE); table1.setOffset(0); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Contractor: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(attr.get("full_name"), new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Owner: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(ownerName, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("Other: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase("_______________________________________", tnr8)); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setWidths(twoD); table1.setOffset(4); p = new Phrase("b. The " + cTitle + " must provide verification of current Worker's Compensation coverage with reference to " + jobName + " on the policy.", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)); p.setLeading(8); cell = new Cell(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.setLeading(8); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); document.add(table1); } table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setOffset(4); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(count + ". Release Authorizations", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); count++; cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(2, 1); table1.setOffset(4); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setWidths(twoD); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); p = new Phrase( "List any Owners, Partners, and/or Corporate Officers who are legally authorized to sign for " + subName + " and who will be signing the MONTHLY REQUEST FOR PAYMENT, FINAL REQUEST FOR PAYMENT, and LIEN WAIVER documents:\n\n", tnr8); p.setLeading(8); p1 = new Phrase( " ______________________________________________________________________ ______________________________________________________________________\n", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)); //p1.setLeading(0); Phrase p2 = new Phrase( " Printed name and title Signature\n\n", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)); //cell.setLeading(8); cell.add(p); cell.add(p1); cell.add(p2); cell.add(p1); cell.add(p2); cell.add(p1); cell.add(p2); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setOffset(0); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(count + ". Shop Drawings - Samples - Submittals", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.setBorder(0); table1.addCell(cell); document.add(table1); count++; table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setWidths(twoD); table1.setOffset(2); p = new Phrase( "All shop drawings, materials samples, and submittals shall be submitted to the Contractor within 30 days of the issuance of this " + title + " Agreement unless specifically noted below. All submitted items shall be in number and type as per the contract documents including, but not limited to, the following:", tnr8); p.setLeading(8); cell = new Cell(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setWidths(twoF); table1.setOffset(4); p = new Phrase("--The number of copies of each submittal for " + jobName + " is " + submittal_copies + ".\n--All submittals, of any type, are due on or before " + dueDate + " unless specifically noted otherwise.\n", tnr8); p.setLeading(8); cell = new Cell(p); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); String submittals = ""; if (!submittalVector.isEmpty()) { p = new Phrase(" Due Date:\n", new Font(Font.TIMES_ROMAN, 8, Font.BOLD)); p.setLeading(8); cell = new Cell(p); cell.setColspan(2); cell.setBorder(0); table1.addCell(cell); for (int i = 0; i < submittalVector.size(); i++) { submittals += (String) submittalVector.elementAt(i) + "\n"; } p = new Phrase(submittals, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)); p.setLeading(8); cell = new Cell(p); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); } else { p = new Phrase("\nSubmittals required per contract documents and specifications.\n", new Font(Font.TIMES_ROMAN, 8, Font.BOLD)); p.setLeading(8); cell = new Cell(p); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); } p = new Phrase("\n(" + subName + " is responsible for all submittals required in the Contract Documents as pertaining to labor and materials included in the scope of this " + title + " Agreement regardless of items listed, not listed, or incorrectly listed above.)", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)); p.setLeading(8); cell = new Cell(p); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(1); table1.setWidths(twoD); table1.setOffset(2); p = new Phrase(cTitle.toUpperCase() + " acknowledges that review and approval of any type of submittal which deviates from the Project Plans and Specifications does NOT relieve the " + cTitle + " from costs, penalties and all other remedies required to meet the published specifications where the " + cTitle + " failed to notify the Owner/Architect/Contractor in writing of the variations from the specifications and failed to obtain written approval for EACH variation from the published specifications.", tnr8); p.setLeading(8); cell = new Cell(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(8); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setOffset(2); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(count + ". Project Close-out", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.setBorder(0); table1.addCell(cell); document.add(table1); count++; table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setOffset(4); table1.setWidths(twoD); p = new Phrase( "All project close-out documents, materials, and Owner-training required by the Contract Documents shall be submitted to the Contractor PRIOR to payment of the " + cTitle + "'s 90% completion payment request. The requirements shall include, but not be limited to, the following:", tnr8); p.setLeading(8); cell = new Cell(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(8); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setOffset(0); table1.setWidths(twoG); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("top"); cell.add(new Phrase("\"O & M\" Submittals: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("top"); cell.add(new Phrase(omSubmittals, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("top"); cell.add(new Phrase("Full Warranty: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("top"); cell.add(new Phrase(fullWarranty, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("top"); cell.add(new Phrase("Up-to-date Lien Release(s): ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("top"); cell.add(new Phrase(lienReleases, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("top"); cell.add(new Phrase("Signed Training Form: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("top"); cell.add(new Phrase(signedTraining, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("top"); cell.add(new Phrase("Materials-Equip-Specialty Items: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("top"); cell.add(new Phrase(specialtyItems, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("right"); cell.setVerticalAlignment("top"); cell.add(new Phrase("Other Items: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("top"); cell.add(new Phrase(otherItems, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL))); cell.setBorder(0); table1.addCell(cell); document.add(table1); if (insure) { table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setOffset(2); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(count + ". " + cTitle + " Safety Program (If Applicable)", new Font(Font.TIMES_ROMAN, 10, Font.BOLD))); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(2, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setOffset(2); table1.setWidths(twoD); p = new Phrase( cTitle + " will submit one copy of the " + cTitle + "'s job-specific safety program to " + attr.get("full_name") + " before any equipment, manpower, or materials are brought onto the Project site. ", tnr8); p.setLeading(8); cell = new Cell(p); p = new Phrase(cTitle + " will require it's " + cTitle.toLowerCase() + "s to have in place a job-specific safety program before they enter the Project site.", tnr8); p.setLeading(8); cell.add(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); //cell.setLeading(8); table1.addCell(blank); cell.setBorder(0); table1.addCell(cell); document.add(table1); } if (insure) { document.newPage(); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(3); table1.setOffset(0); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(title.toUpperCase() + " EXHIBIT \"D\"", new Font(Font.TIMES_ROMAN, 20, Font.BOLD))); cell.setLeading(6); cell.setBorder(0); table1.addCell(cell); cell = new Cell(new Phrase("\n", new Font(Font.TIMES_ROMAN, 8))); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); cell.add(new Phrase(cTitle.toUpperCase() + "'S COST BREAKDOWN\n", new Font(Font.TIMES_ROMAN, 16, Font.BOLD))); cell.setBackgroundColor(Color.lightGray); cell.setUseDescender(true); cell.setLeading(17); cell.setBorder(0); table1.addCell(cell); document.add(table1); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setPadding(0); table1.setOffset(2); p = new Phrase("The following information is to be supplied by " + subName + " for " + jobName + ". List all SUPPLIERS and SUBCONTRACTORS for approval and payment confirmation (attach additional pages if needed):", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p.setLeading(12); cell = new Cell(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase( " Name City Phone Estimated Dollar Amount", tnr8)); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); p = new Phrase( "________________________________________________________________________ $___________________\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); for (int i = 0; i < 10; i++) { cell.add(p); } cell.setBorder(0); table1.addCell(cell); p = new Phrase( "Supplier accepts full responsibility for acts and omissions of his subcontractors and suppliers. No suppliers or subcontractors are to be added or deleted without prior notification to " + attr.get("full_name") + ".", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC)); p.setLeading(10); cell = new Cell(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.setLeading(15); cell.setBorder(0); table1.addCell(cell); p = new Phrase( "List the primary phases of your contracted scope of work and the associated costs. This information may be released to the Owner if disputes arise over future billings and progress payments.", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p.setLeading(12); cell = new Cell(p); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.setLeading(15); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); cell.add(new Phrase( "Description/Phase of Work Labor Material Equipment/Tools Sub-subcontractor Total", tnr8)); cell.setBorder(0); table1.addCell(cell); cell = new Cell(); p = new Phrase( "________________________ $____________ $____________ $____________ $____________ $____________ \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); cell.setHorizontalAlignment("left"); cell.setVerticalAlignment("middle"); for (int i = 0; i < 13; i++) { cell.add(p); } cell.setBorder(0); table1.addCell(cell); document.add(table1); document.add(spacer); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setOffset(2); table1.setPadding(1); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase(subName, new Font(Font.TIMES_ROMAN, 10, Font.UNDERLINE))); cell.add(new Phrase("\n" + cTitle, new Font(Font.TIMES_ROMAN, 6, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); document.add(table1); document.add(spacer); document.add(spacer); table1 = new Table(1, 1); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); table1.setOffset(0); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase("By:____________________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase("\nPrint Name of Authorized Company Officer", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); document.add(table1); document.add(spacer); document.add(spacer); table1 = new Table(1, 1); table1.setOffset(0); table1.setBorderWidth(0); table1.setWidth(100); //table1.setDefaultCellBorder(0); cell = new Cell(); cell.setHorizontalAlignment("center"); cell.setVerticalAlignment("middle"); //cell.setLeading(10); cell.add(new Phrase("By:____________________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL))); cell.add(new Phrase("\nAuthorized Signature", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC))); cell.setBorder(0); table1.addCell(cell); document.add(table1); } }
From source file:datasoul.servicelist.ServiceListExporterDocument.java
License:Open Source License
private LinkedList<Paragraph> addChordsShape(ArrayList<String> chordsName) throws DocumentException { ChordsDB chordsDB = ChordsDB.getInstance(); String notCatalogued = ""; LinkedList<Chunk> images = new LinkedList<Chunk>(); LinkedList<File> filesToDelete = new LinkedList<File>(); LinkedList<Paragraph> ret = new LinkedList<Paragraph>(); for (int i = 0; i < chordsName.size(); i++) { Chord chord = chordsDB.getChordByName(chordsName.get(i)); if (chord != null) { ChordShapePanel csp = new ChordShapePanel(2, chord.getName(), chord.getShape()); BufferedImage im = csp.createImage(); try { File tmp = File.createTempFile("datasoul-img", ".png"); tmp.deleteOnExit();//from w w w.j a v a 2s . c o m filesToDelete.add(tmp); ImageIO.write(im, "png", tmp); Chunk c = new Chunk(Image.getInstance(tmp.getAbsolutePath()), 0, 0, false); images.add(c); } catch (IOException e) { JOptionPane.showMessageDialog(null, java.util.ResourceBundle .getBundle("datasoul/internationalize").getString("INTERNAL ERROR: ") + e.getMessage()); } } else { notCatalogued += chordsName.get(i); } } Paragraph p = new Paragraph(); if (!images.isEmpty()) { for (Chunk c : images) { p.add(c); } p.setLeading(images.getFirst().getImage().getScaledHeight()); p.setKeepTogether(true); } ret.add(p); if (!notCatalogued.equals("")) { p = new Paragraph( java.util.ResourceBundle.getBundle("datasoul/internationalize") .getString("THE FOLLOWING CHORDS ARE NOT CATALOGED: ") + notCatalogued, FontFactory.getFont(FontFactory.HELVETICA, 8)); ret.add(p); } for (File f : filesToDelete) { try { f.delete(); } catch (Exception e) { //ignore, it will be deleted on exit } } return ret; }
From source file:net.nosleep.superanalyzer.Share.java
License:Open Source License
public static void saveListOfAlbumsAsPdf(JFrame window, Analysis analysis, JProgressBar progressBar) { File file = askForFile(window, "pdf"); if (file == null) return;/*from www. j a va2 s .c o m*/ Hashtable albums = analysis.getHash(Analysis.KIND_ALBUM); DecimalFormat timeFormat = new DecimalFormat("0.0"); StringPair list[] = new StringPair[albums.size()]; Enumeration keys = albums.keys(); Integer index = 0; String regex = Album.SeparatorRegEx; while (keys.hasMoreElements()) { String albumartist = (String) keys.nextElement(); String[] parts = albumartist.split(regex); StringPair pair = new StringPair(parts[1], parts[0]); list[index] = pair; index++; } Arrays.sort(list, new StringPairComparator()); int done = 0; progressBar.setMinimum(0); progressBar.setMaximum(list.length); String infoString = NumberFormat.getInstance().format(list.length) + " "; if (list.length == 1) infoString += Misc.getString("ALBUM") + ", "; else infoString += Misc.getString("ALBUMS") + ", "; DateFormat dateFormat = new SimpleDateFormat().getDateInstance(DateFormat.SHORT); infoString += "created on " + dateFormat.format(Calendar.getInstance().getTime()); try { String tmpPath = System.getProperty("java.io.tmpdir") + "/image.png"; // create the pdf document object Document document = new Document(); // create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.getInstance(document, new FileOutputStream(file)); // we open the document document.open(); Font titleFont = FontFactory.getFont(FontFactory.HELVETICA, 18, Font.NORMAL, new Color(0x00, 0x00, 0x00)); Paragraph p = new Paragraph(Misc.getString("MY_ALBUMS"), titleFont); p.setSpacingAfter(4); document.add(p); Font subtitleFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, new Color(0x88, 0x88, 0x88)); p = new Paragraph("The Super Analyzer by Nosleep Software", subtitleFont); p.setSpacingAfter(-2); document.add(p); p = new Paragraph(infoString, subtitleFont); p.setSpacingAfter(30); document.add(p); FontSelector albumSelector = new FontSelector(); Color albumColor = new Color(0x55, 0x55, 0x55); albumSelector.addFont(FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, albumColor)); Font albumAsianFont = FontFactory.getFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED); albumAsianFont.setSize(8); albumAsianFont.setColor(albumColor); albumSelector.addFont(albumAsianFont); FontSelector artistSelector = new FontSelector(); Color artistColor = new Color(0x77, 0x77, 0x77); artistSelector.addFont(FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, artistColor)); Font artistAsianFont = FontFactory.getFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED); artistAsianFont.setSize(8); artistAsianFont.setColor(artistColor); artistSelector.addFont(artistAsianFont); for (index = 0; index < list.length; index++) { p = new Paragraph(); p.setLeading(9); // separate the string into the album and artist parts Phrase phrase = albumSelector.process(list[index].Value); p.add(phrase); phrase = artistSelector.process(" " + Misc.getString("BY") + " " + list[index].Name); p.add(phrase); document.add(p); done++; progressBar.setValue(done); } // step 5: we close the document document.close(); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } }