List of usage examples for com.itextpdf.text Rectangle getLeft
public float getLeft()
From source file:com.planfeed.others.HeaderFooter.java
License:Apache License
public void onEndPage(PdfWriter writer, Document document) { Rectangle rect = writer.getBoxSize("art"); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT, header, rect.getRight(), rect.getTop(), 0);//from w w w . j a va2 s . com ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(String.format("page %d", pagenumber)), (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 18, 0); }
From source file:com.softwaremagico.tm.pdf.complete.elements.CellCompleteBoxEvent.java
License:Open Source License
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfContentByte canvas = canvases[PdfPTable.LINECANVAS]; canvas.setLineWidth(borderThickness); int bottomMargin = isBorderEnabled(Border.BOTTOM) ? margin : 0; int topMargin = isBorderEnabled(Border.TOP) ? margin : 0; int leftMargin = isBorderEnabled(Border.LEFT) ? margin : 0; int rightMargin = isBorderEnabled(Border.RIGHT) ? margin : 0; if (isBorderEnabled(Border.TOP)) { canvas.moveTo(position.getLeft() + leftMargin, position.getTop() - topMargin); canvas.lineTo(position.getRight() - rightMargin, position.getTop() - topMargin); }//from w ww .j a v a2 s. c o m if (isBorderEnabled(Border.BOTTOM)) { canvas.moveTo(position.getLeft() + leftMargin, position.getBottom() + bottomMargin); canvas.lineTo(position.getRight() - rightMargin, position.getBottom() + bottomMargin); } if (isBorderEnabled(Border.RIGHT)) { canvas.moveTo(position.getRight() - rightMargin, position.getBottom() + bottomMargin); canvas.lineTo(position.getRight() - rightMargin, position.getTop() - topMargin); } if (isBorderEnabled(Border.LEFT)) { canvas.moveTo(position.getLeft() + leftMargin, position.getBottom() + bottomMargin); canvas.lineTo(position.getLeft() + leftMargin, position.getTop() - topMargin); } canvas.stroke(); }
From source file:com.softwaremagico.tm.pdf.complete.elements.CellDottedBorderEvent.java
License:Open Source License
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfContentByte canvas = canvases[PdfPTable.LINECANVAS]; canvas.setLineDash(3f, 3f);// w ww . j av a2 s.c o m canvas.moveTo(position.getLeft(), position.getTop()); canvas.lineTo(position.getRight(), position.getTop()); canvas.moveTo(position.getLeft(), position.getBottom()); canvas.lineTo(position.getRight(), position.getBottom()); canvas.stroke(); }
From source file:com.vectorprint.report.itext.debug.CellAndTableDebugger.java
License:Open Source License
@Override public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { if (colorToDebug != null) { DebugHelper.debugBackground(canvases[PdfPTable.BACKGROUNDCANVAS], position, colorToDebug, "bg", getSettings(), ds.getLm()); }/* w w w. j a v a2 s . c o m*/ DebugHelper.debugRect(canvases[PdfPTable.TEXTCANVAS], position, new float[] { 2, 2 }, 0.3f, getSettings(), ds.getLm()); DebugHelper.styleLink(canvases[PdfPTable.TEXTCANVAS], DebugHelper.getFirstNotDefaultStyleClass(styleSetup), " (cell event)", position.getLeft(), position.getTop(), getSettings(), ds.getLm()); }
From source file:com.vectorprint.report.itext.debug.CellAndTableDebugger.java
License:Open Source License
@Override protected void paintRow(int row, Rectangle rect, PdfContentByte[] canvases, boolean last, boolean first) { if (first) {/*from w ww . j a v a 2 s . co m*/ DebugHelper.styleLink(canvases[PdfPTable.TEXTCANVAS], DebugHelper.getFirstNotDefaultStyleClass(styleSetup), " (table event)", rect.getLeft(), rect.getTop() + 6, getSettings(), ds.getLm()); } }
From source file:com.vectorprint.report.itext.debug.DebugHelper.java
License:Open Source License
public static void debugBackground(PdfContentByte canvas, Rectangle rect, BaseColor color, String prefix, EnhancedMap settings, LayerManager layerAware) { canvas = canvas.getPdfWriter().getDirectContentUnder(); int rgb = color.getRed() + color.getBlue() + color.getGreen(); rect.setBackgroundColor(color);// w w w . java 2 s . co m canvas.rectangle(rect); layerAware.startLayerInGroup(DEBUG, canvas); debugFont(canvas, settings); BaseColor txtColor = (rgb < 150) ? color.brighter().brighter() : color.darker().darker(); canvas.setColorFill(txtColor); canvas.setColorStroke(txtColor); canvas.beginText(); canvas.showTextAligned(Element.ALIGN_LEFT, prefix + color.toString().replace(Color.class.getName(), ""), rect.getLeft() + rect.getWidth() / 2, rect.getTop() - rect.getHeight() / 2, 0); canvas.endText(); canvas.endLayer(); }
From source file:com.vectorprint.report.itext.debug.DebugHelper.java
License:Open Source License
/** * adding a link (annotation) to information about the styleClass used * * @param rectangle the value of rectangle * @param styleClass the value of styleClass * @param writer the value of writer/* w w w .j a v a 2 s .c o m*/ */ public static void debugAnnotation(Rectangle rectangle, String styleClass, PdfWriter writer) { if (styleClass == null) { log.warning("not showing link to styleClass because there is no styleClass"); return; } // only now we can define a goto action, we know the position of the image PdfAction act = PdfAction.gotoLocalPage(styleClass, true); writer.getDirectContent().setAction(act, rectangle.getLeft(), rectangle.getBottom(), rectangle.getRight(), rectangle.getTop()); }
From source file:com.vectorprint.report.itext.debug.DebugHelper.java
License:Open Source License
public static void debugRect(PdfContentByte canvas, Rectangle rect, float[] dash, float borderWidth, EnhancedMap settings, LayerManager layerAware) { layerAware.startLayerInGroup(DEBUG, canvas); debugFont(canvas, settings);/*from w ww. ja v a 2s . c o m*/ canvas.setLineWidth(borderWidth); canvas.setLineDash(dash, 0); canvas.moveTo(rect.getLeft(), rect.getBottom()); canvas.lineTo(rect.getRight(), rect.getBottom()); canvas.lineTo(rect.getRight(), rect.getTop()); canvas.lineTo(rect.getLeft(), rect.getTop()); canvas.closePathStroke(); ItextHelper.resetLineDash(canvas); canvas.endLayer(); }
From source file:com.vectorprint.report.itext.debug.DebugStyler.java
License:Open Source License
@Override public void draw(Rectangle rect, String genericTag) throws VectorPrintException { if (getSettings().getBooleanProperty(Boolean.FALSE, DEBUG)) { PdfContentByte canvas = getWriter().getDirectContent(); DebugHelper.debugRect(canvas, rect, new float[] { 1, 3 }, 0.3f, getSettings(), getLayerManager()); DebugHelper.styleLink(canvas, DebugHelper.getFirstNotDefaultStyleClass(styleSetup), "", rect.getLeft(), rect.getTop(), getSettings(), getLayerManager()); }// w w w.j a v a 2s .c om }
From source file:com.vectorprint.report.itext.EventHelper.java
License:Open Source License
/** * Calls the super and {@link Advanced#draw(com.itextpdf.text.Rectangle, java.lang.String) } for each Advanced styler * registered. Adds a debugging link for images when in debug mode. * * @param writer//from w w w . j a v a2s .c o m * @param document * @param rect * @param genericTag * @see #addDelayedStyler(java.lang.String, java.util.Collection, com.itextpdf.text.Chunk) * @see Advanced#addDelayedData(java.lang.String, com.itextpdf.text.Chunk) * @see VectorPrintDocument */ @Override public final void onGenericTag(PdfWriter writer, Document document, final Rectangle rect, String genericTag) { // if (log.isLoggable(Level.FINE)) { // Collection<Advanced> av = doOnGenericTag.get(genericTag); // String data = null; // if (av!=null) { // for (Advanced a : av) { // data += a.getDelayed(genericTag).getDataPart(); // break; // } // } // System.out.println("wrapped: " + carriageReturns.toString() + ", " + genericTag + " " + data + " " + rect.toString() + ", x=" + rect.getLeft()); // } if (doOnGenericTag.get(genericTag) != null && !genericTag.startsWith(VectorPrintDocument.DRAWNEAR) && !genericTag.startsWith(VectorPrintDocument.DRAWSHADOW)) { int i = -1; for (Advanced a : doOnGenericTag.get(genericTag)) { ++i; if (genericTag.startsWith(DefaultElementProducer.ADV) && Integer .parseInt(genericTag.replace(DefaultElementProducer.ADV, "")) > maxTagForGenericTagOnPage) { continue; } try { if (a.shouldDraw(a.getDelayed(genericTag).getData())) { if (a instanceof DebugStyler && imageChunks.containsKey(genericTag)) { Chunk wrapper = imageChunks.get(genericTag); Object[] atts = (Object[]) wrapper.getAttributes().get(Chunk.IMAGE); Rectangle shifted = new Rectangle(rect); shifted.setLeft(shifted.getLeft() + (Float) atts[1]); shifted.setRight(shifted.getRight() + (Float) atts[1]); shifted.setTop(shifted.getTop() + (Float) atts[2]); shifted.setBottom(shifted.getBottom() + (Float) atts[2]); a.draw(shifted, genericTag); } else if (!genericTag.startsWith(VectorPrintDocument.IMG_DEBUG)) { a.draw(rect, genericTag); } } } catch (VectorPrintException ex) { throw new VectorPrintRuntimeException(ex); } } } // images if (genericTag.startsWith(VectorPrintDocument.IMG_DEBUG) && getSettings().getBooleanProperty(false, DEBUG)) { // only now we can define a goto action, we know the position of the image if (rectangles.containsKey(genericTag)) { Rectangle rectangle = imageRectFromChunk(genericTag, rect); DebugHelper.debugAnnotation(rectangle, genericTag.replaceFirst(VectorPrintDocument.IMG_DEBUG, ""), writer); } else { DebugHelper.debugAnnotation(rect, genericTag.replaceFirst(VectorPrintDocument.IMG_DEBUG, ""), writer); } } if (genericTag.startsWith(VectorPrintDocument.DRAWNEAR)) { Rectangle rectangle = imageRectFromChunk(genericTag, rect); com.vectorprint.report.itext.style.stylers.Image image = (com.vectorprint.report.itext.style.stylers.Image) doOnGenericTag .get(genericTag).iterator().next(); short i = -1; for (Advanced a : doOnGenericTag.get(genericTag)) { try { if (++i > 0 && a.shouldDraw(a.getDelayed(genericTag).getData())) { if (getSettings().getBooleanProperty(false, DEBUG)) { DebugHelper.styleLink(writer.getDirectContent(), a.getStyleClass(), "draw near", rectangle.getLeft(), rectangle.getTop(), getSettings(), elementProducer); } a.draw(rectangle, genericTag); } } catch (VectorPrintException ex) { throw new VectorPrintRuntimeException(ex); } } } if (genericTag.startsWith(VectorPrintDocument.DRAWSHADOW)) { // we know the position of the image Rectangle r = imageRectFromChunk(genericTag, rect); com.vectorprint.report.itext.style.stylers.Image image = (com.vectorprint.report.itext.style.stylers.Image) doOnGenericTag .get(genericTag).iterator().next(); try { image.drawShadow(r.getLeft(), r.getBottom(), r.getWidth(), r.getHeight(), genericTag.replaceFirst(VectorPrintDocument.DRAWSHADOW, "")); } catch (VectorPrintException ex) { throw new VectorPrintRuntimeException(ex); } } }