List of usage examples for com.lowagie.text.pdf PdfPCell setBorderColorLeft
public void setBorderColorLeft(Color borderColorLeft)
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;/*from w w w .j a va2s .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);/*w ww. ja v a2 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 w w w. jav a 2s.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:org.apache.poi.xwpf.converter.internal.itext.stylable.StyleUtils.java
License:Open Source License
public static void applyStyles(StyleBorder border, PdfPCell cell) { if (border == null) { return;/*from w w w. ja v a2 s. co m*/ } 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 BigInteger width = border.getWidth(); if (width != null) { cell.setBorderWidth(dxa2points(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 BigInteger width = border.getWidth(); if (width != null) { cell.setBorderWidthBottom(dxa2points(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 BigInteger width = border.getWidth(); if (width != null) { cell.setBorderWidthLeft(dxa2points(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 BigInteger width = border.getWidth(); if (width != null) { cell.setBorderWidthRight(dxa2points(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 BigInteger width = border.getWidth(); if (width != null) { cell.setBorderWidthTop(dxa2points(width)); } } break; } }
From source file:org.apache.poi.xwpf.converter.internal.itext.XWPFTableUtil.java
License:Open Source License
public static void setBorder(CTBorder border, PdfPCell pdfPCell, int borderSide) { if (border == null) { return;/*from ww w. ja v a 2 s. co m*/ } boolean noBorder = (STBorder.NONE == border.getVal()); // No border if (noBorder) { pdfPCell.disableBorderSide(borderSide); } else { float size = -1; BigInteger borderSize = border.getSz(); if (borderSize != null) { size = dxa2points(borderSize); } Color borderColor = null; String hexColor = getBorderColor(border); if (hexColor != null) { borderColor = ColorRegistry.getInstance().getColor("0x" + hexColor); } switch (borderSide) { case Rectangle.TOP: if (size != -1) { pdfPCell.setBorderWidthTop(size); } if (borderColor != null) { pdfPCell.setBorderColorTop(borderColor); } break; case Rectangle.BOTTOM: if (size != -1) { pdfPCell.setBorderWidthBottom(size); } if (borderColor != null) { pdfPCell.setBorderColorBottom(borderColor); } break; case Rectangle.LEFT: if (size != -1) { pdfPCell.setBorderWidthLeft(size); } if (borderColor != null) { pdfPCell.setBorderColorLeft(borderColor); } break; case Rectangle.RIGHT: if (size != -1) { pdfPCell.setBorderWidthRight(size); } if (borderColor != null) { pdfPCell.setBorderColorRight(borderColor); } break; } } }
From source file:org.apache.poi.xwpf.converter.internal.itext.XWPFTableUtil.java
License:Open Source License
public static void setBorder(StyleBorder border, PdfPCell pdfPCell, int borderSide) { if (border == null) { return;//from w w w.j a v a2 s . c o m } // boolean noBorder = (STBorder.NONE == border.getVal()); // No border float size = -1; BigInteger borderSize = border.getWidth(); if (borderSize != null) { size = dxa2points(borderSize); } Color borderColor = border.getColor(); switch (borderSide) { case Rectangle.TOP: if (size != -1) { pdfPCell.setBorderWidthTop(size); } if (borderColor != null) { pdfPCell.setBorderColorTop(borderColor); } break; case Rectangle.BOTTOM: if (size != -1) { pdfPCell.setBorderWidthBottom(size); } if (borderColor != null) { pdfPCell.setBorderColorBottom(borderColor); } break; case Rectangle.LEFT: if (size != -1) { pdfPCell.setBorderWidthLeft(size); } if (borderColor != null) { pdfPCell.setBorderColorLeft(borderColor); } break; case Rectangle.RIGHT: if (size != -1) { pdfPCell.setBorderWidthRight(size); } if (borderColor != null) { pdfPCell.setBorderColorRight(borderColor); } break; } }
From source file:org.mapfish.print.config.layout.CellConfig.java
License:Open Source License
protected void apply(PdfPCell cell, RenderingContext context, PJsonObject params) { if (paddingLeft != null) cell.setPaddingLeft(paddingLeft.floatValue()); if (paddingRight != null) cell.setPaddingRight(paddingRight.floatValue()); if (paddingTop != null) cell.setPaddingTop(paddingTop.floatValue()); if (paddingBottom != null) cell.setPaddingBottom(paddingBottom.floatValue()); if (borderWidthLeft != null) cell.setBorderWidthLeft(borderWidthLeft.floatValue()); if (borderWidthRight != null) cell.setBorderWidthRight(borderWidthRight.floatValue()); if (borderWidthTop != null) cell.setBorderWidthTop(borderWidthTop.floatValue()); if (borderWidthBottom != null) cell.setBorderWidthBottom(borderWidthBottom.floatValue()); if (getBorderColorLeftVal(context, params) != null) cell.setBorderColorLeft(getBorderColorLeftVal(context, params)); if (getBorderColorRightVal(context, params) != null) cell.setBorderColorRight(getBorderColorRightVal(context, params)); if (getBorderColorTopVal(context, params) != null) cell.setBorderColorTop(getBorderColorTopVal(context, params)); if (getBorderColorBottomVal(context, params) != null) cell.setBorderColorBottom(getBorderColorBottomVal(context, params)); if (getBackgroundColorVal(context, params) != null) cell.setBackgroundColor(getBackgroundColorVal(context, params)); if (align != null) cell.setHorizontalAlignment(align.getCode()); if (vertAlign != null) cell.setVerticalAlignment(vertAlign.getCode()); }
From source file:org.mapfish.print.config.layout.TableConfig.java
License:Open Source License
public void apply(PdfPCell cell, int row, int col, int nbRows, int nbCols, RenderingContext context, PJsonObject params) {//from ww w . j ava 2 s.co m if (cells != null) { for (int i = 0; i < cells.size(); i++) { CellException cellException = cells.get(i); if (cellException.matches(row, col)) { cellException.apply(cell, context, params); } } } if (row == 0) { if (borderWidthTop != null) cell.setBorderWidthTop(borderWidthTop.floatValue()); if (getBorderColorTopVal(context, params) != null) cell.setBorderColorTop(getBorderColorTopVal(context, params)); } if (col == 0) { if (borderWidthLeft != null) cell.setBorderWidthLeft(borderWidthLeft.floatValue()); if (getBorderColorLeftVal(context, params) != null) cell.setBorderColorLeft(getBorderColorLeftVal(context, params)); } if (row == nbRows - 1) { if (borderWidthBottom != null) cell.setBorderWidthBottom(borderWidthBottom.floatValue()); if (getBorderColorBottomVal(context, params) != null) cell.setBorderColorBottom(getBorderColorBottomVal(context, params)); } if (col == nbCols - 1) { if (borderWidthRight != null) cell.setBorderWidthRight(borderWidthRight.floatValue()); if (getBorderColorRightVal(context, params) != null) cell.setBorderColorRight(getBorderColorRightVal(context, params)); } }
From source file:org.unitime.timetable.webutil.PdfWebTable.java
License:Open Source License
private float addText(PdfPCell cell, String text, boolean bold, boolean italic, boolean underline, Color color, boolean borderTop, boolean borderBottom, boolean borderLeft, boolean borderRight, Color borderColor, Color bgColor) {/* w w w. j a va 2 s . c o m*/ cell.setBorderWidth(1); if (borderTop) { cell.setBorder(PdfPCell.TOP); if (borderColor == null) cell.setBorderColorTop(Color.BLACK); else cell.setBorderColorTop(borderColor); } if (borderBottom) { cell.setBorder(PdfPCell.BOTTOM); if (borderColor == null) cell.setBorderColorBottom(Color.BLACK); else cell.setBorderColorBottom(borderColor); } if (borderLeft) { cell.setBorder(PdfPCell.LEFT); if (borderColor == null) cell.setBorderColorLeft(Color.BLACK); else cell.setBorderColorLeft(borderColor); } if (borderRight) { cell.setBorder(PdfPCell.RIGHT); if (borderColor == null) cell.setBorderColorRight(Color.BLACK); else cell.setBorderColorRight(borderColor); } return addText(cell, text, bold, italic, underline, color, bgColor); }