Method: Origami::PDF#each_object

Defined in:
lib/origami/pdf.rb

#each_object(compressed: false, recursive: false, &block) ⇒ Object

Iterates over the objects of the document. compressed: iterates over the objects inside object streams. recursive: iterates recursively inside objects like arrays and dictionaries.



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/origami/pdf.rb', line 278

def each_object(compressed: false, recursive: false, &block)
    return enum_for(__method__, compressed: compressed,
                                recursive: recursive
                   ) unless block_given?

    @revisions.each do |revision|
        revision.each_object do |object|
            block.call(object)

            walk_object(object, &block) if recursive

            if object.is_a?(ObjectStream) and compressed
                object.each do |child_obj|
                    block.call(child_obj)

                    walk_object(child_obj) if recursive
                end
            end
        end
    end
end