List of usage examples for com.lowagie.text.pdf PdfPCell setBorder
public void setBorder(int border)
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
private PdfPCell createCell(String string, FontContext context, int ALIGN_RIGHT, int i, int padd) { PdfPCell cell = new PdfPCell(new Paragraph(fontFamilySelector.process(string, context))); cell.setHorizontalAlignment(ALIGN_RIGHT); cell.setBorder(i); cell.setPadding(padd);/*from w ww. j a v a 2 s. co m*/ return cell; }
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
private PdfPTable addCompanyLogo(String logoPath, Company com) { PdfPTable tab1 = new PdfPTable(1); imgPath = logoPath;/* ww w.j a v a 2 s. c o m*/ PdfPCell imgCell = null; try { Image img = Image.getInstance(imgPath); imgCell = new PdfPCell(img); } catch (Exception e) { imgCell = new PdfPCell(new Paragraph(com.getCompanyName(), fontSmallRegular)); } imgCell.setHorizontalAlignment(Element.ALIGN_LEFT); imgCell.setBorder(0); tab1.addCell(imgCell); return tab1; }
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
private PdfPTable addCompanyLogo(String logoPath, String comName) { PdfPTable tab1 = new PdfPTable(1); imgPath = logoPath;/* w w w . j a va 2s . c o m*/ PdfPCell imgCell = null; try { Image img = Image.getInstance(imgPath); imgCell = new PdfPCell(img); } catch (Exception e) { imgCell = new PdfPCell(new Paragraph(comName, fontSmallRegular)); } imgCell.setHorizontalAlignment(Element.ALIGN_LEFT); imgCell.setBorder(0); tab1.addCell(imgCell); return tab1; }
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
private void addHeaderFooter(Document document, PdfWriter writer) throws DocumentException, ServiceException { PdfPTable footer = new PdfPTable(1); PdfPCell footerSeparator = new PdfPCell(new Paragraph("THANK YOU FOR YOUR BUSINESS!", fontTblMediumBold)); footerSeparator.setHorizontalAlignment(Element.ALIGN_CENTER); footerSeparator.setBorder(0); footer.addCell(footerSeparator);/* w w w. j a v a 2 s .c om*/ try { Rectangle page = document.getPageSize(); footer.setTotalWidth(page.getWidth() - document.leftMargin()); footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(), writer.getDirectContent()); } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:com.krawler.spring.exportFuctionality.ExportRecord.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(com[0], fontMediumBold)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); tab1.addCell(cell);/*from ww w .j a va 2s.c om*/ for (int i = 1; i < com.length; i++) { cell = new PdfPCell(new Paragraph(com[i], fontTblMediumBold)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); tab1.addCell(cell); } return tab1; }
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; for (int i = 0; i < count; i++) { cell = new PdfPCell(new Paragraph("", fontTblMediumBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(3);/* w ww . j ava 2s . com*/ 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); tableRow.setPaddingRight(10);//from w ww . j a v a 2 s .co m 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 2 s . com 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 {/*from w w w . j a va 2 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.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 ww w. ja v a 2 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); } }