Prawn::Document::Annotations

Provides very low-level support for annotations. These extensions are mainly for use by prawn-format, so be sure to check that out if all you need is basic internal or external links.

Public Instance Methods

annotate(options) click to toggle source

Adds a new annotation (section 8.4 in PDF spec) to the current page. options must be a Hash describing the annotation.

    # File lib/prawn/document/annotations.rb, line 23
23:       def annotate(options)
24:         page.dictionary.data[:Annots] ||= []
25:         options = sanitize_annotation_hash(options)
26:         page.dictionary.data[:Annots] << ref!(options)
27:         return options
28:       end
text_annotation(rect, contents, options={}) click to toggle source

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.

    # File lib/prawn/document/annotations.rb, line 34
34:       def text_annotation(rect, contents, options={})
35:         options = options.merge(:Subtype => :Text, :Rect => rect, :Contents => contents)
36:         annotate(options)
37:       end

Private Instance Methods

sanitize_annotation_hash(options) click to toggle source
    # File lib/prawn/document/annotations.rb, line 53
53:       def sanitize_annotation_hash(options)
54:         options = options.merge(:Type => :Annot)
55: 
56:         if options[:Dest].is_a?(String)
57:           options[:Dest] = Prawn::LiteralString.new(options[:Dest])
58:         end
59: 
60:         options
61:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.