Class: HexaPDF::Type::Annotations::AppearanceGenerator
- Inherits:
-
Object
- Object
- HexaPDF::Type::Annotations::AppearanceGenerator
- Defined in:
- lib/hexapdf/type/annotations/appearance_generator.rb
Overview
The AppearanceGenerator class provides methods for generating the appearance streams of annotations except those for widgets (see HexaPDF::Type::AcroForm::AppearanceGenerator for those).
There is one private create_TYPE_appearance method for each annotation type. This allows subclassing the appearance generator and adjusting the appearances to one’s needs.
By default, an existing appearance is overwritten and the :print
flag is set as well as the :hidden
flag unset on the annotation so that the appearance will appear on print-outs.
Also note that the annotation’s /Rect entry is modified so that it contains the whole generated appearance.
The visual appearances are chosen to be similar to those used by Adobe Acrobat and others. By subclassing and overriding the necessary methods it is possible to define custom appearances.
The default annotation appearance generator for a document can be changed using the ‘annotation.appearance_generator’ configuration option.
See: PDF2.0 s12.5
Instance Method Summary collapse
-
#create_appearance ⇒ Object
Creates the appropriate appearance for the annotation provided on initialization.
-
#initialize(annotation) ⇒ AppearanceGenerator
constructor
Creates a new instance for the given
annotation
.
Constructor Details
#initialize(annotation) ⇒ AppearanceGenerator
Creates a new instance for the given annotation
.
67 68 69 70 |
# File 'lib/hexapdf/type/annotations/appearance_generator.rb', line 67 def initialize(annotation) @annot = annotation @document = annotation.document end |
Instance Method Details
#create_appearance ⇒ Object
Creates the appropriate appearance for the annotation provided on initialization.
73 74 75 76 77 78 79 |
# File 'lib/hexapdf/type/annotations/appearance_generator.rb', line 73 def create_appearance case @annot[:Subtype] when :Line then create_line_appearance else raise HexaPDF::Error, "Appearance regeneration for #{@annot[:Subtype]} not yet supported" end end |