List of usage examples for com.lowagie.text.pdf PdfPTable addCell
public void addCell(Phrase phrase)
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
private PdfPTable addBlankLine(int count) { PdfPTable table = new PdfPTable(1); PdfPCell cell = null;/* w ww. jav a2 s . co m*/ for (int i = 0; i < count; i++) { cell = new PdfPCell(new Paragraph("", fontTblMediumBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(3); cell.setBorder(0); table.addCell(cell); } return table; }
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
public void addTableRow(PdfPTable container, PdfPTable table) { PdfPCell tableRow = new PdfPCell(table); tableRow.setBorder(0);/* w ww . j a v a2 s . c o m*/ tableRow.setPaddingRight(10); tableRow.setPaddingLeft(10); container.addCell(tableRow); }
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
public ByteArrayOutputStream exportCashFlow(JSONObject jobj, String logoPath, String comName, HttpServletRequest request) throws DocumentException, ServiceException, IOException { ByteArrayOutputStream baos = null; double total = 0; Document document = null;//from w w w . j a v a 2s . co m PdfWriter writer = null; try { baos = new ByteArrayOutputStream(); document = new Document(PageSize.A4, 15, 15, 15, 15); writer = PdfWriter.getInstance(document, baos); document.open(); PdfPTable mainTable = new PdfPTable(1); mainTable.setWidthPercentage(100); PdfPTable tab1 = null; Rectangle page = document.getPageSize(); int bmargin = 15; //border margin PdfContentByte cb = writer.getDirectContent(); cb.rectangle(bmargin, bmargin, page.getWidth() - bmargin * 2, page.getHeight() - bmargin * 2); cb.setColorStroke(Color.WHITE); cb.stroke(); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); table1.setWidths(new float[] { 30, 20 }); PdfPCell blankCell = new PdfPCell(); blankCell.setBorder(0); tab1 = addCompanyLogo(logoPath, comName); PdfPCell cell1 = new PdfPCell(tab1); cell1.setBorder(0); table1.addCell(cell1); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); PdfPCell cell2 = new PdfPCell(new Paragraph(comName, fontSmallRegular)); cell2.setBorder(0); table1.addCell(cell2); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); PdfPCell headerCell = createCell(messageSource.getMessage("acc.dashboard.cashFlowStatement", null, RequestContextUtils.getLocale(request)), fontMediumBold, Element.ALIGN_LEFT, 0, 5); headerCell.setBorder(0); table1.addCell(headerCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); JSONArray ObjArr = jobj.getJSONArray("data"); PdfPCell HeaderCell1 = createCell( messageSource.getMessage("acc.report.2", null, RequestContextUtils.getLocale(request)), fontSmallBold, Element.ALIGN_LEFT, 0, 5); HeaderCell1.setBorderWidthLeft(1); HeaderCell1.setBorderWidthBottom(1); HeaderCell1.setBorderWidthTop(1); HeaderCell1.setBorderWidthRight(1); PdfPCell HeaderCell2 = createCell( messageSource.getMessage("acc.ra.value", null, RequestContextUtils.getLocale(request)), fontSmallBold, Element.ALIGN_RIGHT, 0, 5); HeaderCell2.setBorderWidthBottom(1); HeaderCell2.setBorderWidthTop(1); HeaderCell2.setBorderWidthRight(1); table1.addCell(HeaderCell1); table1.addCell(HeaderCell2); PdfPCell objCell1 = null; PdfPCell objCell2 = null; int objArrLength = ObjArr.length(); for (int i = 0; i < objArrLength; i++) { JSONObject leftObj = ObjArr.getJSONObject(i); if (leftObj.has("lfmt") && leftObj.getString("lfmt").equals("title")) objCell1 = createBalanceSheetCell(leftObj.getString("lname"), fontSmallBold, Element.ALIGN_CENTER, 0, 5, 0); else objCell1 = createBalanceSheetCell(leftObj.getString("lname"), fontSmallRegular, Element.ALIGN_LEFT, 0, 5, 0); objCell2 = createBalanceSheetCell(leftObj.getString("lvalue"), fontSmallRegular, Element.ALIGN_RIGHT, 0, 0, 0); objCell1.setBorderWidthLeft(1); objCell2.setBorderWidthRight(1); objCell1.setBorderWidthRight(1); objCell1.setBorderWidthBottom(1); objCell2.setBorderWidthBottom(1); if (i != (objArrLength - 1)) { table1.addCell(objCell1); table1.addCell(objCell2); } } objCell1.setBorderWidthBottom(1); objCell2.setBorderWidthBottom(1); table1.addCell(objCell1); table1.addCell(objCell2); PdfPCell mainCell11 = new PdfPCell(table1); mainCell11.setBorder(0); mainCell11.setPadding(10); mainTable.addCell(mainCell11); document.add(mainTable); } catch (Exception ex) { return null; } finally { if (document != null) { document.close(); } if (writer != null) { writer.close(); } if (baos != null) { baos.close(); } } return baos; }
From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java
License:Open Source License
public void addComponyLogo(Document d, HttpServletRequest request) throws ServiceException { try {// w w w. jav a2 s. c o m PdfPTable table = new PdfPTable(1); imgPath = getImgPath(request); table.setHorizontalAlignment(Element.ALIGN_LEFT); table.setWidthPercentage(50); PdfPCell cell = null; try { Image img = Image.getInstance(imgPath); cell = new PdfPCell(img); } catch (Exception e) { companyName = sessionHandlerImplObj.getCompanyName(request); cell = new PdfPCell(new Paragraph(fontFamilySelector.process(companyName, FontContext.LOGO_TEXT))); } cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); d.add(table); } catch (Exception e) { throw ServiceException.FAILURE("exportDAOImpl.addComponyLogo", e); } }
From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java
License:Open Source License
public void addTitleSubtitle(Document d) throws ServiceException { try {/*from w ww . j a v a2 s . co m*/ java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16)); PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100); table.setSpacingBefore(6); //Report Title PdfPCell cell = new PdfPCell(new Paragraph( fontFamilySelector.process(config.getString("title"), FontContext.REPORT_TITLE, tColor)));//fontBold)); cell.setBorder(0); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); //Report Subtitle(s) String[] SubTitles = config.getString("subtitles").split("~");// '~' as separator for (int i = 0; i < SubTitles.length; i++) { cell = new PdfPCell( new Paragraph(fontFamilySelector.process(SubTitles[i], FontContext.REPORT_TITLE, tColor))); cell.setBorder(0); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setSpacingAfter(6); d.add(table); //Separator line PdfPTable line = new PdfPTable(1); line.setWidthPercentage(100); PdfPCell cell1 = null; cell1 = new PdfPCell(new Paragraph("")); cell1.setBorder(PdfPCell.BOTTOM); line.addCell(cell1); d.add(line); } catch (Exception e) { throw ServiceException.FAILURE("exportDAOImpl.addTitleSubtitle", e); } }
From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java
License:Open Source License
public int addTable(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2, String[] colHeader, String[] widths, String[] align, String[] xtype, Document document) throws ServiceException { try {/* www.j a v a 2 s. co m*/ java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16)); PdfPTable table; float[] tcol; tcol = new float[colHeader.length + 1]; tcol[0] = 40; for (int i = 1; i < colHeader.length + 1; i++) { tcol[i] = Float.parseFloat(widths[i - 1]); } table = new PdfPTable(colHeader.length + 1); table.setWidthPercentage(tcol, document.getPageSize()); table.setSpacingBefore(15); PdfPCell h2 = new PdfPCell( new Paragraph(fontFamilySelector.process("No.", FontContext.TABLE_HEADER, tColor))); if (config.getBoolean("gridBorder")) { h2.setBorder(PdfPCell.BOX); } else { h2.setBorder(0); } h2.setPadding(4); h2.setBorderColor(Color.GRAY); h2.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(h2); PdfPCell h1 = null; for (int hcol = stcol; hcol < colwidth2.length; hcol++) { h1 = new PdfPCell(new Paragraph( fontFamilySelector.process(colHeader[hcol], FontContext.TABLE_HEADER, tColor))); h1.setHorizontalAlignment(Element.ALIGN_CENTER); if (config.getBoolean("gridBorder")) { h1.setBorder(PdfPCell.BOX); } else { h1.setBorder(0); } h1.setBorderColor(Color.GRAY); h1.setPadding(4); table.addCell(h1); } table.setHeaderRows(1); for (int row = strow; row < stprow; row++) { h2 = new PdfPCell(new Paragraph( fontFamilySelector.process(String.valueOf(row + 1), FontContext.TABLE_DATA, tColor))); if (config.getBoolean("gridBorder")) { h2.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT); } else { h2.setBorder(0); } h2.setPadding(4); h2.setBorderColor(Color.GRAY); h2.setHorizontalAlignment(Element.ALIGN_CENTER); h2.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(h2); JSONObject temp = store.getJSONObject(row); for (int col = 0; col < colwidth2.length; col++) { String str = temp.optString((colwidth2[col]), ""); try { if (xtype.length > 0) { str = formatValue(temp.optString((colwidth2[col]), ""), xtype[col]); } } catch (Exception e) { } Paragraph para = new Paragraph(fontFamilySelector.process(str, FontContext.TABLE_DATA, tColor)); h1 = new PdfPCell(para); if (config.getBoolean("gridBorder")) { h1.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT); } else { h1.setBorder(0); } h1.setPadding(4); h1.setBorderColor(Color.GRAY); if (!align[col].equals("right") && !align[col].equals("left")) { h1.setHorizontalAlignment(Element.ALIGN_CENTER); h1.setVerticalAlignment(Element.ALIGN_CENTER); } else if (align[col].equals("right")) { h1.setHorizontalAlignment(Element.ALIGN_RIGHT); h1.setVerticalAlignment(Element.ALIGN_RIGHT); } else if (align[col].equals("left")) { h1.setHorizontalAlignment(Element.ALIGN_LEFT); h1.setVerticalAlignment(Element.ALIGN_LEFT); } table.addCell(h1); } } document.add(table); document.newPage(); } catch (Exception e) { throw ServiceException.FAILURE("exportDAOImpl.addTable", e); } return stpcol; }
From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java
License:Open Source License
public void createInvoicePdf(Document document, int mode, Map<String, Object> DataInfo, Company com, DateFormat formatter, String currencyid, JSONArray productDetails, String preText, String postText, String baseUrl) throws DocumentException, JSONException { // mode 1 = quotation try {/*w w w.j av a 2 s.c o m*/ KWLCurrency currencyObj = (KWLCurrency) hibernateTemplate.load(KWLCurrency.class, currencyid); config = new com.krawler.utils.json.base.JSONObject(DataInfo.get("config").toString()); PdfPTable tab2 = null; PdfPTable tab3 = null; PdfPTable mainTable = new PdfPTable(1); mainTable.setWidthPercentage(100); String invno = ""; String theader = ""; double quotationDisc = 0; double quotationtaxamount = 0; String quotationtaxname = ""; double totalAmount = 0; double quotationtaxpercent = 0; Date entryDate = null; String customerName = ""; String shipTo = ""; String memo = ""; // itr = idresult.getEntityList().iterator(); if (mode == 1) { theader = "Quotation"; invno = DataInfo.containsKey("invno") ? DataInfo.get("invno").toString() : ""; entryDate = DataInfo.containsKey("entrydate") ? (Date) DataInfo.get("entrydate") : new Date(); customerName = DataInfo.containsKey("customername") ? DataInfo.get("customername").toString() : ""; shipTo = DataInfo.containsKey("address") ? DataInfo.get("address").toString() : ""; memo = DataInfo.containsKey("memo") ? DataInfo.get("memo").toString() : ""; quotationDisc = DataInfo.containsKey("quotationdisc") ? Double.parseDouble(DataInfo.get("quotationdisc").toString()) : 0; quotationtaxamount = DataInfo.containsKey("quotationtax") ? Double.parseDouble(DataInfo.get("quotationtax").toString()) : 0; quotationtaxname = DataInfo.containsKey("quotationtaxname") ? DataInfo.get("quotationtaxname").toString() : ""; quotationtaxpercent = DataInfo.containsKey("quotationtaxpercent") ? Double.parseDouble(DataInfo.get("quotationtaxpercent").toString()) : 0; totalAmount = DataInfo.containsKey("totalamount") ? Double.parseDouble(DataInfo.get("totalamount").toString()) : 0; } String company[] = new String[4]; company[0] = com.getCompanyName(); company[1] = com.getAddress(); company[2] = com.getEmailID(); company[3] = com.getPhoneNumber(); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); table1.setWidths(new float[] { 50, 50 }); tab2 = new PdfPTable(1); PdfPCell invCell = null; invCell = createCell(theader, FontContext.TABLE_HEADER, Element.ALIGN_RIGHT, 0, 5); tab2.addCell(invCell); PdfPCell cel2 = new PdfPCell(tab2); cel2.setBorder(0); table1.addCell(cel2); PdfPCell mainCell11 = new PdfPCell(table1); mainCell11.setBorder(0); mainCell11.setPadding(10); mainTable.addCell(mainCell11); PdfPTable userTable2 = new PdfPTable(2); userTable2.setWidthPercentage(100); userTable2.setWidths(new float[] { 60, 40 }); tab3 = getCompanyInfo(company); PdfPTable tab4 = new PdfPTable(2); tab4.setWidthPercentage(100); tab4.setWidths(new float[] { 30, 70 }); PdfPCell cell2 = createCell(theader + " No.", FontContext.TABLE_HEADER, Element.ALIGN_LEFT, 0, 5); tab4.addCell(cell2); // String invno = mode != StaticValues.AUTONUM_BILLINGINVOICE ? inv.getInvoiceNumber() : inv1.getBillingInvoiceNumber(); cell2 = createCell(": " + invno, FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5); tab4.addCell(cell2); cell2 = createCell("DATE ", FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5); tab4.addCell(cell2); cell2 = createCell(": " + formatter.format(entryDate), FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5); tab4.addCell(cell2); PdfPCell cell1 = new PdfPCell(tab3); cell1.setBorder(0); userTable2.addCell(cell1); cel2 = new PdfPCell(tab4); cel2.setBorder(0); userTable2.addCell(cel2); PdfPCell mainCell12 = new PdfPCell(userTable2); mainCell12.setBorder(0); mainCell12.setPadding(10); mainTable.addCell(mainCell12); PdfPTable tab5 = new PdfPTable(2); tab5.setWidthPercentage(100); tab5.setWidths(new float[] { 50, 50 }); PdfPCell cell3 = createCell("To, ", FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); tab5.addCell(cell3); cell3 = createCell("", FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 0); tab5.addCell(cell3); // cell3 = createCell("", fontRegularNormal, Element.ALIGN_LEFT, 0, 0); // tab5.addCell(cell3); cell3 = createCell(customerName, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); tab5.addCell(cell3); cell3 = createCell("", FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 0); tab5.addCell(cell3); cell3 = createCell(shipTo, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); tab5.addCell(cell3); PdfPCell mainCell14 = new PdfPCell(tab5); mainCell14.setBorder(0); //mainCell14.setPadding(10); mainTable.addCell(mainCell14); getHtmlCell(preText.trim(), mainTable, baseUrl); getHtmlCell("<br>", mainTable, baseUrl); getHtmlCell("<br>", mainTable, baseUrl); String[] header = { "S.No.", "PRODUCT", "DESCRIPTION", "QUANTITY", "UNIT PRICE", "DISCOUNT", "TAX", "LINE TOTAL" }; PdfPTable table = getBlankTable(); PdfPCell invcell = null; for (int i = 0; i < header.length; i++) { invcell = new PdfPCell( new Paragraph(fontFamilySelector.process(header[i], FontContext.TABLE_HEADER))); invcell.setHorizontalAlignment(Element.ALIGN_CENTER); invcell.setBackgroundColor(Color.LIGHT_GRAY); invCell.setBorder(0); invcell.setPadding(3); table.addCell(invcell); } addTableRow(mainTable, table); //Break table after adding header row table = getBlankTable(); String prodName = ""; String subtotal = ""; String quantity = ""; String rate = ""; String description = ""; String discount = ""; String prodtax = ""; int index = 0; double total = 0; for (int cnt = 0; cnt < productDetails.length(); cnt++) { JSONObject productInfo = productDetails.getJSONObject(cnt); prodName = productInfo.getString("productname"); description = productInfo.getString("description"); quantity = productInfo.getString("quantity"); rate = productInfo.getString("orderrate"); subtotal = productInfo.getString("amount"); discount = productInfo.getString("prdiscountamount"); prodtax = productInfo.getString("taxamount"); invcell = createCell((++index) + ".", FontContext.TABLE_DATA, Element.ALIGN_RIGHT, Rectangle.LEFT + Rectangle.RIGHT, 5); table.addCell(invcell); invcell = createCell(prodName, FontContext.TABLE_DATA, Element.ALIGN_LEFT, Rectangle.LEFT + Rectangle.RIGHT, 5); table.addCell(invcell); invcell = createCell(description, FontContext.TABLE_DATA, Element.ALIGN_LEFT, Rectangle.LEFT + Rectangle.RIGHT, 5); table.addCell(invcell); invcell = createCell(quantity, FontContext.TABLE_DATA, Element.ALIGN_CENTER, Rectangle.LEFT + Rectangle.RIGHT, 5); table.addCell(invcell); invcell = createCell(currencyRender(rate, currencyObj), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, Rectangle.LEFT + Rectangle.RIGHT, 5); table.addCell(invcell); invcell = createCell(currencyRender(subtotal, currencyObj), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, Rectangle.LEFT + Rectangle.RIGHT, 5); table.addCell(invcell); invcell = createCell(currencyRender(prodtax, currencyObj), FontContext.TABLE_DATA, Element.ALIGN_CENTER, Rectangle.LEFT + Rectangle.RIGHT, 5); table.addCell(invcell); invcell = createCell(currencyRender(subtotal, currencyObj), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, Rectangle.LEFT + Rectangle.RIGHT, 5); table.addCell(invcell); total += Double.valueOf(subtotal); addTableRow(mainTable, table); //Break table after adding detail's row table = getBlankTable(); } for (int j = 0; j < 98; j++) { invcell = new PdfPCell(new Paragraph(fontFamilySelector.process("", FontContext.TABLE_DATA)));//fontRegularBold)); invcell.setHorizontalAlignment(Element.ALIGN_CENTER); invcell.setBorder(Rectangle.LEFT + Rectangle.RIGHT); table.addCell(invcell); } addTableRow(mainTable, table); //Break table after adding extra space table = getBlankTable(); cell3 = createCell("SUB TOTAL", FontContext.NOTE_TEXT, Element.ALIGN_RIGHT, Rectangle.TOP, 5); cell3.setColspan(7); table.addCell(cell3); cell3 = createCell(currencyRender(String.valueOf(total), currencyObj), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 15, 5); table.addCell(cell3); cell3 = createCell("DISCOUNT(-)", FontContext.NOTE_TEXT, Element.ALIGN_RIGHT, 0, 5); cell3.setColspan(7); table.addCell(cell3); cell3 = calculateDiscount(quotationDisc, currencyObj); table.addCell(cell3); StringBuffer taxNameStr = new StringBuffer(); if (!StringUtil.isNullOrEmpty(quotationtaxname)) { taxNameStr.append(quotationtaxname); taxNameStr.append(" "); taxNameStr.append(quotationtaxpercent); taxNameStr.append("% (+)"); } else { taxNameStr.append("TAX (+)"); } cell3 = createCell(taxNameStr.toString(), FontContext.NOTE_TEXT, Element.ALIGN_RIGHT, 0, 5); cell3.setColspan(7); table.addCell(cell3); cell3 = createCell(currencyRender(String.valueOf(quotationtaxamount), currencyObj), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 15, 5); table.addCell(cell3); cell3 = createCell("TOTAL", FontContext.NOTE_TEXT, Element.ALIGN_RIGHT, 0, 5); cell3.setColspan(7); table.addCell(cell3); cell3 = createCell(currencyRender(String.valueOf(totalAmount), currencyObj), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 15, 5); table.addCell(cell3); addTableRow(mainTable, table); String netinword = EnglishNumberToWordsOjb.convert(Double.parseDouble(String.valueOf(totalAmount)), currencyObj); String currencyname = currencyObj.getName(); cell3 = createCell("Amount (in words) : " + currencyname + " " + netinword + " Only.", FontContext.HEADER_NOTE, Element.ALIGN_LEFT, Rectangle.LEFT + Rectangle.RIGHT + Rectangle.BOTTOM + Rectangle.TOP, 5); PdfPTable table2 = new PdfPTable(1); table2.addCell(cell3); PdfPCell mainCell62 = new PdfPCell(table2); mainCell62.setBorder(0); mainCell62.setPadding(10); mainTable.addCell(mainCell62); PdfPTable helpTable = new PdfPTable(new float[] { 8, 92 }); helpTable.setWidthPercentage(100); Phrase phrase1 = fontFamilySelector.process("Memo: ", FontContext.NOTE_TEXT); Phrase phrase2 = fontFamilySelector.process(memo, FontContext.TABLE_DATA);//fontRegularBold); PdfPCell pcell1 = new PdfPCell(phrase1); PdfPCell pcell2 = new PdfPCell(phrase2); pcell1.setBorder(0); pcell1.setPadding(10); pcell1.setPaddingRight(0); pcell2.setBorder(0); pcell2.setPadding(10); helpTable.addCell(pcell1); helpTable.addCell(pcell2); PdfPCell mainCell61 = new PdfPCell(helpTable); mainCell61.setBorder(0); mainTable.addCell(mainCell61); getHtmlCell("<br>", mainTable, baseUrl); getHtmlCell("<br>", mainTable, baseUrl); getHtmlCell(postText.trim(), mainTable, baseUrl); document.add(mainTable); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java
License:Open Source License
public void getHtmlCell(String htmlString, PdfPTable mainTable, String baseUrl) { StringReader strReader = new StringReader( htmlString.replaceAll("src=\"[^\"]*?video.jsp", "src=\"" + baseUrl + "video.jsp")); StyleSheet styles = new StyleSheet(); try {/* www .j a va2 s .c o m*/ for (Object ele : HTMLWorker.parseToList(strReader, styles)) { //Phrase phraseStr = new Phrase((Phrase)ele); PdfPCell cell = new PdfPCell(); cell.addElement((Element) ele); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_LEFT); mainTable.addCell(cell); } } catch (Exception e) { log.debug("Cannot read html string: " + e.getMessage()); } }
From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java
License:Open Source License
public PdfPTable getCompanyInfo(String com[]) { PdfPTable tab1 = new PdfPTable(1); tab1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cell = new PdfPCell(new Paragraph(fontFamilySelector.process(com[0], FontContext.TABLE_DATA)));//fontBoldMedium)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0);/* ww w.j a va2s . c om*/ tab1.addCell(cell); for (int i = 1; i < com.length; i++) { cell = new PdfPCell(new Paragraph(fontFamilySelector.process(com[i], FontContext.TABLE_DATA)));// fontRegularBold)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); tab1.addCell(cell); } return tab1; }
From source file:com.krawler.spring.exportFunctionality.exportMPXDAOImpl.java
License:Open Source License
public void addComponyLogo(Document d, HttpServletRequest request) throws ServiceException { try {/*from ww w . ja v a2 s . co m*/ PdfPTable table = new PdfPTable(1); imgPath = getImgPath(request); table.setHorizontalAlignment(Element.ALIGN_LEFT); table.setWidthPercentage(50); PdfPCell cell = null; try { Image img = Image.getInstance(imgPath); cell = new PdfPCell(img); } catch (Exception e) { companyName = sessionHandlerImplObj.getCompanyName(request); cell = new PdfPCell( new Paragraph(fontFamilySelector.process(companyName, FontContext.HEADER_NOTE))); } cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); d.add(table); } catch (Exception e) { throw ServiceException.FAILURE("exportDAOImpl.addComponyLogo", e); } }