karnov / htmltoword

Ruby html to word gem
MIT License
177 stars 70 forks source link

Сan't convert large file (~100k rows in HTML) #79

Open YuraAfanasyev opened 5 years ago

YuraAfanasyev commented 5 years ago

When I try to convert a large file (~100k rows in HTML), I get an error: stack level too deep my code is:

respond_to do |format|
  format.docx do
    render docx: 'report', filename: "report.docx"
  end
end

Small files are generated perfectly.

If I change the code to this:

respond_to do |format|
  format.docx do
    html = render_to_string template: 'report', formats: :docx
    result = Htmltoword::Document.create(html)
    send_data result, type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", filename: "report.docx"
  end
end

then the rails server is stopped with error:

/Users/developer/.rvm/gems/ruby-2.5.1@plutus/gems/htmltoword-1.1.0/lib/htmltoword/document.rb:104: [BUG] Illegal instruction at 0x00007fff7164f5e2
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:                    
     * ~/Library/Logs/DiagnosticReports                                     
     * /Library/Logs/DiagnosticReports                                      
   for more details.                                                        
Don't forget to include the above Crash Report log file in bug reports.     

-- Control frame information -----------------------------------------------
c:0112 p:---- s:0851 e:000850 CFUNC  :transform
...

I tried using different versions of rails and ruby, but this does not work. Other gems, such as pandoc-ruby, convert such large files, but text formatting does not work in them.

JenniferSpry commented 5 years ago

We have the same issue. @YuraAfanasyev have you found a solution yet?

JenniferSpry commented 5 years ago

Just found a workaround in this issue: https://github.com/karnov/htmltoword/issues/50