Module: Prawn::Core::Annotations
- Included in:
- Document
- Defined in:
- lib/prawn/core/annotations.rb
Overview
Provides very low-level support for annotations.
Instance Method Summary collapse
-
#annotate(options) ⇒ Object
Adds a new annotation (section 8.4 in PDF spec) to the current page.
-
#link_annotation(rect, options = {}) ⇒ Object
A convenience method for creating Link annotations.
-
#text_annotation(rect, contents, options = {}) ⇒ Object
A convenience method for creating Text annotations.
Instance Method Details
#annotate(options) ⇒ Object
Adds a new annotation (section 8.4 in PDF spec) to the current page. options
must be a Hash describing the annotation.
19 20 21 22 23 24 |
# File 'lib/prawn/core/annotations.rb', line 19 def annotate() state.page.dictionary.data[:Annots] ||= [] = sanitize_annotation_hash() state.page.dictionary.data[:Annots] << ref!() return end |
#link_annotation(rect, options = {}) ⇒ Object
A convenience method for creating Link annotations. rect
must be an array of four numbers, describing the bounds of the annotation. The options
hash should include either :Dest (describing the target destination, usually as a string that has been recorded in the document’s Dests tree), or :A (describing an action to perform on clicking the link), or :PA (for describing a URL to link to).
42 43 44 45 |
# File 'lib/prawn/core/annotations.rb', line 42 def link_annotation(rect, ={}) = .merge(:Subtype => :Link, :Rect => rect) annotate() end |
#text_annotation(rect, contents, options = {}) ⇒ Object
A convenience method for creating Text annotations. rect
must be an array of four numbers, describing the bounds of the annotation. contents
should be a string, to be shown when the annotation is activated.
30 31 32 33 |
# File 'lib/prawn/core/annotations.rb', line 30 def text_annotation(rect, contents, ={}) = .merge(:Subtype => :Text, :Rect => rect, :Contents => contents) annotate() end |