Class PdfContentStreamProcessor

java.lang.Object
com.aowagie.text.pdf.parser.PdfContentStreamProcessor
Direct Known Subclasses:
SimpleTextExtractingPdfContentStreamProcessor

abstract class PdfContentStreamProcessor extends Object
Processor for a PDF content Stream.
Since:
2.1.4
  • Field Details

    • operators

      private Map operators
      A map with all supported operators operators (PDF syntax).
    • resources

      private PdfDictionary resources
      Resources for the content stream.
    • gsStack

      private final Stack gsStack
      Stack keeping track of the graphics state.
    • textMatrix

      private Matrix textMatrix
      Text matrix.
    • textLineMatrix

      private Matrix textLineMatrix
      Text line matrix.
  • Constructor Details

    • PdfContentStreamProcessor

      public PdfContentStreamProcessor()
      Creates a new PDF Content Stream Processor.
  • Method Details

    • populateOperators

      private void populateOperators()
      Loads all the supported graphics and text state operators in a map.
    • reset

      public void reset()
      Resets the graphics state stack, matrices and resources.
    • gs

      public GraphicsState gs()
      Returns the current graphics state.
      Returns:
      the graphics state
    • getCurrentTextMatrix

      public Matrix getCurrentTextMatrix()
      Returns the current text matrix.
      Returns:
      the text matrix
      Since:
      2.1.5
    • getCurrentTextLineMatrix

      public Matrix getCurrentTextLineMatrix()
      Returns the current line matrix.
      Returns:
      the line matrix
      Since:
      2.1.5
    • invokeOperator

      private void invokeOperator(PdfLiteral operator, ArrayList operands)
      Invokes an operator.
      Parameters:
      operator - the PDF Syntax of the operator
      operands - a list with operands
    • decode

      private String decode(PdfString in)
      Decodes a PdfString (which will contain glyph ids encoded in the font's encoding) based on the active font, and determine the unicode equivalent
      Parameters:
      in - the String that needs to be encoded
      Returns:
      the encoded String
      Since:
      2.1.7
    • displayText

      public abstract void displayText(String text, Matrix nextTextMatrix)
      Displays text.
      Parameters:
      text - the text that needs to be displayed
      nextTextMatrix - a text matrix
    • getStringWidth

      private float getStringWidth(String string, float tj)
      Gets the width of a String.
      Parameters:
      string - the string that needs measuring
      tj - text adjustment
      Returns:
      the width of a String
    • displayPdfString

      private void displayPdfString(PdfString string, float tj)
      Displays text.
      Parameters:
      string - the text to display
      tj - the text adjustment
    • processContent

      public void processContent(byte[] contentBytes, PdfDictionary resources)
      Processes PDF syntax
      Parameters:
      contentBytes - the bytes of a content stream
      resources - the resources that come with the content stream