I recently updated one of my apps to Rails 3.1 and found that my PDF generating tests were failing because they were unable to find the CSS or images to use in the PDF.
So I started playing around, and here is what I got:
In your app, add a new initializer (or edit your existing wicked_pdf.rb initializer) and put the following:
As you can see in the code, I also replaced the background urls with correct references, this is assuming that you’re keeping your CSS images in the same location as your normal images (which I don’t see a reason why not but of course you can always tweak the script)
I had one issue with my generated PDF using pow.cx, my CPU would jump to 100% (on the pow process) and the page would timeout. After upgrading to the latest version of pow (0.3.2) using this command:
curl get.pow.cx | sh
I was able to see my PDFs without an issue.
Small change to the above code to fix issue that prevented CSS from being rendered correctly.