List of usage examples for com.lowagie.text Rectangle BOTTOM
int BOTTOM
To view the source code for com.lowagie.text Rectangle BOTTOM.
Click Source Link
Rectangle
. From source file:gov.medicaid.services.impl.ExportServiceBean.java
License:Apache License
/** * Creates a header cell.//from ww w . jav a 2s . co m * * @param text * the header text * @param colspan * the span of the header * @return the generated cell. */ private static PdfPCell createHeaderCell(String text, int colspan) { PdfPCell header = new PdfPCell(new Phrase(text, FontFactory.getFont(FontFactory.HELVETICA_BOLD))); header.setBorder(Rectangle.BOTTOM); header.setColspan(colspan); return header; }
From source file:gov.medicaid.services.util.PDFHelper.java
License:Apache License
/** * Creates a header cell.//w w w . ja va2 s . com * * @param text the header text * @param colspan the span of the header * @return the generated cell. */ public static PdfPCell createHeaderCell(String text, int colspan) { PdfPCell header = new PdfPCell(new Phrase(text, FontFactory.getFont(FontFactory.HELVETICA_BOLD))); header.setBorder(Rectangle.BOTTOM); header.setColspan(colspan); return header; }
From source file:org.apache.poi.xwpf.converter.internal.itext.PDFMapper.java
License:Open Source License
@Override protected IITextContainer startVisitTableCell(XWPFTableCell cell, IITextContainer tableContainer) { StylableTable pdfPTable = (StylableTable) tableContainer; XWPFTableRow row = cell.getTableRow(); ExtendedPdfPCell pdfPCell = new ExtendedPdfPCell(); pdfPCell.setITextContainer(pdfPTable); CTTcPr tcPr = cell.getCTTc().getTcPr(); if (tcPr != null) { // Colspan Integer colspan = null;/*from w w w. j a v a 2s. c o m*/ CTDecimalNumber gridSpan = tcPr.getGridSpan(); if (gridSpan != null) { colspan = gridSpan.getVal().intValue(); } if (colspan != null) { pdfPCell.setColspan(colspan); } // Backround Color CTShd shd = tcPr.getShd(); String hexColor = null; if (shd != null) { hexColor = shd.xgetFill().getStringValue(); } if (hexColor != null && !"auto".equals(hexColor)) { pdfPCell.setBackgroundColor(ColorRegistry.getInstance().getColor("0x" + hexColor)); } // Borders // Table Properties on cells // overridden locally CTTcBorders borders = tcPr.getTcBorders(); if (borders != null) { // border-left setBorder(borders.getLeft(), pdfPCell, Rectangle.LEFT); // border-right setBorder(borders.getRight(), pdfPCell, Rectangle.RIGHT); // border-top setBorder(borders.getTop(), pdfPCell, Rectangle.TOP); // border-bottom setBorder(borders.getBottom(), pdfPCell, Rectangle.BOTTOM); } } int height = row.getHeight(); pdfPCell.setMinimumHeight(dxa2points(height)); return pdfPCell; }
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 www .jav a 2s . c om*/ } 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 ww . java2 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.apache.poi.xwpf.converter.pdf.internal.elements.StylableParagraph.java
License:Open Source License
public void setBorder(CTBorder border, int borderSide) { if (border == null) { return;//from w w w. j av a 2s . c om } boolean noBorder = (STBorder.NONE == border.getVal() || STBorder.NIL == border.getVal()); // No border if (noBorder) { return; } else { // border size float size = -1; BigInteger borderSize = border.getSz(); if (borderSize != null) { // http://officeopenxml.com/WPtableBorders.php // if w:sz="4" => 1/4 points size = borderSize.floatValue() / 8f; } // border color org.apache.poi.xwpf.converter.core.Color bdColor = ColorHelper.getBorderColor(border); Color borderColor = Converter.toAwtColor(bdColor); // border padding Float space = null; BigInteger borderSpace = border.getSpace(); if (borderSpace != null) { // Specifies the spacing offset. Values are specified in points (1/72nd of an inch). space = borderSpace.floatValue(); } switch (borderSide) { case Rectangle.TOP: if (size != -1) { this.setBorderWidthTop(size); } if (borderColor != null) { super.setBorderColorTop(borderColor); } if (space != null) { super.setBorderPaddingTop(space); } break; case Rectangle.BOTTOM: if (size != -1) { this.setBorderWidthBottom(size); } if (borderColor != null) { super.setBorderColorBottom(borderColor); } if (space != null) { super.setBorderPaddingBottom(space); } break; case Rectangle.LEFT: if (size != -1) { this.setBorderWidthLeft(size); } if (borderColor != null) { super.setBorderColorLeft(borderColor); } if (space != null) { super.setBorderPaddingLeft(space); } break; case Rectangle.RIGHT: if (size != -1) { this.setBorderWidthRight(size); } if (borderColor != null) { super.setBorderColorRight(borderColor); } if (space != null) { super.setBorderPaddingRight(space); } break; } } }
From source file:org.areasy.common.doclet.document.elements.CellBorderPadding.java
License:Open Source License
/** * Creates a PdfPCell with a border and a padding of 6. * * @param data The cell content./*www . j a v a2s . c o m*/ */ public CellBorderPadding(Phrase data) { super(data); super.setBorder(Rectangle.TOP + Rectangle.LEFT + Rectangle.BOTTOM + Rectangle.RIGHT); super.setPadding(6); super.setBorderWidth(1); super.setBorderColor(Color.gray); }
From source file:org.areasy.common.doclet.document.elements.CustomPdfPCell.java
License:Open Source License
/** * A coloured title bar (for the "Fields", "Methods" and * "Constructors" titles)./* w w w . j ava2 s.co m*/ */ public CustomPdfPCell(String title) { super(new Phrase(title, Fonts.getFont(TEXT_FONT, 18))); super.setPaddingTop((float) 0.0); super.setPaddingBottom((float) 5.0); super.setPaddingLeft((float) 3.0); super.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); super.setBackgroundColor(COLOR_SUMMARY_HEADER); super.setBorder(Rectangle.TOP + Rectangle.LEFT + Rectangle.BOTTOM + Rectangle.RIGHT); super.setBorderWidth(1); super.setBorderColor(Color.gray); }
From source file:org.areasy.common.doclet.document.elements.CustomPdfPCell.java
License:Open Source License
/** * A coloured title bar (for summary tables etc.) * * @param paragraph The text for the title. * @param backgroundColor Color of the cell *//*from w w w . jav a 2 s . c o m*/ public CustomPdfPCell(Paragraph paragraph, Color backgroundColor) { super(paragraph); super.setPaddingTop((float) 0.0); super.setPaddingBottom((float) 5.0); super.setPaddingLeft((float) 3.0); super.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); super.setBackgroundColor(backgroundColor); super.setBorder(Rectangle.TOP + Rectangle.LEFT + Rectangle.BOTTOM + Rectangle.RIGHT); super.setBorderWidth(1); super.setBorderColor(Color.gray); }
From source file:org.areasy.common.doclet.document.Inherited.java
License:Open Source License
/** * Prints inherited methods and fields from superclasses * * @param supercls class source to get inherited fields and methods for. * @param show SHOW_METHODS or SHOW_FIELDS * @throws Exception//w ww.j a v a2 s. com */ public static void print(ClassDoc supercls, int show) throws Exception { String type; FieldDoc[] fields = supercls.fields(); Arrays.sort(fields); if (supercls.isInterface()) type = "interface"; else type = "class"; // Create cell for additional spacing below PdfPCell spacingCell = new PdfPCell(); spacingCell.addElement(new Chunk(" ")); spacingCell.setFixedHeight((float) 4.0); spacingCell.setBorder(Rectangle.BOTTOM + Rectangle.LEFT + Rectangle.RIGHT); spacingCell.setBorderColor(Color.gray); if ((fields.length > 0) && (show == SHOW_FIELDS)) { Document.instance().add(new Paragraph((float) 6.0, " ")); PdfPTable table = new PdfPTable(1); table.setWidthPercentage((float) 100); Paragraph newLine = new Paragraph(); newLine.add(new Chunk("Fields inherited from " + type + " ", Fonts.getFont(TEXT_FONT, BOLD, 10))); newLine.add(new LinkPhrase(supercls.qualifiedTypeName(), null, 10, false)); table.addCell(new CustomPdfPCell(newLine, COLOR_INHERITED_SUMMARY)); Paragraph paraList = new Paragraph(); for (int i = 0; i < fields.length; i++) { paraList.add(new LinkPhrase(fields[i].qualifiedName(), fields[i].name(), 10, false)); if (i != (fields.length - 1)) paraList.add(new Chunk(", ", Fonts.getFont(TEXT_FONT, BOLD, 12))); } PdfPCell contentCell = new CellBorderPadding(paraList); float leading = (float) contentCell.getLeading() + (float) 1.1; contentCell.setLeading(leading, leading); table.addCell(contentCell); table.addCell(spacingCell); Document.instance().add(table); } MethodDoc[] meth = supercls.methods(); Arrays.sort(meth); if ((meth.length > 0) && (show == SHOW_METHODS)) { Document.instance().add(new Paragraph((float) 6.0, " ")); PdfPTable table = new CustomPdfPTable(); Paragraph newLine = new Paragraph(); newLine.add(new Chunk("Methods inherited from " + type + " ", Fonts.getFont(TEXT_FONT, BOLD, 10))); newLine.add(new LinkPhrase(supercls.qualifiedTypeName(), null, 10, false)); table.addCell(new CustomPdfPCell(newLine, COLOR_INHERITED_SUMMARY)); Paragraph paraList = new Paragraph(); for (int i = 0; i < meth.length; i++) { String methodLabel = meth[i].name(); // Do not list static initializers like "<clinit>" if (!methodLabel.startsWith("<")) { paraList.add(new LinkPhrase(supercls.qualifiedTypeName() + "." + meth[i].name(), meth[i].name(), 10, false)); if (i != (meth.length - 1)) paraList.add(new Chunk(", ", Fonts.getFont(CODE_FONT, 10))); } } PdfPCell contentCell = new CellBorderPadding(paraList); float leading = (float) contentCell.getLeading() + (float) 1.1; contentCell.setLeading(leading, leading); table.addCell(contentCell); table.addCell(spacingCell); Document.instance().add(table); } // Print inherited interfaces / class methods and fields recursively ClassDoc supersupercls = null; if (supercls.isClass()) supersupercls = supercls.superclass(); if (supersupercls != null) { String className = supersupercls.qualifiedName(); if (ifClassMustBePrinted(className)) Inherited.print(supersupercls, show); } ClassDoc[] interfaces = supercls.interfaces(); for (int i = 0; i < interfaces.length; i++) { supersupercls = interfaces[i]; String className = supersupercls.qualifiedName(); if (ifClassMustBePrinted(className)) Inherited.print(supersupercls, show); } }