Class 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 Detail

      • numberOfObjects

        private final int numberOfObjects
      • firstObject

        private final int firstObject
    • Constructor Detail

      • PDFObjectStreamParser

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

      • parseObject

        public COSBase parseObject​(long objectNumber)
                            throws java.io.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:
        java.io.IOException - if there is an error while parsing the stream
      • parseAllObjects

        public java.util.Map<COSObjectKey,​COSBase> parseAllObjects()
                                                                  throws java.io.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:
        java.io.IOException - if there is an error while parsing the stream
      • privateReadObjectNumbers

        private java.util.Map<java.lang.Long,​java.lang.Integer> privateReadObjectNumbers()
                                                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • privateReadObjectOffsets

        private java.util.Map<java.lang.Integer,​java.lang.Long> privateReadObjectOffsets()
                                                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readObjectNumbers

        public java.util.Map<java.lang.Long,​java.lang.Integer> readObjectNumbers()
                                                                                throws java.io.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:
        java.io.IOException - if there is an error while parsing the stream