Module: PDF::Core::Annotations Private

Defined in:
lib/pdf/core/annotations.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.

Provides very low-level support for annotations.

Instance Method Summary collapse

Instance Method Details

#annotate(options) ⇒ options

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.

Adds a new annotation (section 8.4 Annotations in PDF 1.7 spec) to the current page.

Parameters:

  • options (Hash)

    Annotation options. This is basically an Annot dict as decribed in the PDF spec.

Options Hash (options):

  • :Subtype (Symbol<:Text, :Link, :FreeText, :Line, :Square, :Circle, :Polygon, :PolyLine, :Highlight, :Underline, :Squiggly, :StrikeOut, :Stamp, :Caret, :Ink, :Popup, :FileAttachment, :Sound, :Movie, :Widget, :Screen, :PrinterMark, :TrapNet, :Watermark, :3D>)

    The type of annotation

  • :Rect (Array<Numeric, 4>)

    The annotation rectangle

  • :Contents (String)

    Text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form.

  • :P (PDF::Core::Reference)

    An indirect reference to the page object with which this annotation is associated.

  • :NM (String)

    The annotation name, a text string uniquely identifying it among all the annotations on its page.

  • :M (Date, Time, String)

    The date and time when the annotation was most recently modified

  • :F (Integer)

    A set of flags specifying various characteristics of the annotation

  • :AP (Hash)

    An appearance dictionary specifying how the annotation is presented visually on the page

  • :AS (Symbol)

    The annotation’s appearance state

  • :Border (Array<(Numeric, Array<Numeric>)>)

    the characteristics of the annotation’s border

  • :C (Array<Float>)

    Color

  • :StructParent (Integer)

    The integer key of the annotation’s entry in the structural parent tree

  • :OC (Hash)

    An optional content group or optional content membership dictionary

Returns:

  • (options)
Source Code
lib/pdf/core/annotations.rb, line 50
50
def annotate(options)
51
  state.page.dictionary.data[:Annots] ||= []
52
  options = sanitize_annotation_hash(options)
53
  state.page.dictionary.data[:Annots] << ref!(options)
54
  options
55
end

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.

A convenience method for creating Link annotations.

Parameters:

  • rect (Array<Numeric>)

    An array of four numbers, describing the bounds of the annotation.

  • options (Hash) (defaults to: {})

    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).

Returns:

  • (Hash)

    Annotation dictionary

Source Code
lib/pdf/core/annotations.rb, line 79
79
def link_annotation(rect, options = {})
80
  options = options.merge(Subtype: :Link, Rect: rect)
81
  annotate(options)
82
end

#text_annotation(rect, contents, options = {}) ⇒ Hash

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.

A convenience method for creating Text annotations.

Parameters:

  • rect (Array<Numeric>)

    An array of four numbers, describing the bounds of the annotation.

  • contents (String)

    Contents of the annotation

Returns:

  • (Hash)

    Annotation dictionary

Source Code
lib/pdf/core/annotations.rb, line 64
64
def text_annotation(rect, contents, options = {})
65
  options = options.merge(Subtype: :Text, Rect: rect, Contents: contents)
66
  annotate(options)
67
end