prawn-rails 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8087ba0ba0e0bfcbc51bfbc5e05c9847dcf65869
4
- data.tar.gz: 067355f7b11a01986b8ce5f5948598bc3e4536ae
3
+ metadata.gz: b70a70673f88cd5bc6641a1fdc903dfc3e5bc660
4
+ data.tar.gz: bcf5845b43ad53bde0cf4561c21e895254fd092a
5
5
  SHA512:
6
- metadata.gz: d62d8ecf3aed1aa63c100b2d6047a18c913d9fa323dbb8c63eb57c56f180c5673ce0bbdac141f8188fd491897dfe31ba8be5f2c6ac542764131477bb1b86e4b5
7
- data.tar.gz: 2a0ca3e83f4ab55dfa41487b3fd263c15a77c66679b649ac5b97bb062ba0031f3522f6796cd582082ee782df995dbd03c3a802e799415b942ea9206cd75272ba
6
+ metadata.gz: 2b37518f1272fde6439d16f66ef80e539a5b910d1ca0da559285ec3e1400572f0eadefbb2565ecbf0a0b09ddd5465bcac4086cc27314722cdefbdac016bdfd99
7
+ data.tar.gz: 4c93899f687a82e75e2280b23330faf0a30db791a2bc76322c1b866cc7ce46b5d378ced7b09634c143228b17381e30a9bdba64bff4f638502a2a77db61643b7c
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ * `v1.0.0` - January 21, 2017
4
+ - Support `@filename`
5
+ - Set PDF Title metadata based on `@filename` if not specified
6
+ - Fix for Ruby 1.9.3+
7
+ - Cleanup
8
+
9
+ * `v0.1.1` - January 12, 2015
10
+ * `v0.1.0` - October 7, 2014
11
+ * `v0.0.2` - February 22, 2012
12
+ * `v0.0.1` - February 21, 2012
@@ -1,4 +1,4 @@
1
- Copyright 2012 YOURNAME
1
+ Copyright 2012 Carlos Ortiz
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,92 @@
1
+ # Prawn-Rails [![Gem Version](https://badge.fury.io/rb/prawn-rails.svg)](http://badge.fury.io/rb/prawn-rails)
2
+ <a href='http://ko-fi.com/A552JBK' target='_blank'><img height='32' style='border:0px;height:32px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=a' border='0' alt='Buy Me a Coffee' /></a>
3
+
4
+ ## Install
5
+ ```ruby
6
+ gem 'prawn-rails'
7
+ ```
8
+
9
+ Note: `prawn` and `prawn-table` are dependencies of `prawn-rails` so there is no need to mention it in the projects Gemfile unless you want to use a specific version of either of those libraries.
10
+
11
+ ## Usage
12
+ Create a view with `pdf` as format and `prawn` as handler so filename should look like `example.pdf.prawn`
13
+
14
+ It provides a helper called `prawn_document` which builds a PrawnRails::Document with default options. You can override any options as you please. Example:
15
+
16
+ ```ruby
17
+ prawn_document(page_layout: :landscape) do |pdf|
18
+ pdf.text "Hello World"
19
+ end
20
+ ```
21
+
22
+ No need to call `pdf.render`, it is called by `prawn_document`
23
+
24
+ If you want to customize the name of the file should a user try to save it, you can specify the filename in your action:
25
+
26
+ ```ruby
27
+ def show
28
+ @filename = 'my_report.pdf'
29
+ end
30
+ ```
31
+
32
+ ## Built-in Helpers
33
+ * *html_strip(html)*:
34
+ Removes the html tags from a string
35
+
36
+ ## Default configuration
37
+
38
+ Add a `prawn-rails.rb` config to your Rails app under `config/initializers` like this
39
+
40
+ ```ruby
41
+ PrawnRails.config do |config|
42
+ config.page_layout = :portrait
43
+ config.page_size = "A4"
44
+ config.skip_page_creation = false
45
+ end
46
+ ```
47
+
48
+ Please note that these are the defaults.
49
+
50
+ For a list of all available options: [http://www.rubydoc.info/gems/prawn/Prawn%2FDocument:initialize](http://www.rubydoc.info/gems/prawn/Prawn%2FDocument:initialize).
51
+
52
+ For a list of all metadata the the `:info` option supports, please see [https://github.com/prawnpdf/prawn/blob/master/manual/document_and_page_options/metadata.rb](https://github.com/prawnpdf/prawn/blob/master/manual/document_and_page_options/metadata.rb)
53
+
54
+ If `skip_page_creation` is set to true then have to create the first page yourself for eg.
55
+
56
+ ```ruby
57
+ pdf.start_new_page size: "A4", page_layout: :landscape
58
+ ```
59
+
60
+ ## Examples
61
+
62
+ 1. **Hello World**
63
+
64
+ ```ruby
65
+ # hello.pdf.prawn
66
+
67
+ prawn_document(page_layout: :landscape) do
68
+ pdf.text 'Hello World!'
69
+ end
70
+ ```
71
+
72
+ 2. ** Using Active Record **
73
+
74
+ ```ruby
75
+ # myproducts.pdf.prawn
76
+
77
+ prawn_document do
78
+ pdf.text 'Current Products are:'
79
+ pdf.move_down 20
80
+ pdf.table @products.collect{|p| [p.name,p.price]}
81
+ end
82
+ ```
83
+
84
+ ## Credits
85
+
86
+ Created by Carlos Ortiz - @cortiz
87
+
88
+ <a href='http://ko-fi.com/A552JBK' target='_blank'><img height='32' style='border:0px;height:32px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=a' border='0' alt='Buy Me a Coffee' /></a>
89
+
90
+ Maintained by Weston Ganger - @westonganger
91
+
92
+ Special thanks to @rwilliams, @sigmike, @smber1, @iffyuva
data/Rakefile CHANGED
@@ -1,39 +1,15 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'PrawnRails'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
1
+ require File.expand_path(File.dirname(__FILE__) + '/lib/prawn-rails/version.rb')
2
+ require 'bundler/gem_tasks'
22
3
 
23
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
- load 'rails/tasks/engine.rake'
4
+ task :test do
5
+ require 'rake/testtask'
25
6
 
26
-
27
- Bundler::GemHelper.install_tasks
28
-
29
- require 'rake/testtask'
30
-
31
- Rake::TestTask.new(:test) do |t|
32
- t.libs << 'lib'
33
- t.libs << 'test'
34
- t.pattern = 'test/**/*_test.rb'
35
- t.verbose = false
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << 'lib'
9
+ t.libs << 'test'
10
+ t.pattern = 'test/**/*_test.rb'
11
+ t.verbose = false
12
+ end
36
13
  end
37
14
 
38
-
39
- task :default => :test
15
+ task default: :test
@@ -1,5 +1,6 @@
1
1
  require "prawn-rails/config"
2
2
  require "prawn-rails/engine"
3
+ require "prawn-rails/version"
3
4
 
4
5
  module PrawnRails
5
6
  end
@@ -1,11 +1,9 @@
1
1
  require 'ostruct'
2
2
 
3
3
  module PrawnRails
4
- extend self
4
+ extend self
5
5
 
6
- @config = OpenStruct.new(:page_layout => :portrait,
7
- :page_size => "A4",
8
- :skip_page_creation => false)
6
+ @config = OpenStruct.new(page_layout: :portrait, page_size: "A4", skip_page_creation: false)
9
7
 
10
8
  def config
11
9
  begin
@@ -14,9 +12,6 @@ extend self
14
12
  puts e
15
13
  puts e.backtrace
16
14
  end
17
-
18
15
  end
19
16
 
20
17
  end
21
-
22
-
@@ -3,23 +3,25 @@ require 'prawn/table'
3
3
  require "prawn-rails/extension"
4
4
 
5
5
  module PrawnRails
6
- # This derives from Prawn::Document in order to override defaults. Note
7
- # that the Prawn::Document behaviour itself shouldn't be changed.
6
+
7
+ # This derives from Prawn::Document in order to override defaults. Note that the Prawn::Document behaviour itself shouldn't be changed.
8
8
  class Document < Prawn::Document
9
9
  def initialize(opts = {})
10
- default = PrawnRails.config.to_h.merge(opts)
10
+ if PrawnRails.config.respond_to?(:to_h)
11
+ default = PrawnRails.config.to_h.merge(opts)
12
+ else
13
+ default = PrawnRails.config.marshal_dump.merge(opts)
14
+ end
11
15
  super(default)
12
16
  end
13
17
 
14
- # Typicall text expects a string. But rails views have this interesting
15
- # concept that they implicitly call `to_s` on all the variables before
16
- # rendering. So, passing an integer to text fails:
18
+ # Typically text expects a string. But rails views have this interesting concept that they implicitly call
19
+ # `to_s` on all the variables before rendering. So, passing an integer to text fails:
17
20
  #
18
21
  # pdf.text 10 #=> fails because 10 is not a string
19
22
  # pdf.text 10.to_s #=> works
20
23
  #
21
- # To circumvent this situation, we call to_s on value, and delegate
22
- # action to actual Prawn::Document.
24
+ # To circumvent this situation, we call to_s on value, and delegate action to actual Prawn::Document.
23
25
  def text(value, options = {})
24
26
  super(value.to_s, options)
25
27
  end
@@ -7,7 +7,7 @@ module PrawnRails
7
7
  ActionView::Base.send(:include, PrawnRails::RailsHelper)
8
8
  ActionView::Template.register_template_handler(:prawn, PrawnRails::Renderer)
9
9
 
10
- if !Mime::Type.lookup_by_extension(:pdf)
10
+ unless Mime::Type.lookup_by_extension(:pdf)
11
11
  Mime::Type.register_alias("application/pdf", :pdf)
12
12
  end
13
13
  end
@@ -7,37 +7,42 @@ module PrawnRails
7
7
  ##
8
8
  def html_strip html
9
9
  return html if html.nil?
10
- html
11
- text = html.
12
- gsub(/(&nbsp;|\n|\s)+/im, ' ').squeeze(' ').strip.
13
- gsub(/<([^\s]+)[^>]*(src|href)=\s*(.?)([^>\s]*)\3[^>]*>\4<\/\1>/i,
14
- '\4')
10
+
11
+ text = html
12
+ .gsub(/(&nbsp;|\n|\s)+/im, ' ')
13
+ .squeeze(' ')
14
+ .strip
15
+ .gsub(/<([^\s]+)[^>]*(src|href)=\s*(.?)([^>\s]*)\3[^>]*>\4<\/\1>/i, '\4')
15
16
 
16
17
  links = []
17
18
  linkregex = /<[^>]*(src|href)=\s*(.?)([^>\s]*)\2[^>]*>\s*/i
19
+
18
20
  while linkregex.match(text)
19
21
  links << $~[3]
20
22
  text.sub!(linkregex, "[#{links.size}]")
21
23
  end
24
+
25
+ text = text
26
+ .gsub(/<(script|style)[^>]*>.*<\/\1>/im, '')
27
+ .gsub(/<!--.*-->/m, '')
28
+ .gsub(/<hr(| [^>]*)>/i, "___\n")
29
+ .gsub(/<li(| [^>]*)>/i, "\n* ")
30
+ .gsub(/<blockquote(| [^>]*)>/i, '> ')
31
+ .gsub(/<(br)(| [^>]*)>/i, "\n")
32
+ .gsub(/<(\/h[\d]+|p)(| [^>]*)>/i, "\n\n")
33
+ .gsub(/<[^>]*>/, '')
22
34
 
23
- text = CGI.unescapeHTML(
24
- text.
25
- gsub(/<(script|style)[^>]*>.*<\/\1>/im, '').
26
- gsub(/<!--.*-->/m, '').
27
- gsub(/<hr(| [^>]*)>/i, "___\n").
28
- gsub(/<li(| [^>]*)>/i, "\n* ").
29
- gsub(/<blockquote(| [^>]*)>/i, '> ').
30
- gsub(/<(br)(| [^>]*)>/i, "\n").
31
- gsub(/<(\/h[\d]+|p)(| [^>]*)>/i, "\n\n").
32
- gsub(/<[^>]*>/, '')
33
- ).lstrip.gsub(/\n[ ]+/, "\n") + "\n"
35
+ text = CGI.unescapeHTML(text).lstrip.gsub(/\n[ ]+/, "\n") + "\n"
34
36
 
35
- for i in (0...links.size).to_a
36
- text = text + "\n [#{i+1}] <#{CGI.unescapeHTML(links[i])}>" unless
37
- links[i].nil?
37
+ links.each_with_index do |link, i|
38
+ unless links[i].nil?
39
+ text = text + "\n [#{i+1}] <#{CGI.unescapeHTML(link)}>"
40
+ end
38
41
  end
42
+
39
43
  links = nil
40
- text
44
+
45
+ return text
41
46
  end
42
47
  end
43
48
  end
@@ -3,10 +3,13 @@ require 'prawn-rails/document'
3
3
  module PrawnRails
4
4
  module RailsHelper
5
5
  def prawn_document(options={})
6
- options.reverse_merge!(:page_layout => PrawnRails.config.page_layout,
7
- :page_size => PrawnRails.config.page_size)
6
+ options.reverse_merge!(page_layout: PrawnRails.config.page_layout,
7
+ page_size: PrawnRails.config.page_size,
8
+ info: {
9
+ Title: @filename.sub(/\.(p|P)(d|D)(f|F)$/, '')
10
+ })
8
11
 
9
- options.reverse_merge!(:skip_page_creation => true) if PrawnRails.config.skip_page_creation
12
+ options.reverse_merge!(skip_page_creation: true) if PrawnRails.config.skip_page_creation
10
13
 
11
14
  pdf = PrawnRails::Document.new(options)
12
15
 
@@ -3,7 +3,12 @@ require "prawn-rails/document"
3
3
  module PrawnRails
4
4
  class Renderer
5
5
  def self.call(template)
6
- template.source.strip
6
+ %{
7
+ @filename ||= "\#{controller.action_name}.pdf"
8
+ controller.response.headers['Content-Disposition'] = "inline; filename=\\\"\#{@filename}\\\""
9
+
10
+ #{template.source.strip}
11
+ }
7
12
  end
8
13
  end
9
14
  end
@@ -1,3 +1,3 @@
1
1
  module PrawnRails
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -9,7 +9,7 @@ Dummy::Application.configure do
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
11
  config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
12
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
13
13
 
14
14
  # Log error messages when you accidentally call methods on nil
15
15
  config.whiny_nils = true
@@ -36,4 +36,6 @@ Dummy::Application.configure do
36
36
 
37
37
  # Print deprecation notices to the stderr
38
38
  config.active_support.deprecation = :stderr
39
+
40
+ config.eager_load = false
39
41
  end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: d28054e102cd55dcd684cee239d31ddf1e1acd83bd879dd5f671e989f5c9d94ec1ede00e7fcf9b6bde4cd115f93c54e3ba6c5dc05d233292542f27a79706fcb4
15
+
16
+ test:
17
+ secret_key_base: 378b4f2309d4898f5170b41624e19bf60ce8a154ad87c100e8846bddcf4c28b72b533f2e73738ef8f6eabb7a773a0a0e7c32c0649916c5f280eb7ac621fc318c
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: 5e73c057b92f67f980fbea4c1c2c495b25def0048f8c1c040fed9c08f49cd50a2ebf872dd87857afc0861479e9382fceb7d9837a0bce546c2f7594e2f4da45e3
@@ -7,4 +7,3 @@ class NavigationTest < ActionDispatch::IntegrationTest
7
7
  # assert true
8
8
  # end
9
9
  end
10
-
@@ -3,9 +3,9 @@ require "prawn-rails/extension"
3
3
 
4
4
  class PrawnRailsTest < ActiveSupport::TestCase
5
5
  include PrawnRails::Extension
6
+
6
7
  test "html_strip" do
7
-
8
- assert_nil(html_strip(nil))
9
- assert_not_nil(html_strip(""))
8
+ assert_nil html_strip(nil)
9
+ assert_not_nil html_strip("")
10
10
  end
11
11
  end
@@ -1,10 +1,6 @@
1
- # Configure Rails Environment
2
1
  ENV["RAILS_ENV"] = "test"
3
2
 
4
3
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
4
  require "rails/test_help"
6
5
 
7
6
  Rails.backtrace_cleaner.remove_silencers!
8
-
9
- # Load support files
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Ortiz
8
+ - Weston Ganger
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-01-12 00:00:00.000000000 Z
12
+ date: 2017-02-02 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: prawn
@@ -53,7 +54,7 @@ dependencies:
53
54
  - !ruby/object:Gem::Version
54
55
  version: 3.1.0
55
56
  - !ruby/object:Gem::Dependency
56
- name: sqlite3
57
+ name: pdf-reader
57
58
  requirement: !ruby/object:Gem::Requirement
58
59
  requirements:
59
60
  - - ">="
@@ -67,7 +68,7 @@ dependencies:
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  - !ruby/object:Gem::Dependency
70
- name: pdf-reader
71
+ name: rake
71
72
  requirement: !ruby/object:Gem::Requirement
72
73
  requirements:
73
74
  - - ">="
@@ -80,15 +81,59 @@ dependencies:
80
81
  - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
- description: Prawn Handler for RoR 3.x/4.x projects handles and registers pdf formats
84
+ - !ruby/object:Gem::Dependency
85
+ name: minitest
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: bundler
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: sqlite3
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: Prawn Handler for Rails. Handles and registers pdf formats.
84
127
  email:
85
128
  - chrono.dark@gmail.com
129
+ - westonganger@gmail.com
86
130
  executables: []
87
131
  extensions: []
88
132
  extra_rdoc_files: []
89
133
  files:
90
- - MIT-LICENSE
91
- - README.markdown
134
+ - CHANGELOG.md
135
+ - LICENSE
136
+ - README.md
92
137
  - Rakefile
93
138
  - lib/prawn-rails.rb
94
139
  - lib/prawn-rails/config.rb
@@ -98,7 +143,6 @@ files:
98
143
  - lib/prawn-rails/rails_helper.rb
99
144
  - lib/prawn-rails/renderer.rb
100
145
  - lib/prawn-rails/version.rb
101
- - lib/tasks/prawn-rails_tasks.rake
102
146
  - test/dummy/Rakefile
103
147
  - test/dummy/app/assets/javascripts/application.js
104
148
  - test/dummy/app/assets/javascripts/pdf.js
@@ -133,6 +177,7 @@ files:
133
177
  - test/dummy/config/initializers/wrap_parameters.rb
134
178
  - test/dummy/config/locales/en.yml
135
179
  - test/dummy/config/routes.rb
180
+ - test/dummy/config/secrets.yml
136
181
  - test/dummy/db/schema.rb
137
182
  - test/dummy/public/404.html
138
183
  - test/dummy/public/422.html
@@ -155,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
200
  requirements:
156
201
  - - ">="
157
202
  - !ruby/object:Gem::Version
158
- version: '0'
203
+ version: 1.9.3
159
204
  required_rubygems_version: !ruby/object:Gem::Requirement
160
205
  requirements:
161
206
  - - ">="
@@ -163,53 +208,54 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
208
  version: '0'
164
209
  requirements: []
165
210
  rubyforge_project:
166
- rubygems_version: 2.4.5
211
+ rubygems_version: 2.6.8
167
212
  signing_key:
168
213
  specification_version: 4
169
- summary: Prawn Handler for RoR 3.x/4.x projects
214
+ summary: Prawn Handler for Rails
170
215
  test_files:
216
+ - test/test_helper.rb
217
+ - test/dummy/app/helpers/products_helper.rb
218
+ - test/dummy/app/helpers/pdf_helper.rb
219
+ - test/dummy/app/helpers/application_helper.rb
220
+ - test/dummy/app/views/pdf/render_pdf.html.erb
221
+ - test/dummy/app/views/pdf/render_pdf.pdf.prawn
222
+ - test/dummy/app/views/layouts/application.html.erb
171
223
  - test/dummy/app/assets/javascripts/application.js
172
224
  - test/dummy/app/assets/javascripts/pdf.js
173
225
  - test/dummy/app/assets/javascripts/products.js
174
- - test/dummy/app/assets/stylesheets/application.css
175
- - test/dummy/app/assets/stylesheets/pdf.css
176
226
  - test/dummy/app/assets/stylesheets/products.css
177
227
  - test/dummy/app/assets/stylesheets/scaffold.css
178
- - test/dummy/app/controllers/application_controller.rb
228
+ - test/dummy/app/assets/stylesheets/pdf.css
229
+ - test/dummy/app/assets/stylesheets/application.css
179
230
  - test/dummy/app/controllers/pdf_controller.rb
180
- - test/dummy/app/helpers/application_helper.rb
181
- - test/dummy/app/helpers/pdf_helper.rb
182
- - test/dummy/app/helpers/products_helper.rb
231
+ - test/dummy/app/controllers/application_controller.rb
183
232
  - test/dummy/app/models/product.rb
184
- - test/dummy/app/views/layouts/application.html.erb
185
- - test/dummy/app/views/pdf/render_pdf.html.erb
186
- - test/dummy/app/views/pdf/render_pdf.pdf.prawn
233
+ - test/dummy/test/functional/pdf_controller_test.rb
234
+ - test/dummy/test/unit/helpers/pdf_helper_test.rb
235
+ - test/dummy/db/schema.rb
236
+ - test/dummy/public/500.html
237
+ - test/dummy/public/404.html
238
+ - test/dummy/public/422.html
239
+ - test/dummy/public/favicon.ico
240
+ - test/dummy/script/rails
241
+ - test/dummy/Rakefile
187
242
  - test/dummy/config/application.rb
188
243
  - test/dummy/config/boot.rb
189
- - test/dummy/config/database.yml
190
- - test/dummy/config/environment.rb
244
+ - test/dummy/config/routes.rb
191
245
  - test/dummy/config/environments/development.rb
192
- - test/dummy/config/environments/production.rb
193
246
  - test/dummy/config/environments/test.rb
247
+ - test/dummy/config/environments/production.rb
248
+ - test/dummy/config/database.yml
194
249
  - test/dummy/config/initializers/backtrace_silencers.rb
195
- - test/dummy/config/initializers/inflections.rb
196
250
  - test/dummy/config/initializers/mime_types.rb
251
+ - test/dummy/config/initializers/inflections.rb
197
252
  - test/dummy/config/initializers/prawn-rails.rb
198
- - test/dummy/config/initializers/secret_token.rb
199
- - test/dummy/config/initializers/session_store.rb
200
253
  - test/dummy/config/initializers/wrap_parameters.rb
254
+ - test/dummy/config/initializers/session_store.rb
255
+ - test/dummy/config/initializers/secret_token.rb
256
+ - test/dummy/config/secrets.yml
201
257
  - test/dummy/config/locales/en.yml
202
- - test/dummy/config/routes.rb
258
+ - test/dummy/config/environment.rb
203
259
  - test/dummy/config.ru
204
- - test/dummy/db/schema.rb
205
- - test/dummy/public/404.html
206
- - test/dummy/public/422.html
207
- - test/dummy/public/500.html
208
- - test/dummy/public/favicon.ico
209
- - test/dummy/Rakefile
210
- - test/dummy/script/rails
211
- - test/dummy/test/functional/pdf_controller_test.rb
212
- - test/dummy/test/unit/helpers/pdf_helper_test.rb
213
- - test/integration/navigation_test.rb
214
260
  - test/prawn-rails_test.rb
215
- - test/test_helper.rb
261
+ - test/integration/navigation_test.rb
@@ -1,91 +0,0 @@
1
- # Prawn-Rails [![Gem Version](https://badge.fury.io/rb/prawn-rails.svg)](http://badge.fury.io/rb/prawn-rails)
2
-
3
- ## Dependencies
4
-
5
- * prawn > 0.0.12
6
- * prawn-table
7
- * Rails 3.0x
8
- * Ruby > 1.8.7
9
-
10
- ## Install
11
- 1.Add to the Rails Gemfile
12
-
13
- gem 'prawn-rails'
14
-
15
- to the Rails Gemfile
16
- `prawn` and `prawn-table` is a dependency so no need to mention it in the projects Gemfile
17
- but can mention a specific version if your Gemfile, if you want
18
-
19
- ## Usage
20
- Create a view with `pdf` as format and `prawn` as handler
21
- so filename should look like `example.pdf.prawn`
22
-
23
- we provide a helper called `prawn_document`
24
- it builds a PrawnRails::Document with default options. Can override with `page_size` and `page_layout`
25
- example contents of `example.pdf.prawn`
26
-
27
- prawn_document(:page_layout => :landscape) do |pdf|
28
- pdf.text "Hello World"
29
- end
30
-
31
- No need to call `pdf.render`, it is called by `prawn_document`
32
-
33
- Your available to use all prawn document methods like `pdf.text` `pdf.font_size` and also
34
- block like `pdf.font(FONT_NAME,opts) do
35
- pdf.XXXX
36
- end`
37
-
38
- For more documentation go to [the manual](http://prawnpdf.org/manual.pdf)
39
-
40
- ### Build in helpers
41
- * *html_strip(html)*
42
- Removes the html tags from a string
43
-
44
- ### Default configuration
45
-
46
- Add a `prawn-rails.rb` config to your Rails app under `config/initializers` like this
47
-
48
- PrawnRails.config do |config|
49
- config.page_layout = :portrait
50
- config.page_size = "A4"
51
- config.skip_page_creation = false
52
- end
53
-
54
- by default `page_layout` is portrait and `page_size` is "A4"
55
- also `skip_page_creation` is set to false by default, if it is set to true
56
- then have to create the first page yourself for eg.
57
-
58
- pdf.start_new_page size: "A4", page_layout: :landscape
59
-
60
- ## Examples
61
-
62
- 1. **Hello World**
63
-
64
- **hello.pdf.prawn**
65
-
66
- pdf.text hello world
67
-
68
- 2. ** Using Active Record **
69
-
70
- **myproducts.pdf.prawn**
71
-
72
- pdf.text "Current Products are"
73
- pdf.move_down 20
74
- pdf.table(@products.collect{ |p| [p.name,p.price]})
75
-
76
-
77
- ## ToDos
78
-
79
- 1. Add per-render Configuration
80
- 2. Simple Html to PDF ?
81
- 3. Any Other requested
82
-
83
- ## thx to
84
- @rwilliams
85
- @sigmike
86
- @smber1
87
- @iffyuva
88
-
89
- ## Dev Notes
90
- Gem works with any rails 3.0 version and ruby but for development It should be atlest Rails 3.1 (for the testing env)
91
- I'll try to fix that
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :prawn-rails do
3
- # # Task goes here
4
- # end