ruby on rails - wkhtmltopdf error when generating pdf with lots of pages with header / footer -


i using pdfkit (which uses wkhtmltopdf under hood) generate pdfs in rails app. following guide here i've gotten working basic cases of pdfs. running issue when attempting generate pdf lots of pages thats has headers/footers. error see wkhtmltopdf in console when attempting generate pdf is:

qeventdispatcherunixprivate(): unable create thread pipe: many open files qeventdispatcherunixprivate(): can not continue without thread pipe 

a minimal example of html can used recreate error:

<!-- content of pdf_header_url character "h" --> <meta content="<%= pdf_header_url %>" name="pdfkit-header-html"/> <!-- content of pdf_footer_url character "f" --> <meta content="<%= pdf_footer_url %>" name="pdfkit-footer_html"/> <% [*1..3].each |j|%>   <h1><%= j %></h1>   <ul>     <% [*1..1000].each |i|%>       <li><%= %></li>     <% end %>   </ul> <% end %> 

note removing of headers/footers tags allows pdf render fine.

the actual ruby code generate pdf is:

def view_report   html = render_to_string(:template => 'pdf/pdf_body.html', :layout => false)   kit = pdfkit.new(html)   pdf = kit.to_pdf   send_data pdf, :type => 'application/pdf', :disposition => 'inline', :filename => 'foo.pdf' end 

visiting controllers route generate pdf. , lastly, have controller header/footer, since "partials" need fetchable via url:

class pdfcontroller < applicationcontroller    def header     render :layout => false   end    def footer     render :layout => false   end  end 

the values of pdf_header_url , pdf_footer_url literally "h" , "f" sake of minimal reproducible example.

does familiar wkhtmltopdf have recommendations on furthur debug steps take around issue?

i getting same error message today , solved problem easy solution. problem header , footer needed complete html documents html, head , body tags. also, see if can generated html output of header , footer , validate them.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -