Module: Prawn::Core::Destinations
- Included in:
- Document
- Defined in:
- lib/prawn/core/destinations.rb
Overview
:nodoc:
Constant Summary collapse
- NAME_TREE_CHILDREN_LIMIT =
The maximum number of children to fit into a single node in the Dests tree.
20
Instance Method Summary collapse
-
#add_dest(name, reference) ⇒ Object
Adds a new destination to the dests name tree (see #dests).
-
#dest_fit(page = current_page) ⇒ Object
Return a Dest specification that will fit the given page into the viewport.
-
#dest_fit_bounds(page = current_page) ⇒ Object
Return a Dest specfication that will fit the given page’s bounding box into the viewport.
-
#dest_fit_bounds_horizontally(top, page = current_page) ⇒ Object
Same as #dest_fit_horizontally, but works on the page’s bounding box instead of the entire page.
-
#dest_fit_bounds_vertically(left, page = current_page) ⇒ Object
Same as #dest_fit_vertically, but works on the page’s bounding box instead of the entire page.
-
#dest_fit_horizontally(top, page = current_page) ⇒ Object
Return a Dest specification that will fit the given page horizontally into the viewport, aligned vertically at the given top coordinate.
-
#dest_fit_rect(left, bottom, right, top, page = current_page) ⇒ Object
Return a Dest specification that will fit the given rectangle into the viewport, for the given page.
-
#dest_fit_vertically(left, page = current_page) ⇒ Object
Return a Dest specification that will fit the given page vertically into the viewport, aligned horizontally at the given left coordinate.
-
#dest_xyz(left, top, zoom = nil, page = current_page) ⇒ Object
Return a Dest specification for a specific location (and optional zoom level).
-
#dests ⇒ Object
The Dests name tree in the Name dictionary (see Prawn::Document::Internal#names).
Instance Method Details
#add_dest(name, reference) ⇒ Object
Adds a new destination to the dests name tree (see #dests). The reference
parameter will be converted into a Prawn::Reference if it is not already one.
28 29 30 31 |
# File 'lib/prawn/core/destinations.rb', line 28 def add_dest(name, reference) reference = ref!(reference) unless reference.is_a?(Prawn::Core::Reference) dests.data.add(name, reference) end |
#dest_fit(page = current_page) ⇒ Object
Return a Dest specification that will fit the given page into the viewport.
43 44 45 |
# File 'lib/prawn/core/destinations.rb', line 43 def dest_fit(page=current_page) [page, :Fit] end |
#dest_fit_bounds(page = current_page) ⇒ Object
Return a Dest specfication that will fit the given page’s bounding box into the viewport.
71 72 73 |
# File 'lib/prawn/core/destinations.rb', line 71 def dest_fit_bounds(page=current_page) [page, :FitB] end |
#dest_fit_bounds_horizontally(top, page = current_page) ⇒ Object
Same as #dest_fit_horizontally, but works on the page’s bounding box instead of the entire page.
78 79 80 |
# File 'lib/prawn/core/destinations.rb', line 78 def dest_fit_bounds_horizontally(top, page=current_page) [page, :FitBH, top] end |
#dest_fit_bounds_vertically(left, page = current_page) ⇒ Object
Same as #dest_fit_vertically, but works on the page’s bounding box instead of the entire page.
85 86 87 |
# File 'lib/prawn/core/destinations.rb', line 85 def dest_fit_bounds_vertically(left, page=current_page) [page, :FitBV, left] end |
#dest_fit_horizontally(top, page = current_page) ⇒ Object
Return a Dest specification that will fit the given page horizontally into the viewport, aligned vertically at the given top coordinate.
50 51 52 |
# File 'lib/prawn/core/destinations.rb', line 50 def dest_fit_horizontally(top, page=current_page) [page, :FitH, top] end |
#dest_fit_rect(left, bottom, right, top, page = current_page) ⇒ Object
Return a Dest specification that will fit the given rectangle into the viewport, for the given page.
64 65 66 |
# File 'lib/prawn/core/destinations.rb', line 64 def dest_fit_rect(left, bottom, right, top, page=current_page) [page, :FitR, left, bottom, right, top] end |
#dest_fit_vertically(left, page = current_page) ⇒ Object
Return a Dest specification that will fit the given page vertically into the viewport, aligned horizontally at the given left coordinate.
57 58 59 |
# File 'lib/prawn/core/destinations.rb', line 57 def dest_fit_vertically(left, page=current_page) [page, :FitV, left] end |
#dest_xyz(left, top, zoom = nil, page = current_page) ⇒ Object
Return a Dest specification for a specific location (and optional zoom level).
36 37 38 |
# File 'lib/prawn/core/destinations.rb', line 36 def dest_xyz(left, top, zoom=nil, page=current_page) [page, :XYZ, left, top, zoom] end |
#dests ⇒ Object
The Dests name tree in the Name dictionary (see Prawn::Document::Internal#names). This name tree is used to store named destinations (PDF spec 8.2.1). (For more on name trees, see section 3.8.4 in the PDF spec.)
20 21 22 |
# File 'lib/prawn/core/destinations.rb', line 20 def dests names.data[:Dests] ||= ref!(Prawn::Core::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT)) end |