Reputation: 4429
I'm having issues while trying to generate PDFs using PDFKit. If issue the following commands on console:
kit = PDFKit.new("http://localhost:3000/invoices/57f0bf61fc7b3415fc000000")
followed by
kit.to_file("pdfs/invoices/57f0bf61fc7b3415fc000000.pdf")
Everything works fine and the file is generated. Now if I have the same code in a controller, the pdf generation hangs on step 1 and no error is displayed.
If I try wkhtmltopdf http://localhost:3000/invoices/ivoice_id invoice.pdf
it also works.
Why is that? More importantly, how to fix it?
I'm using Rails 4.
Upvotes: 1
Views: 967
Reputation: 1245
Check https://github.com/pdfkit/pdfkit#troubleshooting
If you have some assets in that template that should be served by your local server, then in development in may hang depending on your server configuration. Your current request to render PDF "blocks" the server and it cannot respond to subsequent requests for assets (images, css, js). If possible, serve them from CDN, use multi-process server config in development etc.
Upvotes: 4