Class: HexaPDF::Writer
- Inherits:
-
Object
- Object
- HexaPDF::Writer
- Defined in:
- lib/hexapdf/writer.rb
Overview
Writes the contents of a PDF document to an IO stream.
Class Method Summary collapse
-
.write(document, io) ⇒ Object
Writes the document to the IO object.
Instance Method Summary collapse
-
#initialize(document, io) ⇒ Writer
constructor
Creates a new writer object for the given HexaPDF document that gets written to the IO object.
-
#write ⇒ Object
Writes the document to the IO object.
Constructor Details
#initialize(document, io) ⇒ Writer
Creates a new writer object for the given HexaPDF document that gets written to the IO object.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hexapdf/writer.rb', line 51 def initialize(document, io) @document = document @io = io @io.binmode @io.seek(0, IO::SEEK_SET) # TODO: incremental update! @serializer = Serializer.new @rev_size = 0 end |
Class Method Details
.write(document, io) ⇒ Object
Writes the document to the IO object.
45 46 47 |
# File 'lib/hexapdf/writer.rb', line 45 def self.write(document, io) new(document, io).write end |
Instance Method Details
#write ⇒ Object
Writes the document to the IO object.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/hexapdf/writer.rb', line 63 def write @serializer.encrypter = @document.encrypted? ? @document.security_handler : nil write_file_header pos = nil @document.trailer.info[:Producer] = "HexaPDF version #{HexaPDF::VERSION}" @document.revisions.each do |rev| pos = write_revision(rev, pos) end end |