/** * Draws a rectangle. * * @param x x coordinate of the starting point. * @param y y coordinate of the starting point. * @param width width. * @param height height. * @return current canvas. */ public PdfCanvas rectangle(double x, double y, double width, double height) { contentStream.getOutputStream().writeDouble(x). writeSpace(). writeDouble(y). writeSpace(). writeDouble(width). writeSpace(). writeDouble(height). writeSpace(). writeBytes(re); return this; }
/** * Appends a Bêzier curve to the path, starting from the current point. * * @param x1 x coordinate of the first control point. * @param y1 y coordinate of the first control point. * @param x2 x coordinate of the second control point. * @param y2 y coordinate of the second control point. * @param x3 x coordinate of the ending point. * @param y3 y coordinate of the ending point. * @return current canvas. */ public PdfCanvas curveTo(double x1, double y1, double x2, double y2, double x3, double y3) { contentStream.getOutputStream() .writeDouble(x1) .writeSpace() .writeDouble(y1) .writeSpace() .writeDouble(x2) .writeSpace() .writeDouble(y2) .writeSpace() .writeDouble(x3) .writeSpace() .writeDouble(y3) .writeSpace() .writeBytes(c); return this; }
/** * Appends a Bezier curve to the path, starting from the current point. * * @param x2 x coordinate of the second control point. * @param y2 y coordinate of the second control point. * @param x3 x coordinate of the ending point. * @param y3 y coordinate of the ending point. * @return current canvas. */ public PdfCanvas curveTo(double x2, double y2, double x3, double y3) { contentStream.getOutputStream() .writeDouble(x2) .writeSpace() .writeDouble(y2) .writeSpace() .writeDouble(x3) .writeSpace() .writeDouble(y3).writeSpace() .writeBytes(v); return this; }
/** * Appends a Bezier curve to the path, starting from the current point. * * @param x1 x coordinate of the first control point. * @param y1 y coordinate of the first control point. * @param x3 x coordinate of the ending point. * @param y3 y coordinate of the ending point. * @return current canvas. */ public PdfCanvas curveFromTo(double x1, double y1, double x3, double y3) { contentStream.getOutputStream() .writeDouble(x1) .writeSpace() .writeDouble(y1) .writeSpace() .writeDouble(x3) .writeSpace() .writeDouble(y3).writeSpace() .writeBytes(y); return this; }
/** * Concatenates the 2x3 affine transformation matrix to the current matrix * in the content stream managed by this Canvas. * Contrast with {@link PdfCanvas#setTextMatrix} * * @param a operand 1,1 in the matrix. * @param b operand 1,2 in the matrix. * @param c operand 2,1 in the matrix. * @param d operand 2,2 in the matrix. * @param e operand 3,1 in the matrix. * @param f operand 3,2 in the matrix. * @return current canvas */ public PdfCanvas concatMatrix(double a, double b, double c, double d, double e, double f) { currentGs.updateCtm((float) a, (float) b, (float) c, (float) d, (float) e, (float) f); contentStream.getOutputStream().writeDouble(a).writeSpace(). writeDouble(b).writeSpace(). writeDouble(c).writeSpace(). writeDouble(d).writeSpace(). writeDouble(e).writeSpace(). writeDouble(f).writeSpace().writeBytes(cm); return this; }
/** * Moves text by shifting text line matrix (PDF Td operator). * * @param x x coordinate. * @param y y coordinate. * @return current canvas. */ public PdfCanvas moveText(double x, double y) { contentStream.getOutputStream() .writeDouble(x) .writeSpace() .writeDouble(y).writeSpace() .writeBytes(Td); return this; }
/** * Move the current point <i>(x, y)</i>, omitting any connecting line segment. * * @param x x coordinate. * @param y y coordinate. * @return current canvas. */ public PdfCanvas moveTo(double x, double y) { contentStream.getOutputStream() .writeDouble(x) .writeSpace() .writeDouble(y).writeSpace() .writeBytes(m); return this; }
/** * Appends a straight line segment from the current point <i>(x, y)</i>. The new current * point is <i>(x, y)</i>. * * @param x x coordinate. * @param y y coordinate. * @return current canvas. */ public PdfCanvas lineTo(double x, double y) { contentStream.getOutputStream() .writeDouble(x) .writeSpace() .writeDouble(y).writeSpace() .writeBytes(l); return this; }
private void write(PdfNumber pdfNumber) { if (pdfNumber.hasContent()) { writeBytes(pdfNumber.getInternalContent()); } else if (pdfNumber.isDoubleNumber()) { writeDouble(pdfNumber.getValue()); } else { writeInteger(pdfNumber.intValue()); } }