Class PDFObjectStreamParser

java.lang.Object
org.apache.pdfbox.pdfparser.BaseParser
org.apache.pdfbox.pdfparser.PDFObjectStreamParser

public class PDFObjectStreamParser extends BaseParser
This will parse a PDF 1.5 object stream and extract the object with given object number from the stream.
  • Field Details

    • numberOfObjects

      private final int numberOfObjects
    • firstObject

      private final int firstObject
  • Constructor Details

    • PDFObjectStreamParser

      public PDFObjectStreamParser(COSStream stream, COSDocument document) throws IOException
      Constructor.
      Parameters:
      stream - The stream to parse.
      document - The document for the current parsing.
      Throws:
      IOException - If there is an error initializing the stream.
  • Method Details

    • parseObject

      public COSBase parseObject(long objectNumber) throws IOException
      Search for/parse the object with the given object number. The stream is closed after parsing the object with the given number.
      Parameters:
      objectNumber - the number of the object to b e parsed
      Returns:
      the parsed object or null if the object with the given number can't be found
      Throws:
      IOException - if there is an error while parsing the stream
    • parseAllObjects

      public Map<COSObjectKey,COSBase> parseAllObjects() throws IOException
      Parse all compressed objects. The stream is closed after parsing.
      Returns:
      a map containing all parsed objects using the object number as key
      Throws:
      IOException - if there is an error while parsing the stream
    • privateReadObjectNumbers

      private Map<Long,Integer> privateReadObjectNumbers() throws IOException
      Throws:
      IOException
    • privateReadObjectOffsets

      private Map<Integer,Long> privateReadObjectOffsets() throws IOException
      Throws:
      IOException
    • readObjectNumbers

      public Map<Long,Integer> readObjectNumbers() throws IOException
      Read all object numbers from the compressed object stream. The stream is closed after reading the object numbers.
      Returns:
      a map off all object numbers and the corresponding offset within the object stream.
      Throws:
      IOException - if there is an error while parsing the stream