def get_object(no, generation = 0, use_xrefstm: true) #:nodoc:
            case no
            when Reference
                target = no
            when ::Integer
                target = Reference.new(no, generation)
            when Origami::Object
                return no
            else
                raise TypeError, "Invalid parameter type : #{no.class}"
            end

            #
            # Search through accessible indirect objects.
            #
            @revisions.reverse_each do |rev|
                return rev.body[target] if rev.body.include?(target)
            end

            #
            # Search through xref sections.
            #
            @revisions.reverse_each do |rev|
                next unless rev.xreftable?

                xref = rev.xreftable.find(target.refno)
                next if xref.nil? or xref.free?

                # Try loading the object if it is not present.
                object = load_object_at_offset(rev, xref.offset)
                return object unless object.nil?
            end

            return nil unless use_xrefstm

            # Search through xref streams.
            @revisions.reverse_each do |rev|
                next unless rev.xrefstm?

                xrefstm = rev.xrefstm

                xref = xrefstm.find(target.refno)
                next if xref.nil?

                #
                # We found a matching XRef.
                #
                if xref.is_a?(XRefToCompressedObject)
                    objstm = get_object(xref.objstmno, 0, use_xrefstm: use_xrefstm)

                    object = objstm.extract_by_index(xref.index)
                    if object.is_a?(Origami::Object) and object.no == target.refno
                        return object
                    else
                        return objstm.extract(target.refno)
                    end
                elsif xref.is_a?(XRef)
                    object = load_object_at_offset(rev, xref.offset)
                    return object unless object.nil?
                end
            end

            #
            # Lastly search directly into Object streams (might be very slow).
            #
            @revisions.reverse_each do |rev|
                stream = rev.objects.find{|obj| obj.is_a?(ObjectStream) and obj.include?(target.refno)}
                return stream.extract(target.refno) unless stream.nil?
            end

            nil
        end
def get_object(no, generation = 0, use_xrefstm: true) #:nodoc:
            case no
            when Reference
                target = no
            when ::Integer
                target = Reference.new(no, generation)
            when Origami::Object
                return no
            else
                raise TypeError, "Invalid parameter type : #{no.class}"
            end

            #
            # Search through accessible indirect objects.
            #
            @revisions.reverse_each do |rev|
                return rev.body[target] if rev.body.include?(target)
            end

            #
            # Search through xref sections.
            #
            @revisions.reverse_each do |rev|
                next unless rev.xreftable?

                xref = rev.xreftable.find(target.refno)
                next if xref.nil? or xref.free?

                # Try loading the object if it is not present.
                object = load_object_at_offset(rev, xref.offset)
                return object unless object.nil?
            end

            return nil unless use_xrefstm

            # Search through xref streams.
            @revisions.reverse_each do |rev|
                next unless rev.xrefstm?

                xrefstm = rev.xrefstm

                xref = xrefstm.find(target.refno)
                next if xref.nil?

                #
                # We found a matching XRef.
                #
                if xref.is_a?(XRefToCompressedObject)
                    objstm = get_object(xref.objstmno, 0, use_xrefstm: use_xrefstm)

                    object = objstm.extract_by_index(xref.index)
                    if object.is_a?(Origami::Object) and object.no == target.refno
                        return object
                    else
                        return objstm.extract(target.refno)
                    end
                elsif xref.is_a?(XRef)
                    object = load_object_at_offset(rev, xref.offset)
                    return object unless object.nil?
                end
            end

            #
            # Lastly search directly into Object streams (might be very slow).
            #
            @revisions.reverse_each do |rev|
                stream = rev.objects.find{|obj| obj.is_a?(ObjectStream) and obj.include?(target.refno)}
                return stream.extract(target.refno) unless stream.nil?
            end

            nil
        end
Search for an indirect object in the document.
 _no_:: Reference or number of the object.
 _generation_:: Object generation.