1/3/2024 0 Comments Pdfkit rails![]() #if your site is hosted on heroku or any other hosting server which is 64bitĬonfig.wkhtmltopdf = ('bin', 'wkhtmltopdf-amd64').to_sĭownload these 2 files: (I will explain the reason in the next section) #only if your are working on 32bit machineĬonfig.wkhtmltopdf = ('bin', 'wkhtmltopdf-i386').to_s ![]() Mime::Type.register 'application/pdf', :pdfĬreate a file config/initializers/pdfkit.rb with these contents Since you want the output in pdf format, include this in the config/environment.rb In config/application.rb, include following piece of codeĬ PDFKit::Middleware, :print_media_type => true Update your Gemfile with gem ‘pdfkit’, ‘0.5.0’ and do bundle install or if your doing it from the command line do gem install pdfkit . Prawn restricts you to the old table, grids layout.PDFKit is very simple to understand and it gets your job done very quickly if you follow all the right steps, which of course I did not □.I prefer using PDFKit over Prawn for couple of reasons. The bottom line is that converting html to pdf is no more rocket science. There are numbers of gems out there to convert html to pdf in rails like PDFKit and Prawn (among the popular gems). What has made our job easier is the number of gems out there but every gem is different from another in some or the other. convert reports, tickets or any other page for that matter into the PDF format ‘as is’. One of the common requirements we face across many Rails project is to convert HTML pages to PDF i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |