Module: Docx::Builder::Encoder

Defined in:
lib/docx/builder/encoder.rb

Overview

Rebuild the docx file using the new xml strings for header and document

Class Method Summary collapse

Class Method Details

.build_docx_buffer(original_document, new_document_sections) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/docx/builder/encoder.rb', line 7

def self.build_docx_buffer(original_document, new_document_sections)
  Zip::OutputStream.write_buffer(StringIO.new) do |out|
    original_document.each do |entry|
      entry_name = entry.name
      out.put_next_entry(entry_name)
      out.write(new_document_sections[entry_name] || entry.get_input_stream.read)
    end
  end
end