Module: PDF::Core::Destinations Private

Defined in:
lib/pdf/core/destinations.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Implements destination support for PDF

Constant Summary collapse

NAME_TREE_CHILDREN_LIMIT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The maximum number of children to fit into a single node in the Dests tree.

20

Instance Method Summary collapse

Instance Method Details

#add_dest(name, reference) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Adds a new destination to the Dests name tree.

Parameters:

  • name (Symbol)

    Destination name

  • reference (PDF::Core::Reference, Array, Hash)

    Destination definition, will be converted into a Reference if it is not already one.

See Also:



35
36
37
38
# File 'lib/pdf/core/destinations.rb', line 35

def add_dest(name, reference)
  reference = ref!(reference) unless reference.is_a?(PDF::Core::Reference)
  dests.data.add(name, reference)
end

#dest_fit(dest_page = page) ⇒ Array(PDF::Core::Reference, :Fit)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

builds a Dest specification that will fit the given page into the viewport.

Parameters:

Returns:



59
60
61
# File 'lib/pdf/core/destinations.rb', line 59

def dest_fit(dest_page = page)
  [dest_page.dictionary, :Fit]
end

#dest_fit_bounds(dest_page = page) ⇒ Array(PDF::Core::Reference, :FitB)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds a Dest specification that will fit the given page’s bounding box into the viewport.

Parameters:

Returns:

  • (Array(PDF::Core::Reference, :FitB))

    a Dest specification for a page fitting bounding box into viewport



106
107
108
# File 'lib/pdf/core/destinations.rb', line 106

def dest_fit_bounds(dest_page = page)
  [dest_page.dictionary, :FitB]
end

#dest_fit_bounds_horizontally(top, dest_page = page) ⇒ Array(PDF::Core::Reference, :FitBH, Numeric)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Same as #dest_fit_horizontally, but works on the page’s bounding box instead of the entire page.

Parameters:

Returns:

  • (Array(PDF::Core::Reference, :FitBH, Numeric))

    a Dest specification for a page bounding box fitting horizontally at a given top coordinate



117
118
119
# File 'lib/pdf/core/destinations.rb', line 117

def dest_fit_bounds_horizontally(top, dest_page = page)
  [dest_page.dictionary, :FitBH, top]
end

#dest_fit_bounds_vertically(left, dest_page = page) ⇒ Array(PDF::Core::Reference, :FitBV, Numeric)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Same as #dest_fit_vertically, but works on the page’s bounding box instead of the entire page.

Parameters:

Returns:

  • (Array(PDF::Core::Reference, :FitBV, Numeric))

    a Dest specification for a page bounding box fitting vertically at a given top coordinate



128
129
130
# File 'lib/pdf/core/destinations.rb', line 128

def dest_fit_bounds_vertically(left, dest_page = page)
  [dest_page.dictionary, :FitBV, left]
end

#dest_fit_horizontally(top, dest_page = page) ⇒ Array(PDF::Core::Reference, :FitH, Numeric)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds a Dest specification that will fit the given page horizontally into the viewport, aligned vertically at the given top coordinate.

Parameters:

Returns:

  • (Array(PDF::Core::Reference, :FitH, Numeric))

    a Dest specification for a page content fitting horizontally at a given top coordinate



70
71
72
# File 'lib/pdf/core/destinations.rb', line 70

def dest_fit_horizontally(top, dest_page = page)
  [dest_page.dictionary, :FitH, top]
end

#dest_fit_rect(left, bottom, right, top, dest_page = page) ⇒ Array(Hash, :FitR, Numeric, Numeric, Numeric, Numeric)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds a Dest specification that will fit the given rectangle into the viewport, for the given page.

Parameters:

  • left (Numeric)
  • bottom (Numeric)
  • right (Numeric)
  • top (Numeric)
  • dest_page (PDF::Core::Page) (defaults to: page)

Returns:

  • (Array(Hash, :FitR, Numeric, Numeric, Numeric, Numeric))

    a Dest specification for a page fitting the given rectangle in the viewport



96
97
98
# File 'lib/pdf/core/destinations.rb', line 96

def dest_fit_rect(left, bottom, right, top, dest_page = page)
  [dest_page.dictionary, :FitR, left, bottom, right, top]
end

#dest_fit_vertically(left, dest_page = page) ⇒ Array(Hash, :FitV, Numeric)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build a Dest specification that will fit the given page vertically into the viewport, aligned horizontally at the given left coordinate.

Parameters:

Returns:

  • (Array(Hash, :FitV, Numeric))

    a Dest specification for a page content fitting vertically at a given left coordinate



81
82
83
# File 'lib/pdf/core/destinations.rb', line 81

def dest_fit_vertically(left, dest_page = page)
  [dest_page.dictionary, :FitV, left]
end

#dest_xyz(left, top, zoom = nil, dest_page = page) ⇒ Array(PDF::Core::Reference, :XYZ, Numeric, Numeric, [Numeric, null])

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds a Dest specification for a specific location (and optional zoom level).

Parameters:

  • left (Numeric)
  • top (Numeric)
  • zoom (Numeric) (defaults to: nil)
  • dest_page (PDF::Core::Page) (defaults to: page)

Returns:

  • (Array(PDF::Core::Reference, :XYZ, Numeric, Numeric, [Numeric, null]))

    a Dest specification for a specific location



49
50
51
# File 'lib/pdf/core/destinations.rb', line 49

def dest_xyz(left, top, zoom = nil, dest_page = page)
  [dest_page.dictionary, :XYZ, left, top, zoom]
end

#destsPDF::Core::Reference<PDF::Core::NameTree::Node>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The ‘:Dests` name tree in the Name dictionary. This name tree is used to store named destinations (PDF 1.7 spec 8.2.1). (For more on name trees, see section 3.8.5 in the PDF 1.7 spec.)

Returns:

See Also:

  • Prawn::Document::Internal#names


21
22
23
24
25
# File 'lib/pdf/core/destinations.rb', line 21

def dests
  names.data[:Dests] ||= ref!(
    PDF::Core::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT),
  )
end