def search_object(object, pattern, streams: true, object_streams: true)
            result = []

            case object
            when Stream
                result.concat object.dictionary.strings_cache.select{|str| str.match(pattern) }
                result.concat object.dictionary.names_cache.select{|name| name.value.match(pattern) }

                begin
                    result.push object if streams and object.data.match(pattern)
                rescue Filter::Error
                    return result # Skip object if a decoding error occured.
                end

                return result unless object.is_a?(ObjectStream) and object_streams

                object.each do |child|
                    result.concat search_object(child, pattern,
                                                streams: streams, object_streams: object_streams)
                end

            when Name, String
                result.push object if object.value.match(pattern)

            when ObjectCache
                result.concat object.strings_cache.select{|str| str.match(pattern) }
                result.concat object.names_cache.select{|name| name.value.match(pattern) }
            end

            result
        end
def search_object(object, pattern, streams: true, object_streams: true)
            result = []

            case object
            when Stream
                result.concat object.dictionary.strings_cache.select{|str| str.match(pattern) }
                result.concat object.dictionary.names_cache.select{|name| name.value.match(pattern) }

                begin
                    result.push object if streams and object.data.match(pattern)
                rescue Filter::Error
                    return result # Skip object if a decoding error occured.
                end

                return result unless object.is_a?(ObjectStream) and object_streams

                object.each do |child|
                    result.concat search_object(child, pattern,
                                                streams: streams, object_streams: object_streams)
                end

            when Name, String
                result.push object if object.value.match(pattern)

            when ObjectCache
                result.concat object.strings_cache.select{|str| str.match(pattern) }
                result.concat object.names_cache.select{|name| name.value.match(pattern) }
            end

            result
        end
Searches through an object, possibly going into object streams.
 Returns an array of matching strings, names and streams.