Class PDAppearanceContentStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class PDAppearanceContentStream
    extends PDAbstractContentStream
    implements java.io.Closeable
    Provides the ability to write to an appearance content stream.
    • Constructor Detail

      • PDAppearanceContentStream

        public PDAppearanceContentStream​(PDAppearanceStream appearance)
                                  throws java.io.IOException
        Create a new appearance stream.
        Parameters:
        appearance - The appearance stream to write to.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.
      • PDAppearanceContentStream

        public PDAppearanceContentStream​(PDAppearanceStream appearance,
                                         boolean compress)
                                  throws java.io.IOException
        Create a new appearance stream.
        Parameters:
        appearance - The appearance stream to write to.
        compress - whether the content stream is to be compressed. Set this to true when creating long content streams.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.
      • PDAppearanceContentStream

        public PDAppearanceContentStream​(PDAppearanceStream appearance,
                                         java.io.OutputStream outputStream)
        Create a new appearance stream.
        Parameters:
        appearance - The appearance stream to add to.
        outputStream - The appearances output stream to write to.
    • Method Detail

      • setStrokingColorOnDemand

        public boolean setStrokingColorOnDemand​(PDColor color)
                                         throws java.io.IOException
        Set the stroking color.

        The command is only emitted if the color is not null and the number of components is > 0.

        Parameters:
        color - The colorspace to write.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.
        See Also:
        PDAbstractContentStream.setStrokingColor(PDColor)
      • setStrokingColor

        public void setStrokingColor​(float[] components)
                              throws java.io.IOException
        Set the stroking color.
        Parameters:
        components - the color components dependent on the color space being used.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.
        See Also:
        PDAbstractContentStream.setStrokingColor(java.awt.Color)
      • setNonStrokingColorOnDemand

        public boolean setNonStrokingColorOnDemand​(PDColor color)
                                            throws java.io.IOException
        Set the non stroking color.

        The command is only emitted if the color is not null and the number of components is > 0.

        Parameters:
        color - The colorspace to write.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.
        See Also:
        PDAbstractContentStream.setNonStrokingColor(PDColor)
      • setNonStrokingColor

        public void setNonStrokingColor​(float[] components)
                                 throws java.io.IOException
        Set the non stroking color.
        Parameters:
        components - the color components dependent on the color space being used.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.
        See Also:
        PDAbstractContentStream.setNonStrokingColor(java.awt.Color)
      • setBorderLine

        public void setBorderLine​(float lineWidth,
                                  PDBorderStyleDictionary bs,
                                  COSArray border)
                           throws java.io.IOException
        Convenience method for annotations: sets the line with and dash style.
        Parameters:
        lineWidth - The line width.
        bs - The border style, may be null.
        border - The border array, must have at least three entries. This is only used if the border style is null.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.
      • setLineWidthOnDemand

        public void setLineWidthOnDemand​(float lineWidth)
                                  throws java.io.IOException
        Sets the line width. The command is only emitted if the lineWidth is different to 1.
        Parameters:
        lineWidth - the line width of the path.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.
        See Also:
        PDAbstractContentStream.setLineWidth(float)
      • drawShape

        public void drawShape​(float lineWidth,
                              boolean hasStroke,
                              boolean hasFill)
                       throws java.io.IOException
        Draw a shape.

        Dependent on the lineWidth and whether or not there is a background to be generated there are different commands to be used for draw a shape.

        Parameters:
        lineWidth - the line width of the path.
        hasStroke - shall there be a stroking color.
        hasFill - shall there be a fill color.
        Throws:
        java.io.IOException - If there is an error writing to the content stream.