List of usage examples for com.lowagie.text.pdf PdfPCell setBorderWidthBottom
public void setBorderWidthBottom(float borderWidthBottom)
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
public ByteArrayOutputStream exportRatioAnalysis(HttpServletRequest request, JSONObject jobj, String logoPath, String comName) throws DocumentException, ServiceException, IOException { ByteArrayOutputStream baos = null; double total = 0; Document document = null;/* ww w .j a va2 s. c o m*/ PdfWriter writer = null; try { //flag 1 = BalanceSheet , 2 = P&L 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(); // addHeaderFooter(document, writer); PdfPTable table1 = new PdfPTable(4); table1.setWidthPercentage(100); table1.setWidths(new float[] { 25, 25, 25, 25 }); 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.ra.tabTT", null, RequestContextUtils.getLocale(request)), FontContext.TABLE_HEADER, 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.ra.principalGroups", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5); HeaderCell1.setBorderWidthLeft(1); HeaderCell1.setBorderWidthBottom(1); HeaderCell1.setBorderWidthTop(1); PdfPCell HeaderCell2 = createCell( messageSource.getMessage("acc.ra.value", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_TEXT, Element.ALIGN_RIGHT, 0, 5); HeaderCell2.setBorderWidthBottom(1); HeaderCell2.setBorderWidthTop(1); PdfPCell HeaderCell3 = createCell( messageSource.getMessage("acc.ra.principalRatios", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5); HeaderCell3.setBorderWidthBottom(1); HeaderCell3.setBorderWidthTop(1); HeaderCell3.setBorderWidthLeft(1); PdfPCell HeaderCell4 = createCell( messageSource.getMessage("acc.ra.value", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_TEXT, Element.ALIGN_RIGHT, 0, 5); HeaderCell4.setBorderWidthBottom(1); HeaderCell4.setBorderWidthRight(1); HeaderCell4.setBorderWidthTop(1); table1.addCell(HeaderCell1); table1.addCell(HeaderCell2); table1.addCell(HeaderCell3); table1.addCell(HeaderCell4); PdfPCell objCell1 = null; PdfPCell objCell2 = null; PdfPCell objCell3 = null; PdfPCell objCell4 = null; int objArrLength = ObjArr.length(); for (int i = 0; i < objArrLength; i++) { JSONObject leftObj = ObjArr.getJSONObject(i); objCell1 = createBalanceSheetCell(leftObj.getString("lname"), FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5, 0); objCell2 = createBalanceSheetCell(leftObj.getString("lvalue"), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 0, 0, 0); objCell3 = createBalanceSheetCell(leftObj.getString("rname"), FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5, 0); objCell4 = createBalanceSheetCell(leftObj.getString("rvalue"), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 0, 0, 0); objCell1.setBorderWidthLeft(1); objCell3.setBorderWidthLeft(1); objCell4.setBorderWidthRight(1); if (i != (objArrLength - 1)) { table1.addCell(objCell1); table1.addCell(objCell2); table1.addCell(objCell3); table1.addCell(objCell4); } } objCell1.setBorderWidthBottom(1); objCell2.setBorderWidthBottom(1); objCell3.setBorderWidthBottom(1); objCell4.setBorderWidthBottom(1); table1.addCell(objCell1); table1.addCell(objCell2); table1.addCell(objCell3); table1.addCell(objCell4); 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.exportFuctionality.ExportRecord.java
License:Open Source License
public ByteArrayOutputStream exportBalanceSheetPdf(HttpServletRequest request, String currencyid, DateFormat formatter, String logoPath, String comName, JSONObject jobj, Date startDate, Date endDate, int flag, int toggle) throws DocumentException, ServiceException, IOException { ByteArrayOutputStream baos = null; double total = 0; Document document = null;/*from w w w. j ava 2 s .c om*/ PdfWriter writer = null; try { //flag 1 = BalanceSheet , 2 = P&L String headingString = ""; String DateheadingString = ""; String value = ""; String subHeading1 = ""; String subHeading2 = ""; if (flag == 1) { headingString = messageSource.getMessage("acc.rem.123", null, RequestContextUtils.getLocale(request)); //"Balance Sheet For : "; DateheadingString = messageSource.getMessage("acc.rem.124", null, RequestContextUtils.getLocale(request)); //"Balance Sheet Till :"; value = formatter.format(endDate); subHeading1 = messageSource.getMessage("acc.balanceSheet.Amount(asset)", null, RequestContextUtils.getLocale(request)); //"Asset"; subHeading2 = messageSource.getMessage("acc.balanceSheet.Amount(liability)", null, RequestContextUtils.getLocale(request)); //"Liability"; if (toggle == 1) { subHeading1 = messageSource.getMessage("acc.balanceSheet.Amount(liability)", null, RequestContextUtils.getLocale(request)); //"Liability"; subHeading2 = messageSource.getMessage("acc.balanceSheet.Amount(asset)", null, RequestContextUtils.getLocale(request)); //"Asset"; } } else { headingString = messageSource.getMessage("acc.rem.125", null, RequestContextUtils.getLocale(request)); // "P&L Statement For : "; DateheadingString = messageSource.getMessage("acc.rem.126", null, RequestContextUtils.getLocale(request)); // "P&L Statement From-To :"; value = formatter.format(startDate) + " " + messageSource.getMessage("acc.common.to", null, RequestContextUtils.getLocale(request)) + " " + formatter.format(endDate); subHeading1 = messageSource.getMessage("acc.P&L.Amount(Debit)", null, RequestContextUtils.getLocale(request)); //"Debit"; subHeading2 = messageSource.getMessage("acc.P&L.Amount(Credit)", null, RequestContextUtils.getLocale(request)); //"Credit"; } 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(); // addHeaderFooter(document, writer); PdfPTable table1 = new PdfPTable(3); table1.setWidthPercentage(100); table1.setWidths(new float[] { 30, 30, 40 }); 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); PdfPCell headerCell = createCell(headingString, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); headerCell.setBorder(0); table1.addCell(headerCell); PdfPCell headerNameCell = createCell(comName, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); headerNameCell.setBorder(0); table1.addCell(headerNameCell); table1.addCell(blankCell); headerCell = createCell(DateheadingString, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); headerCell.setBorder(0); table1.addCell(headerCell); headerNameCell = createCell(value, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); headerNameCell.setBorder(0); table1.addCell(headerNameCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); jobj = jobj.getJSONObject("data"); JSONArray rightObjArr = flag == 1 ? jobj.getJSONArray("right") : jobj.getJSONArray("left"); JSONArray leftObjArr = flag == 1 ? jobj.getJSONArray("left") : jobj.getJSONArray("right"); if (toggle == 1) { rightObjArr = jobj.getJSONArray("left"); leftObjArr = jobj.getJSONArray("right"); } JSONArray finalValArr = jobj.getJSONArray("total"); PdfPCell HeaderCell1 = createCell( messageSource.getMessage("acc.P&L.particulars", null, RequestContextUtils.getLocale(request)), FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); HeaderCell1.setBorderWidthBottom(1); PdfPCell HeaderCell2 = createCell(subHeading1, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); HeaderCell2.setBorderWidthBottom(1); table1.addCell(HeaderCell1); table1.addCell(HeaderCell2); table1.addCell(blankCell); double totalAsset = Double.parseDouble(finalValArr.getString(0)); double totalLibility = Double.parseDouble(finalValArr.getString(1)); for (int i = 0; i < rightObjArr.length(); i++) { JSONObject leftObj = rightObjArr.getJSONObject(i); addBalanceSheetCell(leftObj, table1, currencyid); // PdfPCell cell3 = createCell(leftObj.get("accountname").toString(), fontSmallBold, Element.ALIGN_LEFT, 0, 5); // PdfPCell cell4 = createCell(com.krawler.common.util.StringUtil.serverHTMLStripper(leftObj.get("amount").toString()), fontSmallBold, Element.ALIGN_LEFT, 0, 5); // cell3.setBorder(0); // table1.addCell(cell3); // cell4.setBorder(0); // table1.addCell(cell4); } PdfPCell totalAsscell = createBalanceSheetCell( messageSource.getMessage("acc.common.total", null, RequestContextUtils.getLocale(request)) + " " + subHeading1, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 0, 0); table1.addCell(totalAsscell); PdfPCell totalAssValcell = createBalanceSheetCell( exportDaoObj.currencyRender(Double.toString(totalAsset), currencyid), fontSmallBold, Element.ALIGN_RIGHT, 0, 0, 0); table1.addCell(totalAssValcell); for (int i = 0; i < 16; i++) table1.addCell(blankCell); HeaderCell1 = createCell( messageSource.getMessage("acc.balanceSheet.particulars", null, RequestContextUtils.getLocale(request)), FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); HeaderCell1.setBorderWidthBottom(1); HeaderCell2 = createCell(subHeading2, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); HeaderCell2.setBorderWidthBottom(1); table1.addCell(HeaderCell1); table1.addCell(HeaderCell2); table1.addCell(blankCell); for (int i = 0; i < leftObjArr.length(); i++) { JSONObject leftObj = leftObjArr.getJSONObject(i); addBalanceSheetCell(leftObj, table1, currencyid); // PdfPCell cell3 = createCell(leftObj.get("accountname").toString(), fontSmallBold, Element.ALIGN_LEFT, 0, 5); // PdfPCell cell4 = createCell(com.krawler.common.util.StringUtil.serverHTMLStripper(leftObj.get("amount").toString()), fontSmallBold, Element.ALIGN_LEFT, 0, 5); // cell3.setBorder(0); // table1.addCell(cell3); // cell4.setBorder(0); // table1.addCell(cell4); } PdfPCell totalLibcell = createBalanceSheetCell( messageSource.getMessage("acc.common.total", null, RequestContextUtils.getLocale(request)) + " " + subHeading2, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 0, 0); table1.addCell(totalLibcell); PdfPCell totalLibValcell = createBalanceSheetCell( exportDaoObj.currencyRender(Double.toString(totalLibility), currencyid), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 0, 0, 0); table1.addCell(totalLibValcell); table1.addCell(blankCell); PdfPCell mainCell11 = new PdfPCell(table1); mainCell11.setBorder(0); mainCell11.setPadding(10); mainTable.addCell(mainCell11); // document.add(mainTable); 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.exportFuctionality.ExportRecord.java
License:Open Source License
public Double addBalanceSheetCell(JSONObject jobj, PdfPTable table, String currencyid) throws JSONException, SessionExpiredException { String val = ""; double retnum = 0; PdfPCell cell3 = null; PdfPCell cell4 = null;/*from www .j a v a 2s. co m*/ PdfPCell cell5 = createBalanceSheetCell(val, FontContext.SMALL_TEXT, Element.ALIGN_RIGHT, 0, 0, 0); if (!jobj.toString().equalsIgnoreCase("{}")) { String accName = jobj.get("accountname").toString(); double amount = 0; int padding = Integer.parseInt(jobj.get("level").toString()) * 10; try { amount = Double.parseDouble(jobj.get("amount").toString()); val = exportDaoObj.currencyRender(Double.toString(amount), currencyid); java.text.DecimalFormat obj = new java.text.DecimalFormat("###0.00"); if (padding == 0 && !accName.equals("")) { retnum = Double.parseDouble(obj.format(amount)); } } catch (NumberFormatException ex) { val = com.krawler.common.util.StringUtil.serverHTMLStripper(jobj.get("amount").toString()); } if (jobj.has("fmt")) { cell3 = createBalanceSheetCell(accName, FontContext.TABLE_HEADER, Element.ALIGN_LEFT, 0, padding, 0); cell4 = createBalanceSheetCell(val, FontContext.TABLE_HEADER, Element.ALIGN_RIGHT, 0, 0, 0); } else if (padding == 0 && !accName.equals("")) { cell3 = createBalanceSheetCell(accName, FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, padding, 0); cell4 = createBalanceSheetCell(val, FontContext.SMALL_TEXT, Element.ALIGN_RIGHT, 0, 0, 0); if (!val.equals("")) { cell3.setBorderWidthBottom(1); cell3.setBorderColor(Color.GRAY); cell4.setBorderWidthBottom(1); cell4.setBorderColor(Color.gray); } } else { cell3 = createBalanceSheetCell(accName, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, padding, 0); cell4 = createBalanceSheetCell(val, FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 0, 0, 0); } table.addCell(cell3); table.addCell(cell4); table.addCell(cell5); } /*else{ cell3 = createBalanceSheetCell(val, fontSmallBold, Element.ALIGN_RIGHT, 0, 0,0); cell4 = createBalanceSheetCell(val, fontSmallBold, Element.ALIGN_RIGHT, 0, 0,0); }*/ return retnum; }
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;/* ww w . ja v a 2 s. c om*/ 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.exportMPXDAOImpl.java
License:Open Source License
public void addGroupRow(String groupText, String currencyid, PdfPTable table, String[] dataIndexArr) throws JSONException, SessionExpiredException { Paragraph para = new Paragraph(fontFamilySelector.process(groupText, FontContext.REPORT_TITLE)); PdfPCell h1 = new PdfPCell(para); if (config.getBoolean("gridBorder")) { h1.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT); } else {//w ww. j a v a2s . c o m h1.setBorder(PdfPCell.BOTTOM); } h1.setBorderWidthBottom(1); h1.setPadding(4); h1.setBorderColor(Color.GRAY); h1.setBorderColorBottom(Color.DARK_GRAY); h1.setHorizontalAlignment(Element.ALIGN_LEFT); h1.setVerticalAlignment(Element.ALIGN_LEFT); h1.setColspan(dataIndexArr.length + 1); table.addCell(h1); }
From source file:de.jdufner.sudoku.generator.pdf.PdfCellHandler.java
License:Open Source License
private void formatZelle(final int zeile, final int spalte, final PdfPCell cell) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorderColor(new Color(// Integer.parseInt(getPdfStyle().getProperty("sudoku.board.border.color.red")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.border.color.green")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.border.color.blue")))); if (isEvenBlockIndex(zeile, spalte)) { cell.setBackgroundColor(new Color(// Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.odd.color.red")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.odd.color.green")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.odd.color.blue")))); } else {//from ww w.j a va 2 s . co m cell.setBackgroundColor(new Color(// Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.even.color.red")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.even.color.green")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.even.color.blue")))); } cell.setBorderWidth(PdfConstants.RAHMEN_DUENN); if (BoxUtils.isFirstRowInBlock(zeile, getSudokuSize())) { cell.setBorderWidthTop(PdfConstants.RAHMEN_DICK); } else { cell.setBorderWidthTop(PdfConstants.RAHMEN_DUENN); } if (BoxUtils.isLastColumnInRow(spalte, getSudokuSize())) { cell.setBorderWidthRight(PdfConstants.RAHMEN_DICK); } else { cell.setBorderWidthRight(PdfConstants.RAHMEN_DUENN); } if (BoxUtils.isLastRowInColumn(zeile, getSudokuSize())) { cell.setBorderWidthBottom(PdfConstants.RAHMEN_DICK); } else { cell.setBorderWidthBottom(PdfConstants.RAHMEN_DUENN); } if (BoxUtils.isFirstColumnInBlock(spalte, getSudokuSize())) { cell.setBorderWidthLeft(PdfConstants.RAHMEN_DICK); } else { cell.setBorderWidthLeft(PdfConstants.RAHMEN_DUENN); } cell.setFixedHeight(27f); }
From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StyleUtils.java
License:Open Source License
public static void applyStyles(StyleBorder border, PdfPCell cell) { if (border == null) { return;/* w w w . j a va 2s. c om*/ } switch (border.getBorderType()) { case ALL: // border if (border.isNoBorder()) { cell.disableBorderSide(PdfPCell.TOP); cell.disableBorderSide(PdfPCell.BOTTOM); cell.disableBorderSide(PdfPCell.RIGHT); cell.disableBorderSide(PdfPCell.LEFT); } else { cell.enableBorderSide(PdfPCell.TOP); cell.enableBorderSide(PdfPCell.BOTTOM); cell.enableBorderSide(PdfPCell.RIGHT); cell.enableBorderSide(PdfPCell.LEFT); // border-color Color color = border.getColor(); if (color != null) { cell.setBorderColor(color); } // border-width Float width = border.getWidth(); if (width != null) { cell.setBorderWidth(width); } } break; case BOTTOM: // border-bottom if (border.isNoBorder()) { cell.disableBorderSide(PdfPCell.BOTTOM); } else { cell.enableBorderSide(PdfPCell.BOTTOM); // border-bottom-color Color color = border.getColor(); if (color != null) { cell.setBorderColorBottom(color); } // border-bottom-width Float width = border.getWidth(); if (width != null) { cell.setBorderWidthBottom(width); } } break; case LEFT: // border-left if (border.isNoBorder()) { cell.disableBorderSide(PdfPCell.LEFT); } else { cell.enableBorderSide(PdfPCell.LEFT); // border-left-color Color color = border.getColor(); if (color != null) { cell.setBorderColorLeft(color); } // border-left-width Float width = border.getWidth(); if (width != null) { cell.setBorderWidthLeft(width); } } break; case RIGHT: // border-right if (border.isNoBorder()) { cell.disableBorderSide(PdfPCell.RIGHT); } else { cell.enableBorderSide(PdfPCell.RIGHT); // border-right-color Color color = border.getColor(); if (color != null) { cell.setBorderColorRight(color); } // border-right-width Float width = border.getWidth(); if (width != null) { cell.setBorderWidthRight(width); } } break; case TOP: // border-top if (border.isNoBorder()) { cell.disableBorderSide(PdfPCell.TOP); } else { cell.enableBorderSide(PdfPCell.TOP); // border-top-color Color color = border.getColor(); if (color != null) { cell.setBorderColorTop(color); } // border-top-width Float width = border.getWidth(); if (width != null) { cell.setBorderWidthTop(width); } } break; } }
From source file:ilarkesto.integration.itext.Cell.java
License:Open Source License
@Override public Element getITextElement() { PdfPCell cell = new PdfPCell(); cell.setBorderColorTop(getBorderTopColor()); cell.setBorderColorBottom(getBorderBottomColor()); cell.setBorderColorLeft(getBorderLeftColor()); cell.setBorderColorRight(getBorderRightColor()); cell.setBorderWidthTop(APdfBuilder.mmToPoints(getBorderTopWidth())); cell.setBorderWidthBottom(APdfBuilder.mmToPoints(getBorderBottomWidth())); cell.setBorderWidthLeft(APdfBuilder.mmToPoints(getBorderLeftWidth())); cell.setBorderWidthRight(APdfBuilder.mmToPoints(getBorderRightWidth())); cell.setUseBorderPadding(false);/*from w ww . ja v a 2 s. co m*/ cell.setPadding(0); cell.setPaddingTop(APdfBuilder.mmToPoints(getPaddingTop())); cell.setPaddingBottom(APdfBuilder.mmToPoints(getPaddingBottom())); cell.setPaddingLeft(APdfBuilder.mmToPoints(getPaddingLeft())); cell.setPaddingRight(APdfBuilder.mmToPoints(getPaddingRight())); cell.setBackgroundColor(getBackgroundColor()); cell.setExtraParagraphSpace(0); cell.setIndent(0); cell.setColspan(getColspan()); for (ItextElement element : elements) cell.addElement(element.getITextElement()); return cell; }
From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java
License:Apache License
private void assignBorders(CellStyle style, PdfPCell pdfCell) { pdfCell.setBorderWidth(0);//from ww w .j a va 2 s .c o m if (pdfCell.getBackgroundColor() != Color.WHITE) { pdfCell.setBorderColor(pdfCell.getBackgroundColor()); } Border border = style.getBorders(Border.LINE_LEFT); if (border != null) { pdfCell.setBorderWidthLeft(border.getLineWidth()); pdfCell.setBorderColorLeft(border.getColor()); } border = style.getBorders(Border.LINE_RIGHT); if (border != null) { pdfCell.setBorderWidthRight(border.getLineWidth()); pdfCell.setBorderColorRight(border.getColor()); } if (pdfCell.getBackgroundColor() != Color.WHITE) { pdfCell.setBorderWidthRight(0.5f); } border = style.getBorders(Border.LINE_TOP); if (border != null) { pdfCell.setBorderWidthTop(border.getLineWidth()); pdfCell.setBorderColorTop(border.getColor()); } border = style.getBorders(Border.LINE_BOTTOM); if (border != null) { pdfCell.setBorderWidthBottom(border.getLineWidth()); pdfCell.setBorderColorBottom(border.getColor()); } if (pdfCell.getBackgroundColor() != Color.WHITE) { pdfCell.setBorderWidthBottom(0.5f); } }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFCarnet(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.WHITE); celda.setColspan(colspan);//from www . j a va2 s .c o m celda.setBorderWidth(0); celda.setBorderWidthBottom(borde); celda.setPadding(0); celda.setPaddingBottom(padding); return celda; }