Class PdfContentByte

  • Direct Known Subclasses:
    PdfTemplate, StampContent

    public class PdfContentByte
    extends java.lang.Object
    PdfContentByte is an object containing the user positioned text and graphic contents of a page. It knows how to apply the proper font encoding.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  PdfContentByte.GraphicState
      This class keeps the graphic state of the current page
    • Constructor Summary

      Constructors 
      Constructor Description
      PdfContentByte​(PdfWriter wr)
      Constructs a new PdfContentByte-object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void add​(PdfContentByte other)
      Adds the content of another PdfContent-object to this object.
      (package private) void addAnnotation​(PdfAnnotation annot)  
      void addOutline​(PdfOutline outline)
      Deprecated.
      not needed anymore.
      void addOutline​(PdfOutline outline, java.lang.String name)
      Adds a named outline to the document.
      void addPSXObject​(PdfPSXObject psobject)
      Adds a PostScript XObject to this content.
      void addTemplate​(PdfTemplate template, float x, float y)
      Adds a template to this content.
      void addTemplate​(PdfTemplate template, float a, float b, float c, float d, float e, float f)
      Adds a template to this content.
      void arc​(float x1, float y1, float x2, float y2, float startAng, float extent)
      Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees.
      void beginLayer​(PdfOCG layer)
      Begins a graphic block whose visibility is controled by the layer.
      private void beginLayer2​(PdfOCG layer)  
      void beginMarkedContentSequence​(PdfName tag)
      This is just a shorthand to beginMarkedContentSequence(tag, null, false).
      void beginMarkedContentSequence​(PdfName tag, PdfDictionary property, boolean inline)
      Begins a marked content sequence.
      void beginMarkedContentSequence​(PdfStructureElement struc)
      Begins a marked content sequence.
      void beginText()
      Starts the writing of text.
      static java.util.ArrayList bezierArc​(float x1, float y1, float x2, float y2, float startAng, float extent)
      Generates an array of bezier curves to draw an arc.
      (package private) void checkNoPattern​(PdfTemplate t)
      Throws an error if it is a pattern.
      protected void checkWriter()
      Check if we have a valid PdfWriter.
      void circle​(float x, float y, float r)
      Draws a circle.
      void clip()
      Modify the current clipping path by intersecting it with the current path, using the nonzero winding number rule to determine which regions lie inside the clipping path.
      void closePath()
      Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.
      void closePathEoFillStroke()
      Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it.
      void closePathFillStroke()
      Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it.
      void closePathStroke()
      Closes the path and strokes it.
      void concatCTM​(float a, float b, float c, float d, float e, float f)
      Concatenate a matrix to the current transformation matrix.
      PdfAppearance createAppearance​(float width, float height)
      Creates a new appearance to be used with form fields.
      (package private) PdfAppearance createAppearance​(float width, float height, PdfName forcedName)  
      PdfPatternPainter createPattern​(float width, float height)
      Create a new colored tiling pattern.
      PdfPatternPainter createPattern​(float width, float height, float xstep, float ystep)
      Create a new colored tiling pattern.
      PdfPatternPainter createPattern​(float width, float height, float xstep, float ystep, java.awt.Color color)
      Create a new uncolored tiling pattern.
      PdfPatternPainter createPattern​(float width, float height, java.awt.Color color)
      Create a new uncolored tiling pattern.
      PdfTemplate createTemplate​(float width, float height)
      Creates a new template.
      (package private) PdfTemplate createTemplate​(float width, float height, PdfName forcedName)  
      void curveFromTo​(float x1, float y1, float x3, float y3)
      Appends a Bêzier curve to the path, starting from the current point.
      void curveTo​(float x2, float y2, float x3, float y3)
      Appends a Bêzier curve to the path, starting from the current point.
      void curveTo​(float x1, float y1, float x2, float y2, float x3, float y3)
      Appends a Bêzier curve to the path, starting from the current point.
      void drawButton​(float llx, float lly, float urx, float ury, java.lang.String text, BaseFont bf, float size)
      Draws a button.
      void drawRadioField​(float llx, float lly, float urx, float ury, boolean on)
      Draws a TextField.
      void drawTextField​(float llx, float lly, float urx, float ury)
      Draws a TextField.
      void ellipse​(float x1, float y1, float x2, float y2)
      Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.
      void endLayer()
      Ends a layer controled graphic block.
      void endMarkedContentSequence()
      Ends a marked content sequence
      void endText()
      Ends the writing of text and makes the current font invalid.
      void eoClip()
      Modify the current clipping path by intersecting it with the current path, using the even-odd rule to determine which regions lie inside the clipping path.
      void eoFill()
      Fills the path, using the even-odd rule to determine the region to fill.
      void eoFillStroke()
      Fills the path, using the even-odd rule to determine the region to fill and strokes it.
      (package private) static byte[] escapeString​(byte[] b)
      Escapes a byte array according to the PDF conventions.
      (package private) static void escapeString​(byte[] b, ByteBuffer content)
      Escapes a byte array according to the PDF conventions.
      void fill()
      Fills the path, using the non-zero winding number rule to determine the region to fill.
      void fillStroke()
      Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.
      PdfContentByte getDuplicate()
      Gets a duplicate of this PdfContentByte.
      ByteBuffer getInternalBuffer()
      Gets the internal buffer.
      static PdfTextArray getKernArray​(java.lang.String text, BaseFont font)
      Constructs a kern array for a text in a certain font
      float getLeading()
      Gets the current text leading.
      (package private) PageResources getPageResources()
      Gets a Graphics2D to print on.
      PdfDocument getPdfDocument()
      Gets the PdfDocument in use by this object.
      PdfWriter getPdfWriter()
      Gets the PdfWriter in use by this object.
      PdfOutline getRootOutline()
      Gets the root outline.
      float getXTLM()
      Gets the x position of the text line matrix.
      float getYTLM()
      Gets the y position of the text line matrix.
      private void HelperCMYK​(float cyan, float magenta, float yellow, float black)
      Helper to validate and write the CMYK color components.
      private void HelperRGB​(float red, float green, float blue)
      Helper to validate and write the RGB color components
      void lineTo​(float x, float y)
      Appends a straight line segment from the current point (x, y).
      boolean localDestination​(java.lang.String name, PdfDestination destination)
      The local destination to where a local goto with the same name will jump.
      void localGoto​(java.lang.String name, float llx, float lly, float urx, float ury)
      Implements a link to other part of the document.
      void moveText​(float x, float y)
      Moves to the start of the next line, offset from the start of the current line.
      void moveTextWithLeading​(float x, float y)
      Moves to the start of the next line, offset from the start of the current line.
      void moveTo​(float x, float y)
      Move the current point (x, y), omitting any connecting line segment.
      void newlineShowText​(float wordSpacing, float charSpacing, java.lang.String text)
      Moves to the next line and shows text string, using the given values of the character and word spacing parameters.
      void newlineShowText​(java.lang.String text)
      Moves to the next line and shows text.
      void newlineText()
      Moves to the start of the next line.
      void newPath()
      Ends the path without filling or stroking it.
      (package private) void outputColorNumbers​(java.awt.Color color, float tint)
      Outputs the color values to the content.
      void paintShading​(PdfShading shading)
      Paints using a shading object.
      void paintShading​(PdfShadingPattern shading)
      Paints using a shading pattern.
      void rectangle​(float x, float y, float w, float h)
      Adds a rectangle to the current path.
      void rectangle​(Rectangle rectangle)
      Adds a border (complete or partially) to the current path..
      void remoteGoto​(java.lang.String filename, int page, float llx, float lly, float urx, float ury)
      Implements a link to another document.
      void remoteGoto​(java.lang.String filename, java.lang.String name, float llx, float lly, float urx, float ury)
      Implements a link to another document.
      void reset()
      Makes this PdfContentByte empty.
      void resetCMYKColorFill()
      Changes the current color for filling paths to black.
      void resetCMYKColorStroke()
      Changes the current color for stroking paths to black.
      void resetGrayFill()
      Changes the current gray tint for filling paths to black.
      void resetGrayStroke()
      Changes the current gray tint for stroking paths to black.
      void resetRGBColorFill()
      Changes the current color for filling paths to black.
      void resetRGBColorStroke()
      Changes the current color for stroking paths to black.
      void restoreState()
      Restores the graphic state.
      void roundRectangle​(float x, float y, float w, float h, float r)
      Adds a round rectangle to the current path.
      void saveState()
      Saves the graphic state.
      void setAction​(PdfAction action, float llx, float lly, float urx, float ury)
      Implements an action in an area.
      void setCharacterSpacing​(float charSpace)
      Sets the character spacing parameter.
      void setCMYKColorFill​(int cyan, int magenta, int yellow, int black)
      Changes the current color for filling paths (device dependent colors!).
      void setCMYKColorFillF​(float cyan, float magenta, float yellow, float black)
      Changes the current color for filling paths (device dependent colors!).
      void setCMYKColorStroke​(int cyan, int magenta, int yellow, int black)
      Changes the current color for stroking paths (device dependent colors!).
      void setCMYKColorStrokeF​(float cyan, float magenta, float yellow, float black)
      Changes the current color for stroking paths (device dependent colors!).
      void setColorFill​(PdfSpotColor sp, float tint)
      Sets the fill color to a spot color.
      void setColorFill​(java.awt.Color color)
      Sets the fill color.
      void setColorStroke​(PdfSpotColor sp, float tint)
      Sets the stroke color to a spot color.
      void setColorStroke​(java.awt.Color color)
      Sets the stroke color.
      void setDefaultColorspace​(PdfName name, PdfObject obj)
      Sets the default colorspace.
      void setFlatness​(float flatness)
      Changes the Flatness.
      void setFontAndSize​(BaseFont bf, float size)
      Set the font and the size for the subsequent text writing.
      void setGrayFill​(float gray)
      Changes the currentgray tint for filling paths (device dependent colors!).
      void setGrayStroke​(float gray)
      Changes the currentgray tint for stroking paths (device dependent colors!).
      void setGState​(PdfGState gstate)
      Sets the graphic state
      void setHorizontalScaling​(float scale)
      Sets the horizontal scaling parameter.
      void setLeading​(float leading)
      Sets the text leading parameter.
      void setLineCap​(int style)
      Changes the Line cap style.
      void setLineDash​(float phase)
      Changes the value of the line dash pattern.
      void setLineDash​(float[] array, float phase)
      Changes the value of the line dash pattern.
      void setLineDash​(float unitsOn, float phase)
      Changes the value of the line dash pattern.
      void setLineDash​(float unitsOn, float unitsOff, float phase)
      Changes the value of the line dash pattern.
      void setLineJoin​(int style)
      Changes the Line join style.
      void setLineWidth​(float w)
      Changes the line width.
      void setLiteral​(char c)
      Outputs a char directly to the content.
      void setLiteral​(float n)
      Outputs a float directly to the content.
      void setLiteral​(java.lang.String s)
      Outputs a String directly to the content.
      void setMiterLimit​(float miterLimit)
      Changes the Miter limit.
      void setPatternFill​(PdfPatternPainter p)
      Sets the fill color to a pattern.
      void setPatternFill​(PdfPatternPainter p, java.awt.Color color)
      Sets the fill color to an uncolored pattern.
      void setPatternFill​(PdfPatternPainter p, java.awt.Color color, float tint)
      Sets the fill color to an uncolored pattern.
      void setPatternStroke​(PdfPatternPainter p)
      Sets the stroke color to a pattern.
      void setPatternStroke​(PdfPatternPainter p, java.awt.Color color)
      Sets the stroke color to an uncolored pattern.
      void setPatternStroke​(PdfPatternPainter p, java.awt.Color color, float tint)
      Sets the stroke color to an uncolored pattern.
      void setRGBColorFill​(int red, int green, int blue)
      Changes the current color for filling paths (device dependent colors!).
      void setRGBColorFillF​(float red, float green, float blue)
      Changes the current color for filling paths (device dependent colors!).
      void setRGBColorStroke​(int red, int green, int blue)
      Changes the current color for stroking paths (device dependent colors!).
      void setRGBColorStrokeF​(float red, float green, float blue)
      Changes the current color for stroking paths (device dependent colors!).
      void setShadingFill​(PdfShadingPattern shading)
      Sets the shading fill pattern.
      void setShadingStroke​(PdfShadingPattern shading)
      Sets the shading stroke pattern
      void setTextMatrix​(float x, float y)
      Changes the text matrix.
      void setTextMatrix​(float a, float b, float c, float d, float x, float y)
      Changes the text matrix.
      void setTextRenderingMode​(int rendering)
      Sets the text rendering parameter.
      void setTextRise​(float rise)
      Sets the text rise parameter.
      void setWordSpacing​(float wordSpace)
      Sets the word spacing parameter.
      void showText​(PdfTextArray text)
      Show an array of text.
      void showText​(java.lang.String text)
      Shows the text.
      private void showText2​(java.lang.String text)
      A helper to insert into the content stream the text converted to bytes according to the font's encoding.
      void showTextAligned​(int alignment, java.lang.String text, float x, float y, float rotation)
      Shows text right, left or center aligned with rotation.
      void showTextAlignedKerned​(int alignement, java.lang.String text, float x, float y, float rotation)
      Shows text kerned right, left or center aligned with rotation.
      void showTextKerned​(java.lang.String text)
      Shows the text kerned.
      (package private) int size()
      Gets the size of this content.
      void stroke()
      Strokes the path.
      byte[] toPdf​(PdfWriter writer)
      Returns the PDF representation of this PdfContentByte-object.
      java.lang.String toString()
      Returns the String representation of this PdfContentByte-object.
      void transform​(java.awt.geom.AffineTransform af)
      Concatenates a transformation to the current transformation matrix.
      void variableRectangle​(Rectangle rect)
      Adds a variable width border to the current path.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ALIGN_CENTER

        public static final int ALIGN_CENTER
        The alignement is center
        See Also:
        Constant Field Values
      • ALIGN_RIGHT

        public static final int ALIGN_RIGHT
        The alignement is right
        See Also:
        Constant Field Values
      • LINE_CAP_BUTT

        public static final int LINE_CAP_BUTT
        A possible line cap value
        See Also:
        Constant Field Values
      • LINE_CAP_ROUND

        public static final int LINE_CAP_ROUND
        A possible line cap value
        See Also:
        Constant Field Values
      • LINE_CAP_PROJECTING_SQUARE

        public static final int LINE_CAP_PROJECTING_SQUARE
        A possible line cap value
        See Also:
        Constant Field Values
      • LINE_JOIN_MITER

        public static final int LINE_JOIN_MITER
        A possible line join value
        See Also:
        Constant Field Values
      • LINE_JOIN_ROUND

        public static final int LINE_JOIN_ROUND
        A possible line join value
        See Also:
        Constant Field Values
      • LINE_JOIN_BEVEL

        public static final int LINE_JOIN_BEVEL
        A possible line join value
        See Also:
        Constant Field Values
      • TEXT_RENDER_MODE_FILL

        public static final int TEXT_RENDER_MODE_FILL
        A possible text rendering value
        See Also:
        Constant Field Values
      • TEXT_RENDER_MODE_STROKE

        public static final int TEXT_RENDER_MODE_STROKE
        A possible text rendering value
        See Also:
        Constant Field Values
      • TEXT_RENDER_MODE_FILL_STROKE

        public static final int TEXT_RENDER_MODE_FILL_STROKE
        A possible text rendering value
        See Also:
        Constant Field Values
      • TEXT_RENDER_MODE_INVISIBLE

        public static final int TEXT_RENDER_MODE_INVISIBLE
        A possible text rendering value
        See Also:
        Constant Field Values
      • TEXT_RENDER_MODE_FILL_CLIP

        public static final int TEXT_RENDER_MODE_FILL_CLIP
        A possible text rendering value
        See Also:
        Constant Field Values
      • TEXT_RENDER_MODE_STROKE_CLIP

        public static final int TEXT_RENDER_MODE_STROKE_CLIP
        A possible text rendering value
        See Also:
        Constant Field Values
      • TEXT_RENDER_MODE_FILL_STROKE_CLIP

        public static final int TEXT_RENDER_MODE_FILL_STROKE_CLIP
        A possible text rendering value
        See Also:
        Constant Field Values
      • TEXT_RENDER_MODE_CLIP

        public static final int TEXT_RENDER_MODE_CLIP
        A possible text rendering value
        See Also:
        Constant Field Values
      • content

        protected ByteBuffer content
        This is the actual content
      • writer

        protected PdfWriter writer
        This is the writer
      • pdf

        protected PdfDocument pdf
        This is the PdfDocument
      • stateList

        protected java.util.ArrayList stateList
        The list were we save/restore the state
      • layerDepth

        protected java.util.ArrayList layerDepth
        The list were we save/restore the layer depth
      • separator

        protected int separator
        The separator between commands.
      • abrev

        private static java.util.HashMap abrev
    • Constructor Detail

      • PdfContentByte

        public PdfContentByte​(PdfWriter wr)
        Constructs a new PdfContentByte-object.
        Parameters:
        wr - the writer associated to this content
    • Method Detail

      • toString

        public java.lang.String toString()
        Returns the String representation of this PdfContentByte-object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String
      • getInternalBuffer

        public ByteBuffer getInternalBuffer()
        Gets the internal buffer.
        Returns:
        the internal buffer
      • toPdf

        public byte[] toPdf​(PdfWriter writer)
        Returns the PDF representation of this PdfContentByte-object.
        Parameters:
        writer - the PdfWriter
        Returns:
        a byte array with the representation
      • add

        public void add​(PdfContentByte other)
        Adds the content of another PdfContent-object to this object.
        Parameters:
        other - another PdfByteContent-object
      • getXTLM

        public float getXTLM()
        Gets the x position of the text line matrix.
        Returns:
        the x position of the text line matrix
      • getYTLM

        public float getYTLM()
        Gets the y position of the text line matrix.
        Returns:
        the y position of the text line matrix
      • getLeading

        public float getLeading()
        Gets the current text leading.
        Returns:
        the current text leading
      • setFlatness

        public void setFlatness​(float flatness)
        Changes the Flatness.

        Flatness sets the maximum permitted distance in device pixels between the mathematically correct path and an approximation constructed from straight line segments.

        Parameters:
        flatness - a value
      • setLineCap

        public void setLineCap​(int style)
        Changes the Line cap style.

        The line cap style specifies the shape to be used at the end of open subpaths when they are stroked.
        Allowed values are LINE_CAP_BUTT, LINE_CAP_ROUND and LINE_CAP_PROJECTING_SQUARE.

        Parameters:
        style - a value
      • setLineDash

        public void setLineDash​(float phase)
        Changes the value of the line dash pattern.

        The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.

        Parameters:
        phase - the value of the phase
      • setLineDash

        public void setLineDash​(float unitsOn,
                                float phase)
        Changes the value of the line dash pattern.

        The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.

        Parameters:
        phase - the value of the phase
        unitsOn - the number of units that must be 'on' (equals the number of units that must be 'off').
      • setLineDash

        public void setLineDash​(float unitsOn,
                                float unitsOff,
                                float phase)
        Changes the value of the line dash pattern.

        The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.

        Parameters:
        phase - the value of the phase
        unitsOn - the number of units that must be 'on'
        unitsOff - the number of units that must be 'off'
      • setLineDash

        public final void setLineDash​(float[] array,
                                      float phase)
        Changes the value of the line dash pattern.

        The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.

        Parameters:
        array - length of the alternating dashes and gaps
        phase - the value of the phase
      • setLineJoin

        public void setLineJoin​(int style)
        Changes the Line join style.

        The line join style specifies the shape to be used at the corners of paths that are stroked.
        Allowed values are LINE_JOIN_MITER (Miter joins), LINE_JOIN_ROUND (Round joins) and LINE_JOIN_BEVEL (Bevel joins).

        Parameters:
        style - a value
      • setLineWidth

        public void setLineWidth​(float w)
        Changes the line width.

        The line width specifies the thickness of the line used to stroke a path and is measured in used space units.

        Parameters:
        w - a width
      • setMiterLimit

        public void setMiterLimit​(float miterLimit)
        Changes the Miter limit.

        When two line segments meet at a sharp angle and mitered joins have been specified as the line join style, it is possible for the miter to extend far beyond the thickness of the line stroking path. The miter limit imposes a maximum on the ratio of the miter length to the line witdh. When the limit is exceeded, the join is converted from a miter to a bevel.

        Parameters:
        miterLimit - a miter limit
      • clip

        public void clip()
        Modify the current clipping path by intersecting it with the current path, using the nonzero winding number rule to determine which regions lie inside the clipping path.
      • eoClip

        public void eoClip()
        Modify the current clipping path by intersecting it with the current path, using the even-odd rule to determine which regions lie inside the clipping path.
      • setGrayFill

        public void setGrayFill​(float gray)
        Changes the currentgray tint for filling paths (device dependent colors!).

        Sets the color space to DeviceGray (or the DefaultGray color space), and sets the gray tint to use for filling paths.

        Parameters:
        gray - a value between 0 (black) and 1 (white)
      • resetGrayFill

        public void resetGrayFill()
        Changes the current gray tint for filling paths to black.
      • setGrayStroke

        public void setGrayStroke​(float gray)
        Changes the currentgray tint for stroking paths (device dependent colors!).

        Sets the color space to DeviceGray (or the DefaultGray color space), and sets the gray tint to use for stroking paths.

        Parameters:
        gray - a value between 0 (black) and 1 (white)
      • resetGrayStroke

        public void resetGrayStroke()
        Changes the current gray tint for stroking paths to black.
      • HelperRGB

        private void HelperRGB​(float red,
                               float green,
                               float blue)
        Helper to validate and write the RGB color components
        Parameters:
        red - the intensity of red. A value between 0 and 1
        green - the intensity of green. A value between 0 and 1
        blue - the intensity of blue. A value between 0 and 1
      • setRGBColorFillF

        public void setRGBColorFillF​(float red,
                                     float green,
                                     float blue)
        Changes the current color for filling paths (device dependent colors!).

        Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for filling paths.

        Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity).

        Parameters:
        red - the intensity of red. A value between 0 and 1
        green - the intensity of green. A value between 0 and 1
        blue - the intensity of blue. A value between 0 and 1
      • resetRGBColorFill

        public void resetRGBColorFill()
        Changes the current color for filling paths to black.
      • setRGBColorStrokeF

        public void setRGBColorStrokeF​(float red,
                                       float green,
                                       float blue)
        Changes the current color for stroking paths (device dependent colors!).

        Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for stroking paths.

        Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity).

        Parameters:
        red - the intensity of red. A value between 0 and 1
        green - the intensity of green. A value between 0 and 1
        blue - the intensity of blue. A value between 0 and 1
      • resetRGBColorStroke

        public void resetRGBColorStroke()
        Changes the current color for stroking paths to black.
      • HelperCMYK

        private void HelperCMYK​(float cyan,
                                float magenta,
                                float yellow,
                                float black)
        Helper to validate and write the CMYK color components.
        Parameters:
        cyan - the intensity of cyan. A value between 0 and 1
        magenta - the intensity of magenta. A value between 0 and 1
        yellow - the intensity of yellow. A value between 0 and 1
        black - the intensity of black. A value between 0 and 1
      • setCMYKColorFillF

        public void setCMYKColorFillF​(float cyan,
                                      float magenta,
                                      float yellow,
                                      float black)
        Changes the current color for filling paths (device dependent colors!).

        Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for filling paths.

        Following the PDF manual, each operand must be a number between 0 (no ink) and 1 (maximum ink).

        Parameters:
        cyan - the intensity of cyan. A value between 0 and 1
        magenta - the intensity of magenta. A value between 0 and 1
        yellow - the intensity of yellow. A value between 0 and 1
        black - the intensity of black. A value between 0 and 1
      • resetCMYKColorFill

        public void resetCMYKColorFill()
        Changes the current color for filling paths to black.
      • setCMYKColorStrokeF

        public void setCMYKColorStrokeF​(float cyan,
                                        float magenta,
                                        float yellow,
                                        float black)
        Changes the current color for stroking paths (device dependent colors!).

        Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for stroking paths.

        Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity).

        Parameters:
        cyan - the intensity of cyan. A value between 0 and 1
        magenta - the intensity of magenta. A value between 0 and 1
        yellow - the intensity of yellow. A value between 0 and 1
        black - the intensity of black. A value between 0 and 1
      • resetCMYKColorStroke

        public void resetCMYKColorStroke()
        Changes the current color for stroking paths to black.
      • moveTo

        public void moveTo​(float x,
                           float y)
        Move the current point (x, y), omitting any connecting line segment.
        Parameters:
        x - new x-coordinate
        y - new y-coordinate
      • lineTo

        public void lineTo​(float x,
                           float y)
        Appends a straight line segment from the current point (x, y). The new current point is (x, y).
        Parameters:
        x - new x-coordinate
        y - new y-coordinate
      • curveTo

        public void curveTo​(float x1,
                            float y1,
                            float x2,
                            float y2,
                            float x3,
                            float y3)
        Appends a Bêzier curve to the path, starting from the current point.
        Parameters:
        x1 - x-coordinate of the first control point
        y1 - y-coordinate of the first control point
        x2 - x-coordinate of the second control point
        y2 - y-coordinate of the second control point
        x3 - x-coordinaat of the ending point (= new current point)
        y3 - y-coordinaat of the ending point (= new current point)
      • curveTo

        public void curveTo​(float x2,
                            float y2,
                            float x3,
                            float y3)
        Appends a Bêzier curve to the path, starting from the current point.
        Parameters:
        x2 - x-coordinate of the second control point
        y2 - y-coordinate of the second control point
        x3 - x-coordinaat of the ending point (= new current point)
        y3 - y-coordinaat of the ending point (= new current point)
      • curveFromTo

        public void curveFromTo​(float x1,
                                float y1,
                                float x3,
                                float y3)
        Appends a Bêzier curve to the path, starting from the current point.
        Parameters:
        x1 - x-coordinate of the first control point
        y1 - y-coordinate of the first control point
        x3 - x-coordinaat of the ending point (= new current point)
        y3 - y-coordinaat of the ending point (= new current point)
      • circle

        public void circle​(float x,
                           float y,
                           float r)
        Draws a circle. The endpoint will (x+r, y).
        Parameters:
        x - x center of circle
        y - y center of circle
        r - radius of circle
      • rectangle

        public void rectangle​(float x,
                              float y,
                              float w,
                              float h)
        Adds a rectangle to the current path.
        Parameters:
        x - x-coordinate of the starting point
        y - y-coordinate of the starting point
        w - width
        h - height
      • variableRectangle

        public void variableRectangle​(Rectangle rect)
        Adds a variable width border to the current path. Only use if Rectangle.isUseVariableBorders = true.
        Parameters:
        rect - a Rectangle
      • rectangle

        public void rectangle​(Rectangle rectangle)
        Adds a border (complete or partially) to the current path..
        Parameters:
        rectangle - a Rectangle
      • closePath

        public void closePath()
        Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.
      • newPath

        public void newPath()
        Ends the path without filling or stroking it.
      • stroke

        public void stroke()
        Strokes the path.
      • closePathStroke

        public void closePathStroke()
        Closes the path and strokes it.
      • fill

        public void fill()
        Fills the path, using the non-zero winding number rule to determine the region to fill.
      • eoFill

        public void eoFill()
        Fills the path, using the even-odd rule to determine the region to fill.
      • fillStroke

        public void fillStroke()
        Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.
      • closePathFillStroke

        public void closePathFillStroke()
        Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it.
      • eoFillStroke

        public void eoFillStroke()
        Fills the path, using the even-odd rule to determine the region to fill and strokes it.
      • closePathEoFillStroke

        public void closePathEoFillStroke()
        Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it.
      • reset

        public void reset()
        Makes this PdfContentByte empty.
      • beginText

        public void beginText()
        Starts the writing of text.
      • endText

        public void endText()
        Ends the writing of text and makes the current font invalid.
      • saveState

        public void saveState()
        Saves the graphic state. saveState and restoreState must be balanced.
      • restoreState

        public void restoreState()
        Restores the graphic state. saveState and restoreState must be balanced.
      • setCharacterSpacing

        public void setCharacterSpacing​(float charSpace)
        Sets the character spacing parameter.
        Parameters:
        charSpace - a parameter
      • setWordSpacing

        public void setWordSpacing​(float wordSpace)
        Sets the word spacing parameter.
        Parameters:
        wordSpace - a parameter
      • setHorizontalScaling

        public void setHorizontalScaling​(float scale)
        Sets the horizontal scaling parameter.
        Parameters:
        scale - a parameter
      • setLeading

        public void setLeading​(float leading)
        Sets the text leading parameter.

        The leading parameter is measured in text space units. It specifies the vertical distance between the baselines of adjacent lines of text.

        Parameters:
        leading - the new leading
      • setFontAndSize

        public void setFontAndSize​(BaseFont bf,
                                   float size)
        Set the font and the size for the subsequent text writing.
        Parameters:
        bf - the font
        size - the font size in points
      • setTextRenderingMode

        public void setTextRenderingMode​(int rendering)
        Sets the text rendering parameter.
        Parameters:
        rendering - a parameter
      • setTextRise

        public void setTextRise​(float rise)
        Sets the text rise parameter.

        This allows to write text in subscript or superscript mode.

        Parameters:
        rise - a parameter
      • showText2

        private void showText2​(java.lang.String text)
        A helper to insert into the content stream the text converted to bytes according to the font's encoding.
        Parameters:
        text - the text to write
      • showText

        public void showText​(java.lang.String text)
        Shows the text.
        Parameters:
        text - the text to write
      • getKernArray

        public static PdfTextArray getKernArray​(java.lang.String text,
                                                BaseFont font)
        Constructs a kern array for a text in a certain font
        Parameters:
        text - the text
        font - the font
        Returns:
        a PdfTextArray
      • showTextKerned

        public void showTextKerned​(java.lang.String text)
        Shows the text kerned.
        Parameters:
        text - the text to write
      • newlineShowText

        public void newlineShowText​(java.lang.String text)
        Moves to the next line and shows text.
        Parameters:
        text - the text to write
      • newlineShowText

        public void newlineShowText​(float wordSpacing,
                                    float charSpacing,
                                    java.lang.String text)
        Moves to the next line and shows text string, using the given values of the character and word spacing parameters.
        Parameters:
        wordSpacing - a parameter
        charSpacing - a parameter
        text - the text to write
      • setTextMatrix

        public void setTextMatrix​(float a,
                                  float b,
                                  float c,
                                  float d,
                                  float x,
                                  float y)
        Changes the text matrix.

        Remark: this operation also initializes the current point position.

        Parameters:
        a - operand 1,1 in the matrix
        b - operand 1,2 in the matrix
        c - operand 2,1 in the matrix
        d - operand 2,2 in the matrix
        x - operand 3,1 in the matrix
        y - operand 3,2 in the matrix
      • setTextMatrix

        public void setTextMatrix​(float x,
                                  float y)
        Changes the text matrix. The first four parameters are {1,0,0,1}.

        Remark: this operation also initializes the current point position.

        Parameters:
        x - operand 3,1 in the matrix
        y - operand 3,2 in the matrix
      • moveText

        public void moveText​(float x,
                             float y)
        Moves to the start of the next line, offset from the start of the current line.
        Parameters:
        x - x-coordinate of the new current point
        y - y-coordinate of the new current point
      • moveTextWithLeading

        public void moveTextWithLeading​(float x,
                                        float y)
        Moves to the start of the next line, offset from the start of the current line.

        As a side effect, this sets the leading parameter in the text state.

        Parameters:
        x - offset of the new current point
        y - y-coordinate of the new current point
      • newlineText

        public void newlineText()
        Moves to the start of the next line.
      • size

        int size()
        Gets the size of this content.
        Returns:
        the size of the content
      • escapeString

        static byte[] escapeString​(byte[] b)
        Escapes a byte array according to the PDF conventions.
        Parameters:
        b - the byte array to escape
        Returns:
        an escaped byte array
      • escapeString

        static void escapeString​(byte[] b,
                                 ByteBuffer content)
        Escapes a byte array according to the PDF conventions.
        Parameters:
        b - the byte array to escape
        content - the content
      • addOutline

        public void addOutline​(PdfOutline outline)
        Deprecated.
        not needed anymore. The outlines are extracted from the root outline
        Adds an outline to the document.
        Parameters:
        outline - the outline
      • addOutline

        public void addOutline​(PdfOutline outline,
                               java.lang.String name)
        Adds a named outline to the document.
        Parameters:
        outline - the outline
        name - the name for the local destination
      • getRootOutline

        public PdfOutline getRootOutline()
        Gets the root outline.
        Returns:
        the root outline
      • showTextAligned

        public void showTextAligned​(int alignment,
                                    java.lang.String text,
                                    float x,
                                    float y,
                                    float rotation)
        Shows text right, left or center aligned with rotation.
        Parameters:
        alignment - the alignment can be ALIGN_CENTER, ALIGN_RIGHT or ALIGN_LEFT
        text - the text to show
        x - the x pivot position
        y - the y pivot position
        rotation - the rotation to be applied in degrees counterclockwise
      • showTextAlignedKerned

        public void showTextAlignedKerned​(int alignement,
                                          java.lang.String text,
                                          float x,
                                          float y,
                                          float rotation)
        Shows text kerned right, left or center aligned with rotation.
        Parameters:
        alignement - the alignment can be ALIGN_CENTER, ALIGN_RIGHT or ALIGN_LEFT
        text - the text to show
        x - the x pivot position
        y - the y pivot position
        rotation - the rotation to be applied in degrees counterclockwise
      • concatCTM

        public void concatCTM​(float a,
                              float b,
                              float c,
                              float d,
                              float e,
                              float f)
        Concatenate a matrix to the current transformation matrix.
        Parameters:
        a - an element of the transformation matrix
        b - an element of the transformation matrix
        c - an element of the transformation matrix
        d - an element of the transformation matrix
        e - an element of the transformation matrix
        f - an element of the transformation matrix
      • bezierArc

        public static java.util.ArrayList bezierArc​(float x1,
                                                    float y1,
                                                    float x2,
                                                    float y2,
                                                    float startAng,
                                                    float extent)
        Generates an array of bezier curves to draw an arc.

        (x1, y1) and (x2, y2) are the corners of the enclosing rectangle. Angles, measured in degrees, start with 0 to the right (the positive X axis) and increase counter-clockwise. The arc extends from startAng to startAng+extent. I.e. startAng=0 and extent=180 yields an openside-down semi-circle.

        The resulting coordinates are of the form float[]{x1,y1,x2,y2,x3,y3, x4,y4} such that the curve goes from (x1, y1) to (x4, y4) with (x2, y2) and (x3, y3) as their respective Bezier control points.

        Note: this code was taken from ReportLab (www.reportlab.com), an excelent PDF generator for Python.

        Parameters:
        x1 - a corner of the enclosing rectangle
        y1 - a corner of the enclosing rectangle
        x2 - a corner of the enclosing rectangle
        y2 - a corner of the enclosing rectangle
        startAng - starting angle in degrees
        extent - angle extent in degrees
        Returns:
        a list of float[] with the bezier curves
      • arc

        public void arc​(float x1,
                        float y1,
                        float x2,
                        float y2,
                        float startAng,
                        float extent)
        Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees. Angles start with 0 to the right (+x) and increase counter-clockwise.
        Parameters:
        x1 - a corner of the enclosing rectangle
        y1 - a corner of the enclosing rectangle
        x2 - a corner of the enclosing rectangle
        y2 - a corner of the enclosing rectangle
        startAng - starting angle in degrees
        extent - angle extent in degrees
      • ellipse

        public void ellipse​(float x1,
                            float y1,
                            float x2,
                            float y2)
        Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.
        Parameters:
        x1 - a corner of the enclosing rectangle
        y1 - a corner of the enclosing rectangle
        x2 - a corner of the enclosing rectangle
        y2 - a corner of the enclosing rectangle
      • createPattern

        public PdfPatternPainter createPattern​(float width,
                                               float height,
                                               float xstep,
                                               float ystep)
        Create a new colored tiling pattern.
        Parameters:
        width - the width of the pattern
        height - the height of the pattern
        xstep - the desired horizontal spacing between pattern cells. May be either positive or negative, but not zero.
        ystep - the desired vertical spacing between pattern cells. May be either positive or negative, but not zero.
        Returns:
        the PdfPatternPainter where the pattern will be created
      • createPattern

        public PdfPatternPainter createPattern​(float width,
                                               float height)
        Create a new colored tiling pattern. Variables xstep and ystep are set to the same values of width and height.
        Parameters:
        width - the width of the pattern
        height - the height of the pattern
        Returns:
        the PdfPatternPainter where the pattern will be created
      • createPattern

        public PdfPatternPainter createPattern​(float width,
                                               float height,
                                               float xstep,
                                               float ystep,
                                               java.awt.Color color)
        Create a new uncolored tiling pattern.
        Parameters:
        width - the width of the pattern
        height - the height of the pattern
        xstep - the desired horizontal spacing between pattern cells. May be either positive or negative, but not zero.
        ystep - the desired vertical spacing between pattern cells. May be either positive or negative, but not zero.
        color - the default color. Can be null
        Returns:
        the PdfPatternPainter where the pattern will be created
      • createPattern

        public PdfPatternPainter createPattern​(float width,
                                               float height,
                                               java.awt.Color color)
        Create a new uncolored tiling pattern. Variables xstep and ystep are set to the same values of width and height.
        Parameters:
        width - the width of the pattern
        height - the height of the pattern
        color - the default color. Can be null
        Returns:
        the PdfPatternPainter where the pattern will be created
      • createTemplate

        public PdfTemplate createTemplate​(float width,
                                          float height)
        Creates a new template.

        Creates a new template that is nothing more than a form XObject. This template can be included in this PdfContentByte or in another template. Templates are only written to the output when the document is closed permitting things like showing text in the first page that is only defined in the last page.

        Parameters:
        width - the bounding box width
        height - the bounding box height
        Returns:
        the templated created
      • createTemplate

        PdfTemplate createTemplate​(float width,
                                   float height,
                                   PdfName forcedName)
      • createAppearance

        public PdfAppearance createAppearance​(float width,
                                              float height)
        Creates a new appearance to be used with form fields.
        Parameters:
        width - the bounding box width
        height - the bounding box height
        Returns:
        the appearance created
      • createAppearance

        PdfAppearance createAppearance​(float width,
                                       float height,
                                       PdfName forcedName)
      • addPSXObject

        public void addPSXObject​(PdfPSXObject psobject)
        Adds a PostScript XObject to this content.
        Parameters:
        psobject - the object
      • addTemplate

        public void addTemplate​(PdfTemplate template,
                                float a,
                                float b,
                                float c,
                                float d,
                                float e,
                                float f)
        Adds a template to this content.
        Parameters:
        template - the template
        a - an element of the transformation matrix
        b - an element of the transformation matrix
        c - an element of the transformation matrix
        d - an element of the transformation matrix
        e - an element of the transformation matrix
        f - an element of the transformation matrix
      • addTemplate

        public void addTemplate​(PdfTemplate template,
                                float x,
                                float y)
        Adds a template to this content.
        Parameters:
        template - the template
        x - the x location of this template
        y - the y location of this template
      • setCMYKColorFill

        public void setCMYKColorFill​(int cyan,
                                     int magenta,
                                     int yellow,
                                     int black)
        Changes the current color for filling paths (device dependent colors!).

        Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for filling paths.

        This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).

        Following the PDF manual, each operand must be a number between 0 (no ink) and 1 (maximum ink). This method however accepts only integers between 0x00 and 0xFF.

        Parameters:
        cyan - the intensity of cyan
        magenta - the intensity of magenta
        yellow - the intensity of yellow
        black - the intensity of black
      • setCMYKColorStroke

        public void setCMYKColorStroke​(int cyan,
                                       int magenta,
                                       int yellow,
                                       int black)
        Changes the current color for stroking paths (device dependent colors!).

        Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for stroking paths.

        This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).

        Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.
        Parameters:
        cyan - the intensity of red
        magenta - the intensity of green
        yellow - the intensity of blue
        black - the intensity of black
      • setRGBColorFill

        public void setRGBColorFill​(int red,
                                    int green,
                                    int blue)
        Changes the current color for filling paths (device dependent colors!).

        Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for filling paths.

        This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).

        Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.

        Parameters:
        red - the intensity of red
        green - the intensity of green
        blue - the intensity of blue
      • setRGBColorStroke

        public void setRGBColorStroke​(int red,
                                      int green,
                                      int blue)
        Changes the current color for stroking paths (device dependent colors!).

        Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for stroking paths.

        This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).

        Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.
        Parameters:
        red - the intensity of red
        green - the intensity of green
        blue - the intensity of blue
      • setColorStroke

        public void setColorStroke​(java.awt.Color color)
        Sets the stroke color. color can be an ExtendedColor.
        Parameters:
        color - the color
      • setColorFill

        public void setColorFill​(java.awt.Color color)
        Sets the fill color. color can be an ExtendedColor.
        Parameters:
        color - the color
      • setColorFill

        public void setColorFill​(PdfSpotColor sp,
                                 float tint)
        Sets the fill color to a spot color.
        Parameters:
        sp - the spot color
        tint - the tint for the spot color. 0 is no color and 1 is 100% color
      • setColorStroke

        public void setColorStroke​(PdfSpotColor sp,
                                   float tint)
        Sets the stroke color to a spot color.
        Parameters:
        sp - the spot color
        tint - the tint for the spot color. 0 is no color and 1 is 100% color
      • setPatternFill

        public void setPatternFill​(PdfPatternPainter p)
        Sets the fill color to a pattern. The pattern can be colored or uncolored.
        Parameters:
        p - the pattern
      • outputColorNumbers

        void outputColorNumbers​(java.awt.Color color,
                                float tint)
        Outputs the color values to the content.
        Parameters:
        color - The color
        tint - the tint if it is a spot color, ignored otherwise
      • setPatternFill

        public void setPatternFill​(PdfPatternPainter p,
                                   java.awt.Color color)
        Sets the fill color to an uncolored pattern.
        Parameters:
        p - the pattern
        color - the color of the pattern
      • setPatternFill

        public void setPatternFill​(PdfPatternPainter p,
                                   java.awt.Color color,
                                   float tint)
        Sets the fill color to an uncolored pattern.
        Parameters:
        p - the pattern
        color - the color of the pattern
        tint - the tint if the color is a spot color, ignored otherwise
      • setPatternStroke

        public void setPatternStroke​(PdfPatternPainter p,
                                     java.awt.Color color)
        Sets the stroke color to an uncolored pattern.
        Parameters:
        p - the pattern
        color - the color of the pattern
      • setPatternStroke

        public void setPatternStroke​(PdfPatternPainter p,
                                     java.awt.Color color,
                                     float tint)
        Sets the stroke color to an uncolored pattern.
        Parameters:
        p - the pattern
        color - the color of the pattern
        tint - the tint if the color is a spot color, ignored otherwise
      • setPatternStroke

        public void setPatternStroke​(PdfPatternPainter p)
        Sets the stroke color to a pattern. The pattern can be colored or uncolored.
        Parameters:
        p - the pattern
      • paintShading

        public void paintShading​(PdfShading shading)
        Paints using a shading object.
        Parameters:
        shading - the shading object
      • paintShading

        public void paintShading​(PdfShadingPattern shading)
        Paints using a shading pattern.
        Parameters:
        shading - the shading pattern
      • setShadingFill

        public void setShadingFill​(PdfShadingPattern shading)
        Sets the shading fill pattern.
        Parameters:
        shading - the shading pattern
      • setShadingStroke

        public void setShadingStroke​(PdfShadingPattern shading)
        Sets the shading stroke pattern
        Parameters:
        shading - the shading pattern
      • checkWriter

        protected void checkWriter()
        Check if we have a valid PdfWriter.
      • showText

        public void showText​(PdfTextArray text)
        Show an array of text.
        Parameters:
        text - array of text
      • getPdfWriter

        public PdfWriter getPdfWriter()
        Gets the PdfWriter in use by this object.
        Returns:
        the PdfWriter in use by this object
      • getPdfDocument

        public PdfDocument getPdfDocument()
        Gets the PdfDocument in use by this object.
        Returns:
        the PdfDocument in use by this object
      • localGoto

        public void localGoto​(java.lang.String name,
                              float llx,
                              float lly,
                              float urx,
                              float ury)
        Implements a link to other part of the document. The jump will be made to a local destination with the same name, that must exist.
        Parameters:
        name - the name for this link
        llx - the lower left x corner of the activation area
        lly - the lower left y corner of the activation area
        urx - the upper right x corner of the activation area
        ury - the upper right y corner of the activation area
      • localDestination

        public boolean localDestination​(java.lang.String name,
                                        PdfDestination destination)
        The local destination to where a local goto with the same name will jump.
        Parameters:
        name - the name of this local destination
        destination - the PdfDestination with the jump coordinates
        Returns:
        true if the local destination was added, false if a local destination with the same name already exists
      • getDuplicate

        public PdfContentByte getDuplicate()
        Gets a duplicate of this PdfContentByte. All the members are copied by reference but the buffer stays different.
        Returns:
        a copy of this PdfContentByte
      • remoteGoto

        public void remoteGoto​(java.lang.String filename,
                               java.lang.String name,
                               float llx,
                               float lly,
                               float urx,
                               float ury)
        Implements a link to another document.
        Parameters:
        filename - the filename for the remote document
        name - the name to jump to
        llx - the lower left x corner of the activation area
        lly - the lower left y corner of the activation area
        urx - the upper right x corner of the activation area
        ury - the upper right y corner of the activation area
      • remoteGoto

        public void remoteGoto​(java.lang.String filename,
                               int page,
                               float llx,
                               float lly,
                               float urx,
                               float ury)
        Implements a link to another document.
        Parameters:
        filename - the filename for the remote document
        page - the page to jump to
        llx - the lower left x corner of the activation area
        lly - the lower left y corner of the activation area
        urx - the upper right x corner of the activation area
        ury - the upper right y corner of the activation area
      • roundRectangle

        public void roundRectangle​(float x,
                                   float y,
                                   float w,
                                   float h,
                                   float r)
        Adds a round rectangle to the current path.
        Parameters:
        x - x-coordinate of the starting point
        y - y-coordinate of the starting point
        w - width
        h - height
        r - radius of the arc corner
      • setAction

        public void setAction​(PdfAction action,
                              float llx,
                              float lly,
                              float urx,
                              float ury)
        Implements an action in an area.
        Parameters:
        action - the PdfAction
        llx - the lower left x corner of the activation area
        lly - the lower left y corner of the activation area
        urx - the upper right x corner of the activation area
        ury - the upper right y corner of the activation area
      • setLiteral

        public void setLiteral​(java.lang.String s)
        Outputs a String directly to the content.
        Parameters:
        s - the String
      • setLiteral

        public void setLiteral​(char c)
        Outputs a char directly to the content.
        Parameters:
        c - the char
      • setLiteral

        public void setLiteral​(float n)
        Outputs a float directly to the content.
        Parameters:
        n - the float
      • checkNoPattern

        void checkNoPattern​(PdfTemplate t)
        Throws an error if it is a pattern.
        Parameters:
        t - the object to check
      • drawRadioField

        public void drawRadioField​(float llx,
                                   float lly,
                                   float urx,
                                   float ury,
                                   boolean on)
        Draws a TextField.
        Parameters:
        llx -
        lly -
        urx -
        ury -
        on -
      • drawTextField

        public void drawTextField​(float llx,
                                  float lly,
                                  float urx,
                                  float ury)
        Draws a TextField.
        Parameters:
        llx -
        lly -
        urx -
        ury -
      • drawButton

        public void drawButton​(float llx,
                               float lly,
                               float urx,
                               float ury,
                               java.lang.String text,
                               BaseFont bf,
                               float size)
        Draws a button.
        Parameters:
        llx -
        lly -
        urx -
        ury -
        text -
        bf -
        size -
      • getPageResources

        PageResources getPageResources()
        Gets a Graphics2D to print on. The graphics are translated to PDF commands.
        Parameters:
        width - the width of the panel
        height - the height of the panel
        fontMapper - the mapping from awt fonts to BaseFont
        convertImagesToJPEG - converts awt images to jpeg before inserting in pdf
        quality - the quality of the jpeg
        printerJob - a printer job
        Returns:
        a Graphics2D
      • setGState

        public void setGState​(PdfGState gstate)
        Sets the graphic state
        Parameters:
        gstate - the graphic state
      • beginLayer

        public void beginLayer​(PdfOCG layer)
        Begins a graphic block whose visibility is controled by the layer. Blocks can be nested. Each block must be terminated by an endLayer().

        Note that nested layers with PdfLayer.addChild(PdfLayer) only require a single call to this method and a single call to endLayer(); all the nesting control is built in.

        Parameters:
        layer - the layer
      • beginLayer2

        private void beginLayer2​(PdfOCG layer)
      • endLayer

        public void endLayer()
        Ends a layer controled graphic block. It will end the most recent open block.
      • transform

        public void transform​(java.awt.geom.AffineTransform af)
        Concatenates a transformation to the current transformation matrix.
        Parameters:
        af - the transformation
      • setDefaultColorspace

        public void setDefaultColorspace​(PdfName name,
                                         PdfObject obj)
        Sets the default colorspace.
        Parameters:
        name - the name of the colorspace. It can be PdfName.DEFAULTGRAY, PdfName.DEFAULTRGB or PdfName.DEFAULTCMYK
        obj - the colorspace. A null or PdfNull removes any colorspace with the same name
      • beginMarkedContentSequence

        public void beginMarkedContentSequence​(PdfStructureElement struc)
        Begins a marked content sequence. This sequence will be tagged with the structure struc. The same structure can be used several times to connect text that belongs to the same logical segment but is in a different location, like the same paragraph crossing to another page, for example.
        Parameters:
        struc - the tagging structure
      • endMarkedContentSequence

        public void endMarkedContentSequence()
        Ends a marked content sequence
      • beginMarkedContentSequence

        public void beginMarkedContentSequence​(PdfName tag,
                                               PdfDictionary property,
                                               boolean inline)
        Begins a marked content sequence. If property is null the mark will be of the type BMC otherwise it will be BDC.
        Parameters:
        tag - the tag
        property - the property
        inline - true to include the property in the content or false to include the property in the resource dictionary with the possibility of reusing
      • beginMarkedContentSequence

        public void beginMarkedContentSequence​(PdfName tag)
        This is just a shorthand to beginMarkedContentSequence(tag, null, false).
        Parameters:
        tag - the tag