Add this line to your application's Gemfile:
gem 'wicked_pdf_standalone'
And then execute:
$ bundle
Or install it yourself as:
$ gem install wicked_pdf_standalone
Here is example usage, with draper:
$ output_path = File.join("/tmp", "file.pdf")
$ @subject = Model.find(1)
$ @pdf_renderer_instance = WkPdfRenderer.new
$ @pdf_renderer_instance.to_file(output_path, subject.some_default_pdf_renderer_options) do |renderer|
$ renderer.instance_variable_set("@subject", SubjectDecorator.decorate(@subject))
$ end
And if you want to spit out a file, right away:
$ save_path = Rails.root.join("filename.pdf")
$ file = File.open(save_path, 'wb') do |file|
$ file << @pdf_renderer_instance.send(:make_pdf)
$ end
$
$ Developed during open-source day at Selleo web & mobile software development house - http://selleo.com
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request