Rails 3, Wicked_pdf not picking up styles, print media type, or separate template
Asked Answered
D

1

6

So I've been banging my head on this all day yesterday trying to get PDF rendering to work properly. After trying Prawn and PDFKit, I found that the problem with at least getting it to work at all had to do with wkhtmltopdf on Mac OS 10.7, but now the problem is that it completely ignores any styles I add targeting the pdf, the print media type, and any special templates.

Here is a pastebin of where I'm at now: http://pastebin.com/LW16RYjW

Trying all of these and several others didn't work for me:

  1. http://www.snikt.net/blog/2012/04/26/wicked-pdf/
  2. WickedPDF missing layout
  3. http://akabhilash.wordpress.com/2010/11/27/pdf-generation-with-wicked-pdf-in-rails/

I finally got to this setup:

Not knowing what else to do, I physically copied pdf_helper.rb into my lib/ directory (I don't know why it wasn't there before, or even whether it should've been upon bundling(?))

Can anyone tell me why it doesn't seem to be picking up any of the rendering options in the controller, and how I can get the styles to register without affecting the screen (html) version? Any help would be greatly appreciated. Thanks in advance for your time.

Dispersal answered 17/1, 2013 at 21:36 Comment(1)
For others that might run into this, you have to set :print_media_type => true as a config option when rendering. WickedPDF doesn't do this by default.Lynettalynette
A
0

Turn off the middleware, or add the route you are trying to customize in the middleware call as documented in the README.

Aoristic answered 19/1, 2013 at 0:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.