Class: Pdfrb::Model::Type::GenericAppearance
- Inherits:
-
Object
- Object
- Pdfrb::Model::Type::GenericAppearance
- Defined in:
- lib/pdfrb/model/type/generic_appearance.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#annotation ⇒ Object
readonly
Returns the value of attribute annotation.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
- #create_appearance ⇒ Object
-
#initialize(annotation, document) ⇒ GenericAppearance
constructor
A new instance of GenericAppearance.
Constructor Details
#initialize(annotation, document) ⇒ GenericAppearance
Returns a new instance of GenericAppearance.
9 10 11 12 |
# File 'lib/pdfrb/model/type/generic_appearance.rb', line 9 def initialize(annotation, document) @annotation = annotation @document = document end |
Instance Attribute Details
#annotation ⇒ Object (readonly)
Returns the value of attribute annotation.
7 8 9 |
# File 'lib/pdfrb/model/type/generic_appearance.rb', line 7 def annotation @annotation end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
7 8 9 |
# File 'lib/pdfrb/model/type/generic_appearance.rb', line 7 def document @document end |
Instance Method Details
#create_appearance ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pdfrb/model/type/generic_appearance.rb', line 14 def create_appearance rect = annotation[:Rect] return nil unless rect.is_a?(::Array) && rect.length == 4 x0, y0, x1, y1 = rect width = (x1 - x0).abs height = (y1 - y0).abs return nil if width.zero? || height.zero? stream = document.add( { Type: :XObject, Subtype: :Form, BBox: [0, 0, width, height], Matrix: [1, 0, 0, 1, 0, 0], Length: 0, }, type: Pdfrb::Model::Cos::Stream ) stream.stream = "q Q\n" annotation[:AP] = { N: Pdfrb::Model::Reference.new(stream.oid, stream.gen) } stream end |