Skip to content

using pdf template instead of default html template #127

Closed
otty opened this Issue Feb 15, 2012 · 4 comments

4 participants

@otty
otty commented Feb 15, 2012

Hi,

i know pdfkit focus on creating pdf from default views, but does anyone know how to render views from "show.pdf.slim" or "index.pdf.slim" instead of "show.html.slim" when requesting a pdf via the middleware? i'm looking for a global solution for the entire app. If there is an xyz.pdf.slim as view, this one should prefered instead of the default view.

to be more specific, when using the middleware, the following does not work anymore ( as by default )

    respond_to do |format|
      format.html
      format.pdf
    end
it would be nice to have that done globaly ( like prepared with the mime-type registration )
any ideas?

regards,
Adrian

@mdeering
pdfkit member

Check for the environment variable env["Rack-Middleware-PDFKit"] and render your pdf view based on it. being present or not.

@otty
otty commented Feb 17, 2012

Thx for the answer. But as i wrote, i'm looking for a solution for the entire app, like rendering pdf templates all the time instead of the html templates. any idea how to configure rails to use pdf templates instead of html templates?

@metaskills

I thought views in Rails all the way back to 2.3 could have multiple mime types. I did an article here where I talked about this. Look for view.html.pdf.haml for the section I describe this behavior. Does this no longer work in Rails 3.2?

@sigmavirus24
pdfkit member

There has been no response to a solution that appears as if it should work. If others encounter something like this, feel free to ping us here and we'll reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.