![pdfkit rails pdfkit rails](https://i.stack.imgur.com/0j9jO.jpg)
pdf” to any of our application’s URLs to get a PDF version of that page.
![pdfkit rails pdfkit rails](https://i.stack.imgur.com/nrvDt.jpg)
Your PDF will be displayed on the browser. Now you can find the PDF file being generated on the file path. Now to generate the pdf file by writing down the following codes on one of your controller actions kit = PDFKit.new"HelloThis is PDF!!!" Write the following in the “ config/application.rb” require 'pdfkit' # config.root_url = " # Use only if your external hostname is unavailable on the server. nfigure do |config|Ĭonfig.wkhtmltopdf = 'C:Program Fileswkhtmltopdfwkhtmltopdf. If you are in linux and the path is set as the default path then you don’t need to give the path. If you are in windows then you need to give the path to the exe file generated after installation. Extract the file to a directory that is in your PATH, such as /opt or /usr/local/bin and run from there.įor Debian/Ubuntu use the following command: apt-get install wkhtmltopdfĬreate a new file “pdfkit.rb” in “config/initializers/” path and write the following.
I have aDownload the binary for your architecture at the I took a look on this : pdfkit Usage and it works to save any website to PDF.I have used rails 3.2.8 and ruby 1.9.3 as my environment.ĭownload the “wkhtmltopdf” library from the link Here is a simple example which describes the installation of “wkhtmltopdf” and usages of pdfkit. It uses “wkhtmltopdf” on the back-end which renders HTML using Webkit. PDFkit is a powerful library which generates PDF from HTML + CSS.