To install and use wicked_pdf try articles like below.
Here when using wicked pdf internally it uses wkhtmltopdf binary to convert HTML to PDF. When one process uses this binary others have to wait until the operation is done. When creating multiple PDF files concurrently in rails background jobs we seen it take lot of time to generate PDF.
So the idea is to move this part alone to some server-less solutions. We are using Google cloud function
Create a folder pdf-generator and then add Gemfile
mkdir pdf-generation
cd pdf-generation
touch Gemfile
touch app.rb
# download wkhtmltopdf linux binary and put it inside this folder
run this command bundle exec functions-framework-ruby --target create
Then you host it to google cloud functions and change the url in production. Since it is autoscaled we generated upto 1,00 PDF concurrently. We generate around 200K PDF files per month which cost around less than $2 including discounts.
Notes:
It's 2024 wkhtmltopdf has been deprecated and there is also a discussion in wicked_pdf gem about this. Use it if you don't have any other choice.
Thanks for the above article authors and Thanks for reading!