List of usage examples for com.lowagie.text.pdf PdfPTable LINECANVAS
int LINECANVAS
To view the source code for com.lowagie.text.pdf PdfPTable LINECANVAS.
Click Source Link
PdfContentByte
where the border lines will be drawn. From source file:com.qcadoo.report.api.pdf.TableBorderEvent.java
License:Open Source License
@Override public void tableLayout(final PdfPTable table, final float[][] widths, final float[] heights, final int headerRows, final int rowStart, final PdfContentByte[] canvases) { float[] width = widths[0]; float x1 = width[0]; float x2 = width[width.length - 1]; float y1 = heights[0]; float y2 = heights[heights.length - 1]; PdfContentByte cb = canvases[PdfPTable.LINECANVAS]; cb.saveState();/*from w ww . j a v a 2 s.c om*/ cb.setLineWidth(1); cb.setColorStroke(ColorUtils.getLineDarkColor()); cb.rectangle(x1, y1, x2 - x1, y2 - y1); cb.stroke(); cb.restoreState(); }
From source file:org.mapfish.print.ChunkDrawer.java
License:Open Source License
public void tableLayout(PdfPTable table, float widths[][], float heights[], int headerRows, int rowStart, PdfContentByte[] canvases) {//from w w w . j a v a2 s . c o m PdfContentByte dc = canvases[PdfPTable.LINECANVAS]; Rectangle rect = new Rectangle(widths[0][0], heights[1], widths[0][1], heights[0]); render(rect, dc); }
From source file:org.revager.export.PDFCellEventExtRef.java
License:Open Source License
@Override public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) { PdfContentByte cb = canvas[PdfPTable.LINECANVAS]; // cb.reset(); Rectangle attachmentRect = new Rectangle(rect.getLeft() - 25, rect.getTop() - 25, rect.getRight() - rect.getWidth() - 40, rect.getTop() - 10); String fileDesc = file.getName() + " (" + translate("File Attachment") + ")"; try {/*www.j a va 2 s .c o m*/ PdfAnnotation attachment = PdfAnnotation.createFileAttachment(writer, attachmentRect, fileDesc, null, file.getAbsolutePath(), file.getName()); writer.addAnnotation(attachment); } catch (IOException e) { /* * just do not add a reference if the file was not found or another * error occured. */ } // cb.setColorStroke(new GrayColor(0.8f)); // cb.roundRectangle(rect.getLeft() + 4, rect.getBottom(), // rect.getWidth() - 8, rect.getHeight() - 4, 4); cb.stroke(); }
From source file:org.unitime.timetable.export.PDFPrinter.java
License:Open Source License
@Override public void printLine(String... fields) { PdfPCellEvent setLineDashEvent = new PdfPCellEvent() { @Override//from w w w . j a v a 2 s. co m public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) { PdfContentByte cb = canvas[PdfPTable.LINECANVAS]; cb.setLineDash(new float[] { 2, 2 }, 0); } }; for (int idx = 0; idx < fields.length; idx++) { if (iHiddenColumns.contains(idx)) continue; String f = fields[idx]; if (f == null || f.isEmpty() || (iCheckLast && f.equals(iLastLine == null || idx >= iLastLine.length ? null : iLastLine[idx]))) f = ""; boolean number = sNumber.matcher(f).matches(); Font font = PdfFont.getFont(); Phrase p = new Phrase(f, PdfFont.getSmallFont()); PdfPCell cell = new PdfPCell(p); cell.setBorder(iLastLine == null ? Rectangle.TOP : Rectangle.NO_BORDER); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(number ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT); cell.setPaddingBottom(4f); cell.setCellEvent(setLineDashEvent); if (number) cell.setPaddingRight(10f); iTable.addCell(cell); float width = 0; if (f.indexOf('\n') >= 0) { for (StringTokenizer s = new StringTokenizer(f, "\n"); s.hasMoreTokens();) width = Math.max(width, font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize())); } else width = Math.max(width, font.getBaseFont().getWidthPoint(f, font.getSize())); iMaxWidth[idx] = Math.max(iMaxWidth[idx], width + (number ? 10 : 0)); } iLastLine = fields; }