Class: HexaPDF::Type::Catalog

Inherits:
Dictionary show all
Defined in:
lib/hexapdf/type/catalog.rb

Overview

Represents the PDF’s catalog dictionary which is at the root of the document’s object hierarchy.

The catalog dictionary is linked via the /Root entry from the Trailer.

See: PDF1.7 s7.7.2, Trailer

Constant Summary

Constants included from DictionaryFields

DictionaryFields::Boolean, DictionaryFields::PDFByteString, DictionaryFields::PDFDate

Instance Attribute Summary

Attributes inherited from Object

#data, #document, #must_be_indirect

Instance Method Summary collapse

Methods inherited from Dictionary

#[], #[]=, define_field, define_type, #delete, #each, each_field, #empty?, field, #key?, #to_h, type, #type

Methods inherited from Object

#<=>, #==, #cache, #cached?, #clear_cache, deep_copy, #deep_copy, #document?, #eql?, field, #gen, #gen=, #hash, #indirect?, #initialize, #inspect, make_direct, #null?, #oid, #oid=, #type, #validate, #value, #value=

Constructor Details

This class inherits a constructor from HexaPDF::Object

Instance Method Details

#acro_form(create: false) ⇒ Object

Returns the main AcroForm object.

  • If an AcroForm object exists, the create argument is not used.

  • If no AcroForm object exists and create is true, a new AcroForm object with default settings will be created and returned.

  • If no AcroForm object exists and create is false, nil is returned.

See: AcroForm::Form



125
126
127
128
129
130
131
132
133
# File 'lib/hexapdf/type/catalog.rb', line 125

def acro_form(create: false)
  if (form = self[:AcroForm])
    form
  elsif create
    form = self[:AcroForm] = document.add({}, type: :XXAcroForm)
    form.set_default_appearance_string
    form
  end
end

#must_be_indirect?Boolean

Returns true since catalog objects must always be indirect.

Returns:



89
90
91
# File 'lib/hexapdf/type/catalog.rb', line 89

def must_be_indirect?
  true
end

#namesObject

Returns the name dictionary containing all name trees of the document, creating it if needed.

See: Names



104
105
106
# File 'lib/hexapdf/type/catalog.rb', line 104

def names
  self[:Names] ||= document.add({}, type: :XXNames)
end

#outlineObject

Returns the document outline, creating it if needed.

See: Outline



111
112
113
# File 'lib/hexapdf/type/catalog.rb', line 111

def outline
  self[:Outlines] ||= document.add({}, type: :Outlines)
end

#page_labels(create: false) ⇒ Object

Returns the page labels number tree.

  • If a page labels number tree exists, the create argument is not used.

  • If no page labels number tree exists and create is true, a new one is created.

  • If no page labels number tree exists and create is false, nil is returned.

See: HexaPDF::Document::Pages



144
145
146
147
148
149
150
# File 'lib/hexapdf/type/catalog.rb', line 144

def page_labels(create: false)
  if (object = self[:PageLabels])
    object
  elsif create
    self[:PageLabels] = document.wrap({}, type: NumberTreeNode)
  end
end

#pagesObject

Returns the root node of the page tree, creating it if needed.

See: PageTreeNode



96
97
98
# File 'lib/hexapdf/type/catalog.rb', line 96

def pages
  self[:Pages] ||= document.add({Type: :Pages})
end