Class: Pdfrb::Model::Type::PageTreeNode

Inherits:
Cos::Dictionary show all
Defined in:
lib/pdfrb/model/type/page_tree_node.rb

Overview

Intermediate page-tree node (s7.7.3.2). Holds /Kids (array of PageTreeNode or Page) + /Count + inheritable /MediaBox, /CropBox, /Resources, /Rotate. The root uses the same dict shape and is conventionally distinguished via PageTreeNodeRoot for type-dispatch purposes.

Direct Known Subclasses

PageTreeNodeRoot

Instance Attribute Summary

Attributes inherited from Object

#document, #gen, #oid, #value

Instance Method Summary collapse

Methods inherited from Cos::Dictionary

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, own_fields, #pdf_type, register_type, type_map, #validate

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Dictionary

Instance Method Details

#each_page(&block) ⇒ Object

Walk all leaf PageObjects under this node.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pdfrb/model/type/page_tree_node.rb', line 16

def each_page(&block)
  return enum_for(:each_page) unless block_given?

  kids = self[:Kids] || []
  kids.each do |kid_ref|
    kid = kid_ref.is_a?(Pdfrb::Model::Reference) ?
            document&.object(kid_ref) : kid_ref
    next unless kid

    case kid[:Type]
    when :Pages then kid.each_page(&block)
    when :Page then yield kid
    end
  end
end

#page_countObject



32
33
34
# File 'lib/pdfrb/model/type/page_tree_node.rb', line 32

def page_count
  self[:Count] || 0
end