/** * 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; }
/** * 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; }
private void addToPropertiesAndBeginLayer(IPdfOCG layer) { PdfName name = resources.addProperties(layer.getPdfObject()); contentStream.getOutputStream().write(PdfName.OC).writeSpace() .write(name).writeSpace().writeBytes(BDC).writeNewLine(); }
/** * Sets text rendering mode. * * @param textRenderingMode text rendering mode @see PdfCanvasConstants. * @return current canvas. */ public PdfCanvas setTextRenderingMode(int textRenderingMode) { currentGs.setTextRenderingMode(textRenderingMode); contentStream.getOutputStream() .writeInteger(textRenderingMode).writeSpace() .writeBytes(Tr); return this; }
/** * Paints a shading object and adds it to the resources of this canvas * * @param shading * @return current canvas. */ public PdfCanvas paintShading(PdfShading shading) { PdfName shadingName = resources.addShading(shading); contentStream.getOutputStream().write((PdfObject) shadingName).writeSpace().writeBytes(sh); return this; }
/** * Sets the character spacing parameter. * * @param charSpacing a parameter * @return current canvas. */ public PdfCanvas setCharacterSpacing(float charSpacing) { currentGs.setCharSpacing(charSpacing); contentStream.getOutputStream() .writeFloat(charSpacing).writeSpace() .writeBytes(Tc); return this; }
/** * Sets the word spacing parameter. * * @param wordSpacing a parameter * @return current canvas. */ public PdfCanvas setWordSpacing(float wordSpacing) { currentGs.setWordSpacing(wordSpacing); contentStream.getOutputStream() .writeFloat(wordSpacing).writeSpace() .writeBytes(Tw); return this; }
/** * Changes the value of the <VAR>line dash pattern</VAR>. * <br> * The line dash pattern controls the pattern of dashes and gaps used to stroke paths. * It is specified by an <I>array</I> and a <I>phase</I>. The array specifies the length * of the alternating dashes and gaps. The phase specifies the distance into the dash * pattern to start the dash. * * @param phase the value of the phase * @return current canvas. */ public PdfCanvas setLineDash(float phase) { currentGs.setDashPattern(getDashPatternArray(phase)); contentStream.getOutputStream().writeByte('[').writeByte(']').writeSpace() .writeFloat(phase).writeSpace() .writeBytes(d); return this; }
/** * Sets the horizontal scaling parameter. * * @param scale a parameter. * @return current canvas. */ public PdfCanvas setHorizontalScaling(float scale) { currentGs.setHorizontalScaling(scale); contentStream.getOutputStream() .writeFloat(scale) .writeSpace() .writeBytes(Tz); return this; }
/** * Sets the text rise parameter. * <br> * This allows to write text in subscript or superscript mode. * <br> * * @param textRise a parameter * @return current canvas. */ public PdfCanvas setTextRise(float textRise) { currentGs.setTextRise(textRise); contentStream.getOutputStream() .writeFloat(textRise).writeSpace() .writeBytes(Ts); return this; }
/** * Sets the text leading parameter. * <br> * The leading parameter is measured in text space units. It specifies the vertical distance * between the baselines of adjacent lines of text. *<br> * * @param leading the new leading. * @return current canvas. */ public PdfCanvas setLeading(float leading) { currentGs.setLeading(leading); contentStream.getOutputStream() .writeFloat(leading) .writeSpace() .writeBytes(TL); return this; }
/** * Sets line width. * * @param lineWidth line width. * @return current canvas. */ public PdfCanvas setLineWidth(float lineWidth) { if (currentGs.getLineWidth() == lineWidth) { return this; } currentGs.setLineWidth(lineWidth); contentStream.getOutputStream() .writeFloat(lineWidth).writeSpace() .writeBytes(w); return this; }
/** * Sets the miter limit, a parameter specifying the maximum length a miter join * may extend beyond the join point, relative to the angle of the line segments. * * @param miterLimit * @return current canvas. */ public PdfCanvas setMiterLimit(float miterLimit) { if (currentGs.getMiterLimit() == miterLimit) return this; currentGs.setMiterLimit(miterLimit); contentStream.getOutputStream() .writeFloat(miterLimit).writeSpace() .writeBytes(M); return this; }
/** * Sets the line join style, the shape to be used at the corners of paths * when they are stroked. * * @param lineJoinStyle * @return current canvas. * @see PdfCanvasConstants.LineJoinStyle for possible values. */ public PdfCanvas setLineJoinStyle(int lineJoinStyle) { if (currentGs.getLineJoinStyle() == lineJoinStyle) return this; currentGs.setLineJoinStyle(lineJoinStyle); contentStream.getOutputStream() .writeInteger(lineJoinStyle).writeSpace() .writeBytes(j); return this; }
/** * Sets the ExtGState dictionary for the current graphics state * * @param extGState a dictionary that maps resource names to graphics state parameter dictionaries * @return current canvas. */ public PdfCanvas setExtGState(PdfExtGState extGState) { if (!extGState.isFlushed()) currentGs.updateFromExtGState(extGState, document); PdfName name = resources.addExtGState(extGState); contentStream.getOutputStream().write(name).writeSpace().writeBytes(gs); document.checkIsoConformance(currentGs, IsoKey.EXTENDED_GRAPHICS_STATE); return this; }
private PdfCanvas addImage(PdfXObject xObject, float a, float b, float c, float d, float e, float f) { saveState(); concatMatrix(a, b, c, d, e, f); PdfName name = resources.addImage(xObject.getPdfObject()); contentStream.getOutputStream().write(name).writeSpace().writeBytes(Do); restoreState(); return this; }
/** * Set the rendering intent. possible values are: PdfName.AbsoluteColorimetric, * PdfName.RelativeColorimetric, PdfName.Saturation, PdfName.Perceptual. * * @param renderingIntent a PdfName containing a color metric * @return current canvas. */ public PdfCanvas setRenderingIntent(PdfName renderingIntent) { document.checkIsoConformance(renderingIntent, IsoKey.RENDERING_INTENT); if (renderingIntent.equals(currentGs.getRenderingIntent())) return this; currentGs.setRenderingIntent(renderingIntent); contentStream.getOutputStream() .write(renderingIntent).writeSpace() .writeBytes(ri); return this; }
private void write(PdfArray pdfArray) { writeByte('['); for (int i = 0; i < pdfArray.size(); i++) { PdfObject value = pdfArray.get(i, false); PdfIndirectReference indirectReference; if ((indirectReference = value.getIndirectReference()) != null) { write(indirectReference); } else { write(value); } if (i < pdfArray.size() - 1) writeSpace(); } writeByte(']'); }
/** * Writes object to body of PDF document. * * @param pdfObj object to write. * @throws IOException */ protected void writeToBody(PdfObject pdfObj) throws IOException { if (crypto != null) { crypto.setHashKeyForNextObject(pdfObj.getIndirectReference().getObjNumber(), pdfObj.getIndirectReference().getGenNumber()); } writeInteger(pdfObj.getIndirectReference().getObjNumber()). writeSpace(). writeInteger(pdfObj.getIndirectReference().getGenNumber()).writeBytes(obj); write(pdfObj); writeBytes(endobj); }