Gemfile
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary', '~> 0.12.5'
Controller:
def pdf_list
@lists = Domain.select(:domain_name, :ip_address, :priority)
respond_to do |format|
format.pdf do
render pdf: "pdf",
margin: {:top => 20, :bottom => 18},
page_size: 'A4',
template: 'domains/list.pdf.erb',
disposition: 'inline',
footer: {html: {template: 'domains/footer.pdf.erb'}}
end
end
end
I have generated the html file to pdf file using wicked_pdf in rails.
Without rendering footer i can able to generate pdf for more than 300 pages.
If i am including footer with content pdf file is not generating for more than 200 pages using wicked_pdf.
Errors:
RuntimeError in DomainListsController#pdf_list Failed to execute: ["/usr/local/bin/wkhtmltopdf", "--page-size", "A4", "--margin-top", "20", "--margin-bottom", "18", "--footer-html", "file:////var/folders/v6/_516wg4d5rsdrhlb5sn82fbc0000gp/T/wicked_footer_pdf20191206-1975-o5qou2.html", "file:////var/folders/v6/_516wg4d5rsdrhlb5sn82fbc0000gp/T/wicked_pdf20191206-1975-16o6tkk.html", "/var/folders/v6/_516wg4d5rsdrhlb5sn82fbc0000gp/T/wicked_pdf_generated_file20191206-1975-1u66u16.pdf"] Error: PDF could not be generated! Command Error: Loading pages (1/6) [> ] 0% [======> ] 10% [==============================> ] 50% [==============================> ] 50%
In log files:
Error: Failed to load file:////var/folders/v6/_516wg4d5rsdrhlb5sn82fbc0000gp/T/wicked_footer_pdf20191206-1975-o5qou2.html?page=274§ion=FULL ASSET REPORT&sitepage=274&title=FULL ASSETS REPORT&subsection=&frompage=1&subsubsection=&isodate=2019-12-06&topage=275&doctitle=FULL ASSETS REPORT&sitepages=275&webpage=file:////var/folders/v6/_516wg4d5rsdrhlb5sn82fbc0000gp/T/wicked_pdf20191206-1975-16o6tkk.html&time=11:07 AM&date=06/12/19, with network status code 201 and http status code 0 - Error opening //var/folders/v6/_516wg4d5rsdrhlb5sn82fbc0000gp/T/wicked_footer_pdf20191206-1975-o5qou2.html: Too many open files Error: Failed loading page file:////var/folders/v6/_516wg4d5rsdrhlb5sn82fbc0000gp/T/wicked_footer_pdf20191206-1975-o5qou2.html?page=274§ion=FULL ASSET REPORT&sitepage=274&title=FULL ASSETS REPORT&subsection=&frompage=1&subsubsection=&isodate=2019-12-06&topage=275&doctitle=FULL ASSETS REPORT&sitepages=275&webpage=file:////var/folders/v6/_516wg4d5rsdrhlb5sn82fbc0000gp/T/wicked_pdf20191206-1975-16o6tkk.html&time=11:07 AM&date=06/12/19 (sometimes it will work just to ignore this error with --load-error-handling ignore)
footer.pdf.erb
tolist.pdf.erb
as footer. Please check this method once, you will figure out the error. – Santosh Aryalshow_as_html: true
– Santosh Aryal