This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Corrupted file using Ruby Wrapper with REE 1.8.7

rafaelp wrote on 2010-07-09:
When I use the example below, the file written is corrupted.
client.convertHtml(inMemoryHtml, open('html.pdf', 'wb'))
Changing to the line below doesn't work too
client.convertHtml(inMemoryHtml, open('html.pdf', 'w'))

It only works when I wrote these lines:

file_contents = client.convertHtml(inMemoryHtml)'html.rb', 'w') {|f| f.write(file_contents) }

I'm using ree-1.8.7
support wrote on 2010-07-09:
Thanks for the report.

The problem with our example is that it does not close the file. While it might work sometimes, it is safer to call the API like this:'html.pdf', 'wb') {|f| client.convertHtml(inMemoryHtml, f)}

Does this work for you?