Class PDDefaultAppearanceString


  • class PDDefaultAppearanceString
    extends java.lang.Object
    Represents a default appearance string, as found in the /DA entry of free text annotations.

    The default appearance string (DA) contains any graphics state or text state operators needed to establish the graphics state parameters, such as text size and colour, for displaying the field’s variable text. Only operators that are allowed within text objects shall occur in this string. Note: This class is not yet public, as its API is still unstable.

    • Field Detail

      • DEFAULT_FONT_SIZE

        private static final float DEFAULT_FONT_SIZE
        The default font size used by Acrobat.
        See Also:
        Constant Field Values
      • defaultResources

        private final PDResources defaultResources
      • fontName

        private COSName fontName
      • fontSize

        private float fontSize
      • fontColor

        private PDColor fontColor
    • Constructor Detail

      • PDDefaultAppearanceString

        PDDefaultAppearanceString​(COSString defaultAppearance,
                                  PDResources defaultResources)
                           throws java.io.IOException
        Constructor for reading an existing DA string.
        Parameters:
        defaultResources - DR entry
        defaultAppearance - DA entry
        Throws:
        java.io.IOException - If the DA could not be parsed
    • Method Detail

      • processAppearanceStringOperators

        private void processAppearanceStringOperators​(byte[] content)
                                               throws java.io.IOException
        Processes the operators of the given content stream.
        Parameters:
        content - the content to parse.
        Throws:
        java.io.IOException - if there is an error reading or parsing the content stream.
      • processOperator

        private void processOperator​(Operator operator,
                                     java.util.List<COSBase> operands)
                              throws java.io.IOException
        This is used to handle an operation.
        Parameters:
        operator - The operation to perform.
        operands - The list of arguments.
        Throws:
        java.io.IOException - If there is an error processing the operation.
      • processSetFont

        private void processSetFont​(java.util.List<COSBase> operands)
                             throws java.io.IOException
        Process the set font and font size operator.
        Parameters:
        operands - the font name and size
        Throws:
        java.io.IOException - in case there are missing operators or the font is not within the resources
      • processSetFontColor

        private void processSetFontColor​(java.util.List<COSBase> operands)
                                  throws java.io.IOException
        Process the font color operator. This is assumed to be an RGB color.
        Parameters:
        operands - the color components
        Throws:
        java.io.IOException - in case of the color components not matching
      • getFontName

        COSName getFontName()
        Get the font name
        Returns:
        the font name to use for resource lookup
      • setFontName

        void setFontName​(COSName fontName)
        Set the font name.
        Parameters:
        fontName - the font name to use for resource lookup
      • getFont

        PDFont getFont()
        Returns the font.
      • setFont

        void setFont​(PDFont font)
        Set the font.
        Parameters:
        font - the font to use.
      • getFontSize

        public float getFontSize()
        Returns the font size.
      • setFontSize

        void setFontSize​(float fontSize)
        Set the font size.
        Parameters:
        fontSize - the font size.
      • getFontColor

        PDColor getFontColor()
        Returns the font color
      • setFontColor

        void setFontColor​(PDColor fontColor)
        Set the font color.
        Parameters:
        fontColor - the fontColor to use.
      • writeTo

        void writeTo​(PDPageContentStream contents,
                     float zeroFontSize)
              throws java.io.IOException
        Writes the DA string to the given content stream.
        Throws:
        java.io.IOException
      • copyNeededResourcesTo

        void copyNeededResourcesTo​(PDAppearanceStream appearanceStream)
                            throws java.io.IOException
        Copies any needed resources from the document’s DR dictionary into the stream’s Resources dictionary. Resources with the same name shall be left intact.
        Throws:
        java.io.IOException