Class: PDF::Writer::Object::Outline
- Inherits:
-
PDF::Writer::Object
- Object
- PDF::Writer::Object
- PDF::Writer::Object::Outline
- Defined in:
- lib/extensions/pdf-writer/pdf/writer/object/outline.rb
Overview
Define the outlines in the doc, empty for now
Instance Attribute Summary
Attributes inherited from PDF::Writer::Object
Instance Method Summary collapse
-
#initialize(parent, label, title = label) ⇒ Outline
constructor
A new instance of Outline.
- #to_s ⇒ Object
Constructor Details
#initialize(parent, label, title = label) ⇒ Outline
Returns a new instance of Outline.
13 14 15 16 17 18 19 20 |
# File 'lib/extensions/pdf-writer/pdf/writer/object/outline.rb', line 13 def initialize(parent, label, title = label) super(parent) @action = PDF::Writer::Action.new(parent, label, :ilink) @title = title parent.outlines.list << self end |
Instance Method Details
#to_s ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/extensions/pdf-writer/pdf/writer/object/outline.rb', line 22 def to_s pos = @parent.outlines.list.index(self) res = "\n#{@oid} 0 obj\n<< /Title (#{@title})" res << " /Prev #{@parent.outlines.list[pos - 1].oid} 0 R" if pos.nonzero? res << " /Next #{@parent.outlines.list[pos + 1].oid} 0 R" if @oid != parent.outlines.list[-1].oid res << " /A #{@action.oid} 0 R>>\nendobj" res end |