PdfWriter writer = ...; PdfContentByte cb = writer.getDirectContent(); cb.saveState(); cb.setColorStroke(Color.black); cb.rectangle(x,y,x1,y1); cb.stroke(); cb.restoreState();
private static void absText(String text, int x, int y) { try { PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.saveState(); cb.beginText(); cb.moveText(x, y); cb.setFontAndSize(bf, 12); cb.showText(text); cb.endText(); cb.restoreState(); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void saveState(PdfContentByte cb) { cb.saveState(); MetaState state = new MetaState(this); savedStates.push(state); }
public void saveState(PdfContentByte cb) { cb.saveState(); MetaState state = new MetaState(this); savedStates.push(state); }
public void saveState(PdfContentByte cb) { cb.saveState(); MetaState state = new MetaState(this); savedStates.push(state); }
/** * @see com.lowagie.text.pdf.draw.DrawInterface#draw(com.lowagie.text.pdf.PdfContentByte, float, float, float, float, float) */ public void draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) { canvas.saveState(); drawLine(canvas, llx, urx, y); canvas.restoreState(); }
/** * @see com.lowagie.text.pdf.draw.DrawInterface#draw(com.lowagie.text.pdf.PdfContentByte, float, float, float, float, float) */ public void draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) { canvas.saveState(); drawLine(canvas, llx, urx, y); canvas.restoreState(); }
/** * @see com.lowagie.text.pdf.draw.DrawInterface#draw(com.lowagie.text.pdf.PdfContentByte, float, float, float, float, float) */ public void draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) { canvas.saveState(); drawLine(canvas, llx, urx, y); canvas.restoreState(); }
public void initializePage(PdfContentByte currentPage, float height) { _currentPage = currentPage; _pageHeight = height; _currentPage.saveState(); _transform = new AffineTransform(); _transform.scale(1.0d / _dotsPerPoint, 1.0d / _dotsPerPoint); _stroke = transformStroke(STROKE_ONE); _originalStroke = _stroke; _oldStroke = _stroke; setStrokeDiff(_stroke, null); if (_defaultDestination == null) { _defaultDestination = new PdfDestination(PdfDestination.FITH, height); _defaultDestination.addPage(_writer.getPageReference(1)); } _linkTargetAreas = new HashSet(); }
/** * @since 2.1.6 private is now protected */ protected void saveAndRotateCanvases(PdfContentByte[] canvases, float a, float b, float c, float d, float e, float f) { int last = PdfPTable.TEXTCANVAS + 1; if (canvasesPos == null) canvasesPos = new int[last * 2]; for (int k = 0; k < last; ++k) { ByteBuffer bb = canvases[k].getInternalBuffer(); canvasesPos[k * 2] = bb.size(); canvases[k].saveState(); canvases[k].concatCTM(a, b, c, d, e, f); canvasesPos[k * 2 + 1] = bb.size(); } }
/** * @since 2.1.6 private is now protected */ protected void saveAndRotateCanvases(PdfContentByte[] canvases, float a, float b, float c, float d, float e, float f) { int last = PdfPTable.TEXTCANVAS + 1; if (canvasesPos == null) canvasesPos = new int[last * 2]; for (int k = 0; k < last; ++k) { ByteBuffer bb = canvases[k].getInternalBuffer(); canvasesPos[k * 2] = bb.size(); canvases[k].saveState(); canvases[k].concatCTM(a, b, c, d, e, f); canvasesPos[k * 2 + 1] = bb.size(); } }
/** * @since 2.1.6 private is now protected */ protected void saveAndRotateCanvases(PdfContentByte[] canvases, float a, float b, float c, float d, float e, float f) { int last = PdfPTable.TEXTCANVAS + 1; if (canvasesPos == null) canvasesPos = new int[last * 2]; for (int k = 0; k < last; ++k) { ByteBuffer bb = canvases[k].getInternalBuffer(); canvasesPos[k * 2] = bb.size(); canvases[k].saveState(); canvases[k].concatCTM(a, b, c, d, e, f); canvasesPos[k * 2 + 1] = bb.size(); } }
/** * @see com.lowagie.text.pdf.draw.DrawInterface#draw(com.lowagie.text.pdf.PdfContentByte, float, float, float, float, float) */ public void draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) { canvas.saveState(); canvas.setLineWidth(lineWidth); canvas.setLineCap(PdfContentByte.LINE_CAP_ROUND); canvas.setLineDash(0, gap, gap / 2); drawLine(canvas, llx, urx, y); canvas.restoreState(); }
/** * @see com.lowagie.text.pdf.draw.DrawInterface#draw(com.lowagie.text.pdf.PdfContentByte, float, float, float, float, float) */ public void draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) { canvas.saveState(); canvas.setLineWidth(lineWidth); canvas.setLineCap(PdfContentByte.LINE_CAP_ROUND); canvas.setLineDash(0, gap, gap / 2); drawLine(canvas, llx, urx, y); canvas.restoreState(); }
PdfContentByte canvas = writer.getDirectContentUnder(); canvas.saveState(); canvas.beginText(); canvas.setFontAndSize(bf_helv, 12); canvas.showTextAligned(Element.ALIGN_LEFT, "Test TEXT - Why is it missing after download?", 100, 800,0); canvas.endText(); canvas.restoreState();
/** * @see com.lowagie.text.pdf.draw.DrawInterface#draw(com.lowagie.text.pdf.PdfContentByte, float, float, float, float, float) */ public void draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) { canvas.saveState(); canvas.setLineWidth(lineWidth); canvas.setLineCap(PdfContentByte.LINE_CAP_ROUND); canvas.setLineDash(0, gap, gap / 2); drawLine(canvas, llx, urx, y); canvas.restoreState(); }
PdfContentByte cb = writer.getDirectContentUnder(); cb.saveState(); cb.setLineWidth(1.2); cb.setColor(BaseColor.DARK_GRAY); cb.moveTo(x, y); cb.lineTo(x + width, y); cb.stroke(); cb.restoreState();
public static void drawRectangle(PdfContentByte content, float width, float height) { content.saveState(); PdfGState state = new PdfGState(); state.setFillOpacity(0.6f); content.setGState(state); content.setRGBColorFill(0xFF, 0xFF, 0xFF); content.setLineWidth(3); content.rectangle(0, 0, width, height); content.fillStroke(); content.restoreState(); }
public void onEndPage(PdfWriter writer, Document document) { PdfContentByte cb = writer.getDirectContent(); cb.saveState(); cb.setColorStroke(new CMYKColor(1f, 0f, 0f, 0f)); cb.setColorFill(new CMYKColor(1f, 0f, 0f, 0f)); cb.rectangle(20,10,10,820); cb.fill(); cb.restoreState(); }
public class MyPdfPageEvent extends PdfPageEventHelper { public void onGenericTag(PdfWriter writer, Document doc, Rectangle rect, String tag) { PdfContentByte canvas = writer.getDirectContent(); canvas.saveState(); canvas.setColorStroke(Color.BLACK); // or whatever // You can also mess with the line's thickness, endcaps, dash style, etc. // Lots of options to play with. canvas.moveTo(rect.getLeft(), rect.getBottom()); canvas.lineTo(rect.getRight(), rect.getTop()); canvas.stroke(); canvas.restoreState(); } }