Class: HexaPDF::Type::Annotations::Ink
- Inherits:
-
MarkupAnnotation
- Object
- Object
- Dictionary
- HexaPDF::Type::Annotation
- MarkupAnnotation
- HexaPDF::Type::Annotations::Ink
- Includes:
- BorderStyling
- Defined in:
- lib/hexapdf/type/annotations/ink.rb
Overview
An ink annotation is a markup annotation that displays a freehand “scribble” composed of one or more disjoint paths.
The convenience method #add_path can be used to add paths to the annotation.
The style of the scribble can be customized using the convenience methods Annotation#opacity and BorderStyling#border_style (note that only a simple line dash pattern is supported).
Example:
#>pdf-small
doc.annotations.create_scribble(doc.pages[0]).
add_path(10, 10, 50, 40, 40, 80, 80, 60).
add_path(5, 90, 20, 90, 15, 50, 80, 5).
border_style(color: "hp-blue", width: 2, style: [3, 1]).
regenerate_appearance
See: PDF2.0 s12.5.6.13, HexaPDF::Type::MarkupAnnotation
Constant Summary
Constants included from DictionaryFields
DictionaryFields::Boolean, DictionaryFields::PDFByteString, DictionaryFields::PDFDate
Instance Attribute Summary
Attributes inherited from Object
#data, #document, #must_be_indirect
Instance Method Summary collapse
-
#add_path(*points) ⇒ Object
:call-seq: annot.add_path => [x0, y0, x1, y1, …] annot.add_path(*points) => annot.
-
#paths ⇒ Object
:call-seq: annot.paths => [[x00, y00, x01, y01, …], [x10, y10, x11, y11, …], …].
Methods included from BorderStyling
Methods inherited from HexaPDF::Type::Annotation
#appearance, #appearance_dict, #contents, #create_appearance, #flags, #must_be_indirect?, #opacity, #regenerate_appearance
Methods included from Utils::BitField
Methods inherited from Dictionary
#[], #[]=, define_field, define_type, #delete, #each, each_field, #empty?, field, #key?, #to_hash, type, #type
Methods inherited from Object
#<=>, #==, #cache, #cached?, #clear_cache, deep_copy, #deep_copy, #document?, #eql?, field, #gen, #gen=, #hash, #indirect?, #initialize, #inspect, make_direct, #must_be_indirect?, #null?, #oid, #oid=, #type, #validate, #value, #value=
Constructor Details
This class inherits a constructor from HexaPDF::Object
Instance Method Details
#add_path(*points) ⇒ Object
:call-seq:
annot.add_path => [x0, y0, x1, y1, ...]
annot.add_path(*points) => annot
Adds the path consisting of the given points to the list of paths and returns self.
Adding at least one path is required. Note, however, that without setting the appearance style through convenience methods like #border_style nothing will be shown.
Example:
#>pdf-small
doc.annotations.create_scribble(doc.pages[0]).
add_path(10, 10, 40, 60, 90, 90).
regenerate_appearance
93 94 95 96 97 98 99 100 101 |
# File 'lib/hexapdf/type/annotations/ink.rb', line 93 def add_path(*points) if points.length % 2 != 0 raise ArgumentError, "An even number of arguments must be provided" else self[:InkList] ||= [] self[:InkList] << points self end end |
#paths ⇒ Object
:call-seq:
annot.paths => [[x00, y00, x01, y01, ...], [x10, y10, x11, y11, ...], ...]
Returns an array with all the paths of this annotation.
74 75 76 |
# File 'lib/hexapdf/type/annotations/ink.rb', line 74 def paths self[:InkList].to_a end |