Skip to content

Commit

Permalink
Merge pull request #92 from hebron-george/generate_simple_lease
Browse files Browse the repository at this point in the history
PDF Gems included
  • Loading branch information
hebron-george authored Jul 22, 2019
2 parents 7a6a36b + 970d7ef commit 1d831b0
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ gem 'sidekiq'
gem 'sidekiq-cron'
gem 'pry-rails'

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'bcrypt', '3.1.12'
Expand Down
7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ GEM
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
wicked_pdf (1.4.0)
activesupport
will_paginate (3.1.6)
wkhtmltopdf-binary (0.12.4)
xpath (3.1.0)
nokogiri (~> 1.8)

Expand Down Expand Up @@ -306,10 +309,12 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
wicked_pdf
will_paginate
wkhtmltopdf-binary

RUBY VERSION
ruby 2.5.1p57

BUNDLED WITH
1.16.6
1.17.1
9 changes: 9 additions & 0 deletions app/controllers/leases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ def create
# GET /properties/:property_id/leases/1
# GET /properties/:property_id/leases/1.json
def show
respond_to do |format|
format.html
format.pdf do
render :pdf => "Lease #{@lease.start_date.year} - #{@lease.property.display_name}",
:layout => "pdf.html",
:page_size => 'A4',
:template => "leases/show.html.erb"
end
end
end

# GET /properties/:property_id/leases/1/edit
Expand Down
9 changes: 9 additions & 0 deletions app/views/layouts/pdf.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Happy House</title>
</head>
<body>
<%= yield %>
</body>
</html>
21 changes: 21 additions & 0 deletions config/initializers/wicked_pdf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# WickedPDF Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `render :pdf` call.
#
# To learn more, check out the README:
#
# https://github.com/mileszs/wicked_pdf/blob/master/README.md

WickedPdf.config = {
# Path to the wkhtmltopdf executable: This usually isn't needed if using
# one of the wkhtmltopdf-binary family of gems.
# exe_path: '/usr/local/bin/wkhtmltopdf',
# or
# exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')

# Layout file to be used for all PDFs
# (but can be overridden in `render :pdf` calls)
# layout: 'pdf.html',
}

0 comments on commit 1d831b0

Please sign in to comment.