ruby-docx/docx

Zlib buffer error

abartov opened this issue · 1 comments

Hello.

I'm trying to use the gem to make a simple edit to some paragraphs in a docx file. The processing goes well, but when attempting to call #save on the document object, I get a Zlib buffer error, with the following stack trace:

["ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/inflater.rb:44:in `inflate'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/inflater.rb:44:in `internal_produce_input'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/inflater.rb:15:in `sysread'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/input_stream.rb:82:in `sysread'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/ioextras/abstract_input_stream.rb:33:in `read'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/file.rb:264:in `block in read'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/entry.rb:501:in `get_input_stream'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/file.rb:232:in `get_input_stream'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/file.rb:264:in `read'", "ruby-2.3.4/gems/docx-0.3.0/lib/docx/document.rb:110:in `block (2 levels) in save'", "ruby-2.3.4/gems/rubyzip-1.2.1/lib/zip/entry_set.rb:38:in `block in each'"]

Any ideas on what the problem may be?

Oh, never mind. I realized that #save reads from the original file rather than write it from memory, which makes it impossible to overwrite the file in-place. It is probably worth warning against this in the documentation.