We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Disable the PDFKit middleware so that your controller handles the generation of the PDF.
Register PDF as a mime-type in environment.rb Mime::Type.register "application/pdf", :pdf
Mime::Type.register "application/pdf", :pdf
In your controller, cache pages just like normal with caches_page :show
caches_page :show
create a format.pdf call in your respond_to block and init a new PDFKit object, pass in the url to the current action and call to_pdf on it.
to_pdf
respond_to do |format| format.html # show.html.erb format.pdf { render :text => PDFKit.new( post_url(@post) ).to_pdf } end
Now in your cache directory you'll create two cache files - one .html and one .pdf.
.html
.pdf