Class: HexaPDF::Type::Catalog
- Inherits:
-
Dictionary
- Object
- Object
- Dictionary
- HexaPDF::Type::Catalog
- 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: PDF2.0 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
-
#acro_form(create: false) ⇒ Object
Returns the main AcroForm object.
-
#must_be_indirect? ⇒ Boolean
Returns
truesince catalog objects must always be indirect. -
#names ⇒ Object
Returns the name dictionary containing all name trees of the document, creating it if needed.
-
#optional_content ⇒ Object
Returns the optional content properties dictionary, creating it if needed.
-
#outline ⇒ Object
Returns the document outline, creating it if needed.
-
#page_labels(create: false) ⇒ Object
Returns the page labels number tree.
-
#pages ⇒ Object
Returns the root node of the page tree, creating it if needed.
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
createargument is not used. -
If no AcroForm object exists and
createistrue, a new AcroForm object with default settings will be created and returned. -
If no AcroForm object exists and
createisfalse,nilis returned.
See: AcroForm::Form
134 135 136 137 138 139 140 141 142 |
# File 'lib/hexapdf/type/catalog.rb', line 134 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.
89 90 91 |
# File 'lib/hexapdf/type/catalog.rb', line 89 def must_be_indirect? true end |
#names ⇒ Object
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 |
#optional_content ⇒ Object
Returns the optional content properties dictionary, creating it if needed.
This is the main entry point for working with optional content, a.k.a. layers.
See: OptionalContentProperties
120 121 122 |
# File 'lib/hexapdf/type/catalog.rb', line 120 def optional_content self[:OCProperties] ||= document.add({OCGs: [], D: {Creator: 'HexaPDF'}}, type: :XXOCProperties) end |
#outline ⇒ Object
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
createargument is not used. -
If no page labels number tree exists and
createistrue, a new one is created. -
If no page labels number tree exists and
createisfalse,nilis returned.
See: HexaPDF::Document::Pages
153 154 155 156 157 158 159 |
# File 'lib/hexapdf/type/catalog.rb', line 153 def page_labels(create: false) if (object = self[:PageLabels]) object elsif create self[:PageLabels] = document.wrap({}, type: NumberTreeNode) end end |
#pages ⇒ Object
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 |