Class: Pdfrb::Annotation::Base
- Inherits:
-
Object
- Object
- Pdfrb::Annotation::Base
- Defined in:
- lib/pdfrb/annotation/base.rb
Overview
Base annotation builder. Subclasses override subtype and
default_fields to provide type-specific defaults. Each subclass
calls register_as at load time.
Direct Known Subclasses
Caret, Circle, FileAttachment, FreeText, Highlight, Ink, Line, Link, Polygon, Polyline, Popup, PrinterMark, Redact, Screen, Sound, Square, Squiggly, Stamp, StrikeOut, Text, Underline, Watermark, Widget
Class Method Summary collapse
-
.create(document:, page:, rect:, **opts) ⇒ Object
Create the annotation and attach it to the page's /Annots.
-
.default_fields ⇒ Hash
Extra fields to merge into the annotation dict.
-
.register_as(symbol = subtype) ⇒ Object
Register this class in the Annotation registry.
-
.subtype ⇒ Symbol
The /Subtype value (e.g. :Link).
Class Method Details
.create(document:, page:, rect:, **opts) ⇒ Object
Create the annotation and attach it to the page's /Annots.
22 23 24 25 26 27 |
# File 'lib/pdfrb/annotation/base.rb', line 22 def create(document:, page:, rect:, **opts) dict = base_dict(page: page, rect: rect, **opts).merge!(default_fields).merge!(type_overrides(opts)) annot = document.add(dict, type: Pdfrb::Model::Type::Annotation) attach_to_page(page, annot) annot end |
.default_fields ⇒ Hash
Extra fields to merge into the annotation dict.
17 18 19 |
# File 'lib/pdfrb/annotation/base.rb', line 17 def default_fields {} end |
.register_as(symbol = subtype) ⇒ Object
Register this class in the Annotation registry.
30 31 32 33 |
# File 'lib/pdfrb/annotation/base.rb', line 30 def register_as(symbol = subtype) Annotation.register(symbol, self) self end |
.subtype ⇒ Symbol
Returns the /Subtype value (e.g. :Link).
11 12 13 |
# File 'lib/pdfrb/annotation/base.rb', line 11 def subtype raise NotImplementedError, "#{self} must define subtype" end |