Class PDPageContentStreamExt

java.lang.Object
com.helger.pdflayout.pdfbox.PDPageContentStreamExt
All Implemented Interfaces:
Closeable, AutoCloseable

@CodingStyleguideUnaware @NotThreadSafe public final class PDPageContentStreamExt extends Object implements Closeable
Provides the ability to write to a page content stream.
Extensions/changes for this project:
  • Speed up in text drawing
  • Removed all deprecated methods
  • Allowing to prepend content
Author:
Ben Litchfield
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected OutputStream
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument doc, org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream appearance)
    Create a new appearance stream.
    PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument aDoc, org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream appearance, OutputStream outputStream)
    Create a new appearance stream.
    PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.PDPage sourcePage)
    Create a new PDPage content stream.
    PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.PDPage sourcePage, org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode appendContent, boolean compress)
    Create a new PDPage content stream.
    PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument aDoc, org.apache.pdfbox.pdmodel.PDPage sourcePage, org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode appendContent, boolean compress, boolean resetContext)
    Create a new PDPage content stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addRect(float x, float y, float width, float height)
    Add a rectangle to the current path.
    void
    beginMarkedContent(org.apache.pdfbox.cos.COSName tag)
    Begin a marked content sequence.
    void
    beginMarkedContent(org.apache.pdfbox.cos.COSName tag, org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList propertyList)
    Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.
    void
    Begin some text operations.
    void
    Intersects the current clipping path with the current path, using the nonzero rule.
    void
    Intersects the current clipping path with the current path, using the even-odd rule.
    void
    Close the content stream.
    void
    Close and stroke the path.
    void
    Closes the current subpath.
    void
    curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
    Append a cubic Bézier curve to the current path.
    void
    curveTo1(float x1, float y1, float x3, float y3)
    Append a cubic Bézier curve to the current path.
    void
    curveTo2(float x2, float y2, float x3, float y3)
    Append a cubic Bézier curve to the current path.
    void
    drawForm(org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject form)
    Draws the given Form XObject at the current location.
    void
    drawImage(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject image, float x, float y)
    Draw an image at the x,y coordinates, with the default size of the image.
    void
    drawImage(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject image, float x, float y, float width, float height)
    Draw an image at the x,y coordinates, with the given size.
    void
    drawImage(org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage inlineImage, float x, float y)
    Draw an inline image at the x,y coordinates, with the default size of the image.
    void
    drawImage(org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage inlineImage, float x, float y, float width, float height)
    Draw an inline image at the x,y coordinates and a certain width and height.
    void
    End a marked content sequence.
    void
    End some text operations.
    void
    Fills the path using the nonzero winding rule.
    void
    Fills the path using the even-odd winding rule.
    void
    lineTo(float x, float y)
    Draw a line from the current position to the given coordinates.
    void
    moveTo(float x, float y)
    Move the current position to the given coordinates.
    void
    Move to the start of the next line of text.
    void
    newLineAtOffset(float tx, float ty)
    The Td operator.
    void
    Q operator.
    void
    q operator.
    void
    setCharacterSpacing(float spacing)
    Set the character spacing.
    void
    setFont(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize)
    Set the font and font size to draw text with.
    void
    setGraphicsStateParameters(org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState state)
    Set an extended graphics state.
    void
    setLeading(double leading)
    Sets the text leading.
    void
    setLineCapStyle(int lineCapStyle)
    Set the line cap style.
    void
    setLineDashPattern(float[] pattern, float phase)
    Set the line dash pattern.
    void
    setLineJoinStyle(int lineJoinStyle)
    Set the line join style.
    void
    setLineWidth(float lineWidth)
    Set line width to the given value.
    void
    Set the non-stroking color in the DeviceGray color space.
    void
    setNonStrokingColor(double c, double m, double y, double k)
    Set the non-stroking color in the DeviceRGB color space.
    void
    Set the non-stroking color in the DeviceGray color space.
    void
    setNonStrokingColor(int r, int g, int b)
    Set the non-stroking color in the DeviceRGB color space.
    void
    setNonStrokingColor(int c, int m, int y, int k)
    Set the non-stroking color in the DeviceCMYK color space.
    void
    Set the non-stroking color using an AWT color.
    void
    setNonStrokingColor(org.apache.pdfbox.pdmodel.graphics.color.PDColor color)
    Sets the non-stroking color and, if necessary, the non-stroking color space.
    void
    setStrokingColor(double g)
    Set the stroking color in the DeviceGray color space.
    void
    setStrokingColor(float c, float m, float y, float k)
    Set the stroking color in the DeviceCMYK color space.
    void
    setStrokingColor(int r, int g, int b)
    Set the stroking color in the DeviceRGB color space.
    void
    Set the stroking color using an AWT color.
    void
    setStrokingColor(org.apache.pdfbox.pdmodel.graphics.color.PDColor color)
    Sets the stroking color and, if necessary, the stroking color space.
    void
    setTextMatrix(org.apache.pdfbox.util.Matrix matrix)
    The Tm operator.
    void
    shadingFill(org.apache.pdfbox.pdmodel.graphics.shading.PDShading shading)
    Fills the clipping area with the given shading.
    void
    Shows the given text at the location specified by the current text matrix.
    void
    Stroke the path.
    void
    transform(org.apache.pdfbox.util.Matrix matrix)
    The cm operator.
    protected void
    write(byte... text)
    Writes a string to the content stream as ASCII.
    protected void
    writeBytes(byte[] data)
    Writes binary data to the content stream.
    protected void
    Writes a string to the content stream as ASCII.
    protected void
    writeOperand(float real)
    Writes a real real to the content stream.
    protected void
    writeOperand(int integer)
    Writes a real number to the content stream.
    protected void
    writeOperand(org.apache.pdfbox.cos.COSName name)
    Writes a COSName to the content stream.
    protected final void
    writeOperator(byte... text)
    Writes a string to the content stream as ASCII.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • PDPageContentStreamExt

      public PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.PDPage sourcePage) throws IOException
      Create a new PDPage content stream.
      Parameters:
      document - The document the page is part of.
      sourcePage - The page to write the contents to.
      Throws:
      IOException - If there is an error writing to the page contents.
    • PDPageContentStreamExt

      public PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.PDPage sourcePage, org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode appendContent, boolean compress) throws IOException
      Create a new PDPage content stream.
      Parameters:
      document - The document the page is part of.
      sourcePage - The page to write the contents to.
      appendContent - Indicates whether content will be overwritten. If false all previous content is deleted.
      compress - Tell if the content stream should compress the page contents.
      Throws:
      IOException - If there is an error writing to the page contents.
    • PDPageContentStreamExt

      public PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument aDoc, org.apache.pdfbox.pdmodel.PDPage sourcePage, org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode appendContent, boolean compress, boolean resetContext) throws IOException
      Create a new PDPage content stream.
      Parameters:
      aDoc - The document the page is part of.
      sourcePage - The page to write the contents to.
      appendContent - Indicates whether content will be overwritten. If false all previous content is deleted.
      compress - Tell if the content stream should compress the page contents.
      resetContext - Tell if the graphic context should be reseted.
      Throws:
      IOException - If there is an error writing to the page contents.
    • PDPageContentStreamExt

      public PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument doc, org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream appearance) throws IOException
      Create a new appearance stream. Note that this is not actually a "page" content stream.
      Parameters:
      doc - The document the page is part of.
      appearance - The appearance stream to write to.
      Throws:
      IOException - If there is an error writing to the page contents.
    • PDPageContentStreamExt

      public PDPageContentStreamExt(org.apache.pdfbox.pdmodel.PDDocument aDoc, org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream appearance, OutputStream outputStream)
      Create a new appearance stream. Note that this is not actually a "page" content stream.
      Parameters:
      aDoc - The document the appearance is part of.
      appearance - The appearance stream to add to.
      outputStream - The appearances output stream to write to.
  • Method Details

    • beginText

      public void beginText() throws IOException
      Begin some text operations.
      Throws:
      IOException - If there is an error writing to the stream or if you attempt to nest beginText calls.
      IllegalStateException - If the method was not allowed to be called at this time.
    • endText

      public void endText() throws IOException
      End some text operations.
      Throws:
      IOException - If there is an error writing to the stream or if you attempt to nest endText calls.
      IllegalStateException - If the method was not allowed to be called at this time.
    • setFont

      public void setFont(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize) throws IOException
      Set the font and font size to draw text with.
      Parameters:
      font - The font to use.
      fontSize - The font size to draw the text.
      Throws:
      IOException - If there is an error writing the font information.
    • setCharacterSpacing

      public void setCharacterSpacing(float spacing) throws IOException
      Set the character spacing. The value shall be added to the horizontal or vertical component of the glyph's displacement, depending on the writing mode.
      Parameters:
      spacing - character spacing
      Throws:
      IOException - If the content stream could not be written.
    • showText

      public void showText(String text) throws IOException
      Shows the given text at the location specified by the current text matrix.
      Parameters:
      text - The Unicode text to show.
      Throws:
      IOException - If an io exception occurs.
    • setLeading

      public void setLeading(double leading) throws IOException
      Sets the text leading.
      Parameters:
      leading - The leading in unscaled text units.
      Throws:
      IOException - If there is an error writing to the stream.
    • newLine

      public void newLine() throws IOException
      Move to the start of the next line of text. Requires the leading (see setLeading(double)) to have been set.
      Throws:
      IOException - If there is an error writing to the stream.
    • newLineAtOffset

      public void newLineAtOffset(float tx, float ty) throws IOException
      The Td operator. Move to the start of the next line, offset from the start of the current line by (tx, ty).
      Parameters:
      tx - The x translation.
      ty - The y translation.
      Throws:
      IOException - If there is an error writing to the stream.
      IllegalStateException - If the method was not allowed to be called at this time.
    • setTextMatrix

      public void setTextMatrix(org.apache.pdfbox.util.Matrix matrix) throws IOException
      The Tm operator. Sets the text matrix to the given values. A current text matrix will be replaced with the new one.
      Parameters:
      matrix - the transformation matrix
      Throws:
      IOException - If there is an error writing to the stream.
      IllegalStateException - If the method was not allowed to be called at this time.
    • drawImage

      public void drawImage(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject image, float x, float y) throws IOException
      Draw an image at the x,y coordinates, with the default size of the image.
      Parameters:
      image - The image to draw.
      x - The x-coordinate to draw the image.
      y - The y-coordinate to draw the image.
      Throws:
      IOException - If there is an error writing to the stream.
    • drawImage

      public void drawImage(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject image, float x, float y, float width, float height) throws IOException
      Draw an image at the x,y coordinates, with the given size.
      Parameters:
      image - The image to draw.
      x - The x-coordinate to draw the image.
      y - The y-coordinate to draw the image.
      width - The width to draw the image.
      height - The height to draw the image.
      Throws:
      IOException - If there is an error writing to the stream.
      IllegalStateException - If the method was called within a text block.
    • drawImage

      public void drawImage(org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage inlineImage, float x, float y) throws IOException
      Draw an inline image at the x,y coordinates, with the default size of the image.
      Parameters:
      inlineImage - The inline image to draw.
      x - The x-coordinate to draw the inline image.
      y - The y-coordinate to draw the inline image.
      Throws:
      IOException - If there is an error writing to the stream.
    • drawImage

      public void drawImage(org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage inlineImage, float x, float y, float width, float height) throws IOException
      Draw an inline image at the x,y coordinates and a certain width and height.
      Parameters:
      inlineImage - The inline image to draw.
      x - The x-coordinate to draw the inline image.
      y - The y-coordinate to draw the inline image.
      width - The width of the inline image to draw.
      height - The height of the inline image to draw.
      Throws:
      IOException - If there is an error writing to the stream.
      IllegalStateException - If the method was called within a text block.
    • drawForm

      public void drawForm(org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject form) throws IOException
      Draws the given Form XObject at the current location.
      Parameters:
      form - Form XObject
      Throws:
      IOException - if the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • transform

      public void transform(org.apache.pdfbox.util.Matrix matrix) throws IOException
      The cm operator. Concatenates the given matrix with the CTM.
      Parameters:
      matrix - the transformation matrix
      Throws:
      IOException - If there is an error writing to the stream.
    • saveGraphicsState

      public void saveGraphicsState() throws IOException
      q operator. Saves the current graphics state.
      Throws:
      IOException - If an error occurs while writing to the stream.
    • restoreGraphicsState

      public void restoreGraphicsState() throws IOException
      Q operator. Restores the current graphics state.
      Throws:
      IOException - If an error occurs while writing to the stream.
    • setStrokingColor

      public void setStrokingColor(@Nonnull org.apache.pdfbox.pdmodel.graphics.color.PDColor color) throws IOException
      Sets the stroking color and, if necessary, the stroking color space.
      Parameters:
      color - Color in a specific color space.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
    • setStrokingColor

      public void setStrokingColor(@Nonnull PLColor aColor) throws IOException
      Set the stroking color using an AWT color. Conversion uses the default sRGB color space.
      Parameters:
      aColor - The color to set.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      Since:
      7.2.0
    • setStrokingColor

      public void setStrokingColor(int r, int g, int b) throws IOException
      Set the stroking color in the DeviceRGB color space. Range is 0..255.
      Parameters:
      r - The red value
      g - The green value.
      b - The blue value.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      IllegalArgumentException - If the parameters are invalid.
    • setStrokingColor

      public void setStrokingColor(float c, float m, float y, float k) throws IOException
      Set the stroking color in the DeviceCMYK color space. Range is 0..1
      Parameters:
      c - The cyan value.
      m - The magenta value.
      y - The yellow value.
      k - The black value.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      IllegalArgumentException - If the parameters are invalid.
    • setStrokingColor

      public void setStrokingColor(double g) throws IOException
      Set the stroking color in the DeviceGray color space. Range is 0..1.
      Parameters:
      g - The gray value.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      IllegalArgumentException - If the parameter is invalid.
    • setNonStrokingColor

      public void setNonStrokingColor(@Nonnull org.apache.pdfbox.pdmodel.graphics.color.PDColor color) throws IOException
      Sets the non-stroking color and, if necessary, the non-stroking color space.
      Parameters:
      color - Color in a specific color space.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
    • setNonStrokingColor

      public void setNonStrokingColor(@Nonnull PLColor aColor) throws IOException
      Set the non-stroking color using an AWT color. Conversion uses the default sRGB color space.
      Parameters:
      aColor - The color to set.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      Since:
      7.2.0
    • setNonStrokingColor

      public void setNonStrokingColor(int r, int g, int b) throws IOException
      Set the non-stroking color in the DeviceRGB color space. Range is 0..255.
      Parameters:
      r - The red value.
      g - The green value.
      b - The blue value.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      IllegalArgumentException - If the parameters are invalid.
    • setNonStrokingColor

      public void setNonStrokingColor(int c, int m, int y, int k) throws IOException
      Set the non-stroking color in the DeviceCMYK color space. Range is 0..255.
      Parameters:
      c - The cyan value.
      m - The magenta value.
      y - The yellow value.
      k - The black value.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      IllegalArgumentException - If the parameters are invalid.
    • setNonStrokingColor

      public void setNonStrokingColor(double c, double m, double y, double k) throws IOException
      Set the non-stroking color in the DeviceRGB color space. Range is 0..1.
      Parameters:
      c - The cyan value.
      m - The magenta value.
      y - The yellow value.
      k - The black value.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
    • setNonStrokingColor

      public void setNonStrokingColor(int g) throws IOException
      Set the non-stroking color in the DeviceGray color space. Range is 0..255.
      Parameters:
      g - The gray value.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      IllegalArgumentException - If the parameter is invalid.
    • setNonStrokingColor

      public void setNonStrokingColor(double g) throws IOException
      Set the non-stroking color in the DeviceGray color space. Range is 0..1.
      Parameters:
      g - The gray value.
      Throws:
      IOException - If an IO error occurs while writing to the stream.
      IllegalArgumentException - If the parameter is invalid.
    • addRect

      public void addRect(float x, float y, float width, float height) throws IOException
      Add a rectangle to the current path.
      Parameters:
      x - The lower left x coordinate.
      y - The lower left y coordinate.
      width - The width of the rectangle.
      height - The height of the rectangle.
      Throws:
      IOException - If the content stream could not be written.
      IllegalStateException - If the method was called within a text block.
    • curveTo

      public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) throws IOException
      Append a cubic Bézier curve to the current path. The curve extends from the current point to the point (x3, y3), using (x1, y1) and (x2, y2) as the Bézier control points.
      Parameters:
      x1 - x coordinate of the point 1
      y1 - y coordinate of the point 1
      x2 - x coordinate of the point 2
      y2 - y coordinate of the point 2
      x3 - x coordinate of the point 3
      y3 - y coordinate of the point 3
      Throws:
      IOException - If the content stream could not be written.
      IllegalStateException - If the method was called within a text block.
    • curveTo2

      public void curveTo2(float x2, float y2, float x3, float y3) throws IOException
      Append a cubic Bézier curve to the current path. The curve extends from the current point to the point (x3, y3), using the current point and (x2, y2) as the Bézier control points.
      Parameters:
      x2 - x coordinate of the point 2
      y2 - y coordinate of the point 2
      x3 - x coordinate of the point 3
      y3 - y coordinate of the point 3
      Throws:
      IllegalStateException - If the method was called within a text block.
      IOException - If the content stream could not be written.
    • curveTo1

      public void curveTo1(float x1, float y1, float x3, float y3) throws IOException
      Append a cubic Bézier curve to the current path. The curve extends from the current point to the point (x3, y3), using (x1, y1) and (x3, y3) as the Bézier control points.
      Parameters:
      x1 - x coordinate of the point 1
      y1 - y coordinate of the point 1
      x3 - x coordinate of the point 3
      y3 - y coordinate of the point 3
      Throws:
      IOException - If the content stream could not be written.
      IllegalStateException - If the method was called within a text block.
    • moveTo

      public void moveTo(float x, float y) throws IOException
      Move the current position to the given coordinates.
      Parameters:
      x - The x coordinate.
      y - The y coordinate.
      Throws:
      IOException - If the content stream could not be written.
      IllegalStateException - If the method was called within a text block.
    • lineTo

      public void lineTo(float x, float y) throws IOException
      Draw a line from the current position to the given coordinates.
      Parameters:
      x - The x coordinate.
      y - The y coordinate.
      Throws:
      IOException - If the content stream could not be written.
      IllegalStateException - If the method was called within a text block.
    • stroke

      public void stroke() throws IOException
      Stroke the path.
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • closeAndStroke

      public void closeAndStroke() throws IOException
      Close and stroke the path.
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • fill

      public void fill() throws IOException
      Fills the path using the nonzero winding rule.
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • fillEvenOdd

      public void fillEvenOdd() throws IOException
      Fills the path using the even-odd winding rule.
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • shadingFill

      public void shadingFill(org.apache.pdfbox.pdmodel.graphics.shading.PDShading shading) throws IOException
      Fills the clipping area with the given shading.
      Parameters:
      shading - Shading resource
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • closePath

      public void closePath() throws IOException
      Closes the current subpath.
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • clip

      public void clip() throws IOException
      Intersects the current clipping path with the current path, using the nonzero rule.
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • clipEvenOdd

      public void clipEvenOdd() throws IOException
      Intersects the current clipping path with the current path, using the even-odd rule.
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • setLineWidth

      public void setLineWidth(float lineWidth) throws IOException
      Set line width to the given value.
      Parameters:
      lineWidth - The width which is used for drawing.
      Throws:
      IOException - If the content stream could not be written
      IllegalStateException - If the method was called within a text block.
    • setLineJoinStyle

      public void setLineJoinStyle(int lineJoinStyle) throws IOException
      Set the line join style.
      Parameters:
      lineJoinStyle - 0 for miter join, 1 for round join, and 2 for bevel join.
      Throws:
      IOException - If the content stream could not be written.
      IllegalStateException - If the method was called within a text block.
      IllegalArgumentException - If the parameter is not a valid line join style.
    • setLineCapStyle

      public void setLineCapStyle(int lineCapStyle) throws IOException
      Set the line cap style.
      Parameters:
      lineCapStyle - 0 for butt cap, 1 for round cap, and 2 for projecting square cap.
      Throws:
      IOException - If the content stream could not be written.
      IllegalStateException - If the method was called within a text block.
      IllegalArgumentException - If the parameter is not a valid line cap style.
    • setLineDashPattern

      public void setLineDashPattern(float[] pattern, float phase) throws IOException
      Set the line dash pattern.
      Parameters:
      pattern - The pattern array
      phase - The phase of the pattern
      Throws:
      IOException - If the content stream could not be written.
      IllegalStateException - If the method was called within a text block.
    • beginMarkedContent

      public void beginMarkedContent(org.apache.pdfbox.cos.COSName tag) throws IOException
      Begin a marked content sequence.
      Parameters:
      tag - the tag
      Throws:
      IOException - If the content stream could not be written
    • beginMarkedContent

      public void beginMarkedContent(org.apache.pdfbox.cos.COSName tag, org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList propertyList) throws IOException
      Begin a marked content sequence with a reference to an entry in the page resources' Properties dictionary.
      Parameters:
      tag - the tag
      propertyList - property list
      Throws:
      IOException - If the content stream could not be written
    • endMarkedContent

      public void endMarkedContent() throws IOException
      End a marked content sequence.
      Throws:
      IOException - If the content stream could not be written
    • setGraphicsStateParameters

      public void setGraphicsStateParameters(org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState state) throws IOException
      Set an extended graphics state.
      Parameters:
      state - The extended graphics state.
      Throws:
      IOException - If the content stream could not be written.
    • writeOperand

      protected void writeOperand(float real) throws IOException
      Writes a real real to the content stream.
      Parameters:
      real - the value to be written
      Throws:
      IOException - In case of IO error
    • writeOperand

      protected void writeOperand(int integer) throws IOException
      Writes a real number to the content stream.
      Parameters:
      integer - the value to be written
      Throws:
      IOException - In case of IO error
    • writeOperand

      protected void writeOperand(org.apache.pdfbox.cos.COSName name) throws IOException
      Writes a COSName to the content stream.
      Parameters:
      name - the value to be written
      Throws:
      IOException - In case of IO error
    • writeOperator

      protected final void writeOperator(byte... text) throws IOException
      Writes a string to the content stream as ASCII.
      Parameters:
      text - the value to be written
      Throws:
      IOException - In case of IO error
    • write

      protected void write(byte... text) throws IOException
      Writes a string to the content stream as ASCII.
      Parameters:
      text - the value to be written
      Throws:
      IOException - In case of IO error
    • writeLine

      protected void writeLine() throws IOException
      Writes a string to the content stream as ASCII.
      Throws:
      IOException - In case of IO error
    • writeBytes

      protected void writeBytes(byte[] data) throws IOException
      Writes binary data to the content stream.
      Parameters:
      data - the value to be written
      Throws:
      IOException - In case of IO error
    • close

      public void close() throws IOException
      Close the content stream. This must be called when you are done with this object.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - If the underlying stream has a problem being written to.