class HexaPDF::Type::Catalog

See: PDF2.0 s7.7.2, Trailer
The catalog dictionary is linked via the /Root entry from the Trailer.
hierarchy.
Represents the PDF’s catalog dictionary which is at the root of the document’s object

def acro_form(create: false)

See: AcroForm::Form

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

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

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

Returns the main AcroForm object.
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

def must_be_indirect?

Returns +true+ since catalog objects must always be indirect.
def must_be_indirect?
  true
end

def names

See: Names

needed.
Returns the name dictionary containing all name trees of the document, creating it if
def names
  self[:Names] ||= document.add({}, type: :XXNames)
end

def optional_content

See: OptionalContentProperties

This is the main entry point for working with optional content, a.k.a. layers.

Returns the optional content properties dictionary, creating it if needed.
def optional_content
  self[:OCProperties] ||= document.add({OCGs: [], D: {Creator: 'HexaPDF'}}, type: :XXOCProperties)
end

def outline

See: Outline

Returns the document outline, creating it if needed.
def outline
  self[:Outlines] ||= document.add({}, type: :Outlines)
end

def page_labels(create: false)

See: HexaPDF::Document::Pages

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

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

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

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

def pages

See: PageTreeNode

Returns the root node of the page tree, creating it if needed.
def pages
  self[:Pages] ||= document.add({Type: :Pages})
end

def perform_validation(&block)

Ensures that there is a valid page tree.
def perform_validation(&block)
  super
  unless key?(:Pages)
    yield("A PDF document needs a page tree", true)
    value[:Pages] = document.add({Type: :Pages})
    value[:Pages].validate(&block)
  end
end