List of usage examples for com.lowagie.text.pdf PdfPCell setBorderColorRight
public void setBorderColorRight(Color borderColorRight)
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 ww w.j a v a 2 s .com*/ } 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 w w .j ava 2 s . c om 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);// w w w . jav a 2 s .c om 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;/* w w w. j a va 2s . 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;/*w ww .j a va 2 s . com*/ } 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;//w w w . j a v a 2 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.jsondoc.springmvc.pdf.PdfExportView.java
License:Open Source License
public File getPdfFile(String filename) { try {/*from w ww. jav a 2s. c o m*/ File file = new File(filename + "-v" + jsonDoc.getVersion() + FILE_EXTENSION); FileOutputStream fileout = new FileOutputStream(file); Document document = new Document(); PdfWriter.getInstance(document, fileout); // Header HeaderFooter header = new HeaderFooter(new Phrase("Copyright " + Calendar.getInstance().get(Calendar.YEAR) + " Paybay Networks - All rights reserved"), false); header.setBorder(Rectangle.NO_BORDER); header.setAlignment(Element.ALIGN_LEFT); document.setHeader(header); // Footer HeaderFooter footer = new HeaderFooter(new Phrase("Page "), true); footer.setBorder(Rectangle.NO_BORDER); footer.setAlignment(Element.ALIGN_CENTER); document.setFooter(footer); document.open(); //init documentation apiDocs = buildApiDocList(); apiMethodDocs = buildApiMethodDocList(apiDocs); Phrase baseUrl = new Phrase("Base url: " + jsonDoc.getBasePath()); document.add(baseUrl); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); int pos = 1; for (ApiMethodDoc apiMethodDoc : apiMethodDocs) { Phrase phrase = new Phrase(/*"Description: " + */apiMethodDoc.getDescription()); document.add(phrase); document.add(Chunk.NEWLINE); PdfPTable table = new PdfPTable(2); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.setWidthPercentage(100); table.setWidths(new int[] { 50, 200 }); // HEADER CELL START TABLE table.addCell(ITextUtils.getHeaderCell("URL")); table.addCell(ITextUtils.getHeaderCell("<baseUrl> " + apiMethodDoc.getPath())); table.completeRow(); // FIRST CELL table.addCell(ITextUtils.getCell("Http Method", 0)); table.addCell(ITextUtils.getCell(apiMethodDoc.getVerb().name(), pos)); pos++; table.completeRow(); // PRODUCES if (!apiMethodDoc.getProduces().isEmpty()) { table.addCell(ITextUtils.getCell("Produces", 0)); table.addCell(ITextUtils.getCell(buildApiMethodProduces(apiMethodDoc), pos)); pos++; table.completeRow(); } // CONSUMES if (!apiMethodDoc.getConsumes().isEmpty()) { table.addCell(ITextUtils.getCell("Consumes", 0)); table.addCell(ITextUtils.getCell(buildApiMethodConsumes(apiMethodDoc), pos)); pos++; table.completeRow(); } // HEADERS if (!apiMethodDoc.getHeaders().isEmpty()) { table.addCell(ITextUtils.getCell("Request headers", 0)); PdfPTable pathParamsTable = new PdfPTable(3); pathParamsTable.setWidths(new int[] { 30, 20, 40 }); pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); for (ApiHeaderDoc apiHeaderDoc : apiMethodDoc.getHeaders()) { PdfPCell boldCell = new PdfPCell(); Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD); boldCell.setPhrase(new Phrase(apiHeaderDoc.getName(), fontbold)); boldCell.getPhrase().setFont(new Font(Font.BOLD)); boldCell.setBorder(Rectangle.NO_BORDER); pathParamsTable.addCell(boldCell); PdfPCell paramCell = new PdfPCell(); StringBuilder builder = new StringBuilder(); for (String value : apiHeaderDoc.getAllowedvalues()) builder.append(value).append(", "); paramCell.setPhrase(new Phrase("Allowed values: " + builder.toString())); paramCell.setBorder(Rectangle.NO_BORDER); pathParamsTable.addCell(paramCell); paramCell.setPhrase(new Phrase(apiHeaderDoc.getDescription())); pathParamsTable.addCell(paramCell); pathParamsTable.completeRow(); } PdfPCell bluBorderCell = new PdfPCell(pathParamsTable); bluBorderCell.setBorder(Rectangle.NO_BORDER); bluBorderCell.setBorderWidthRight(1f); bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR); table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos)); pos++; table.completeRow(); } // PATH PARAMS if (!apiMethodDoc.getPathparameters().isEmpty()) { table.addCell(ITextUtils.getCell("Path params", 0)); PdfPTable pathParamsTable = new PdfPTable(3); pathParamsTable.setWidths(new int[] { 30, 15, 40 }); pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); for (ApiParamDoc apiParamDoc : apiMethodDoc.getPathparameters()) { PdfPCell boldCell = new PdfPCell(); Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD); boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold)); boldCell.getPhrase().setFont(new Font(Font.BOLD)); boldCell.setBorder(Rectangle.NO_BORDER); pathParamsTable.addCell(boldCell); PdfPCell paramCell = new PdfPCell(); paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText())); paramCell.setBorder(Rectangle.NO_BORDER); pathParamsTable.addCell(paramCell); paramCell.setPhrase(new Phrase(apiParamDoc.getDescription())); pathParamsTable.addCell(paramCell); pathParamsTable.completeRow(); } PdfPCell bluBorderCell = new PdfPCell(pathParamsTable); bluBorderCell.setBorder(Rectangle.NO_BORDER); bluBorderCell.setBorderWidthRight(1f); bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR); table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos)); pos++; table.completeRow(); } // QUERY PARAMS if (!apiMethodDoc.getQueryparameters().isEmpty()) { table.addCell(ITextUtils.getCell("Query params", 0)); PdfPTable queryParamsTable = new PdfPTable(3); queryParamsTable.setWidths(new int[] { 30, 15, 40 }); queryParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); queryParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); for (ApiParamDoc apiParamDoc : apiMethodDoc.getQueryparameters()) { PdfPCell boldCell = new PdfPCell(); Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD); boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold)); boldCell.getPhrase().setFont(new Font(Font.BOLD)); boldCell.setBorder(Rectangle.NO_BORDER); queryParamsTable.addCell(boldCell); PdfPCell paramCell = new PdfPCell(); paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText())); paramCell.setBorder(Rectangle.NO_BORDER); queryParamsTable.addCell(paramCell); paramCell.setPhrase(new Phrase( apiParamDoc.getDescription() + ", mandatory: " + apiParamDoc.getRequired())); queryParamsTable.addCell(paramCell); queryParamsTable.completeRow(); } PdfPCell bluBorderCell = new PdfPCell(queryParamsTable); bluBorderCell.setBorder(Rectangle.NO_BORDER); bluBorderCell.setBorderWidthRight(1f); bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR); table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos)); pos++; table.completeRow(); } // BODY OBJECT if (null != apiMethodDoc.getBodyobject()) { table.addCell(ITextUtils.getCell("Body object:", 0)); String jsonObject = buildJsonFromTemplate(apiMethodDoc.getBodyobject().getJsondocTemplate()); table.addCell(ITextUtils.getCell(jsonObject, pos)); pos++; table.completeRow(); } // RESPONSE OBJECT table.addCell(ITextUtils.getCell("Json response:", 0)); table.addCell( ITextUtils.getCell(apiMethodDoc.getResponse().getJsondocType().getOneLineText(), pos)); pos++; table.completeRow(); // RESPONSE STATUS CODE table.addCell(ITextUtils.getCell("Status code:", 0)); table.addCell(ITextUtils.getCell(apiMethodDoc.getResponsestatuscode(), pos)); pos++; table.completeRow(); table.setSpacingAfter(10f); table.setSpacingBefore(5f); document.add(table); } document.close(); return file; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } return null; }
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) {//w w w.j av a2s. c o 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 ww . ja 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); }