Class: Wizport::Pdf::Document
- Defined in:
- lib/wizport/document/pdf/document.rb
Instance Attribute Summary collapse
-
#objs ⇒ Object
readonly
Returns the value of attribute objs.
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #make_id ⇒ Object
- #save(file) ⇒ Object
- #to_pdf ⇒ Object
Methods inherited from Element
#dict, #parent, #stream, #to_s, #type
Methods included from Visitable
Constructor Details
#initialize ⇒ Document
Returns a new instance of Document.
10 11 12 13 14 15 16 17 |
# File 'lib/wizport/document/pdf/document.rb', line 10 def initialize @objs = [] @objs << @catalog = Catalog.new(make_id, 0) @objs << @pages = Pages.new(make_id, 0) @catalog.dict '/Pages', @pages @objs << @page = Page.new(make_id, 0) @page.dict '/Parent', @pages end |
Instance Attribute Details
#objs ⇒ Object (readonly)
Returns the value of attribute objs.
9 10 11 |
# File 'lib/wizport/document/pdf/document.rb', line 9 def objs @objs end |
Instance Method Details
#make_id ⇒ Object
19 20 21 |
# File 'lib/wizport/document/pdf/document.rb', line 19 def make_id @objs.size + 1 end |
#save(file) ⇒ Object
29 30 31 |
# File 'lib/wizport/document/pdf/document.rb', line 29 def save(file) File.open(file, 'w') { |file| file.write(to_pdf) } end |
#to_pdf ⇒ Object
23 24 25 26 27 |
# File 'lib/wizport/document/pdf/document.rb', line 23 def to_pdf builder = PdfBuilder.new accept(builder) builder.to_pdf end |