class HexaPDF::Document::Annotations

Parent
Included Modules

This class provides methods for creating and managing the annotations of a PDF file.

An annotation is an object that can be added to a certain location on a page, provides a visual appearance and allows for interaction with the user via keyboard and mouse.

Usage

To create an annotation either call the general create method or a specific creation method for an annotation type. After the annotation has been created customize it using the convenience methods on the annotation object. The last step should be the call to regenerate_appearance so that the appearance is generated.

See: PDF2.0 s12.5

Public Class Methods

new(document)

Creates a new Annotations object for the given PDF document.

Public Instance Methods

create(type, page, **options) → annotation

Creates a new annotation object with the given type and page by calling the respective create_type method.

The options are passed on the specific annotation creation method.

create_line(page, start_point:, end_point:) → annotation

Creates a line annotation from start_point to end_point on the given page and returns it.

The line uses a black color and a width of 1pt. It can be further styled using the convenience methods on the returned annotation object.

Example:

doc.annotations.create_line(doc.pages[0], start_point: [100, 100], end_point: [130, 180]).
  border_style(color: "blue", width: 2).
  leader_line_length(10).
  regenerate_appearance

See: Type::Annotations::Line