wicked_pdf 2.0.2 → 2.8.2

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
  SHA256:
3
- metadata.gz: f9f7795e6c1ecec768a23b467e08da9401933ff1ba011146d9a851593e7aaca1
4
- data.tar.gz: e1a9bcfb09ff09d69846ee0e2519ad40a02eafb5e908eadb1674e3df6fa833b2
3
+ metadata.gz: d3f4ea7f135d4f4fc710ea43e0995b11afdce78631af49dda12dffa789071479
4
+ data.tar.gz: 1bab46b51b286f41c25536416e43e58123ecbc9d0c03bb263f4799a3e4363159
5
5
  SHA512:
6
- metadata.gz: 434ec5a13a8acc6ea7f39ee8d1a1c677a9f60ef217f22eaacace541068c2f079a2cce752440961d4c308c4a97221717c0508335e72551b71b488c6e6ba497fd8
7
- data.tar.gz: e29cb1771f8041c3cc30c9dbb797fc1f5fcffc9d85027e6d518f9cb03dc15c5ef0a4abb90c0be29564729c13fa804820b45a2f19998b27e2c3a805ac023a5fd4
6
+ metadata.gz: ea1929b8e9eaa18be71e0cd36e2075843d21be4925363c2e276941b4ec6ef7ec81283aa03d514b92992438e3bd80a53d1c5cdac32f5248afda536eedc928bb0d
7
+ data.tar.gz: 2f87dcc412541846b09f11ff4c6d2742a10f8b377224bcec05c3ca070c821498bf4c4d6ed86c1791436e3a28d9625ff0342b943177993a476339b2a0e07f9d3d
@@ -0,0 +1,56 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request, workflow_dispatch]
4
+
5
+ jobs:
6
+ tests:
7
+ name: Tests with Ruby ${{ matrix.ruby-version }} and Rails ${{ matrix.gemfile }}
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ gemfile: ["5.0"]
12
+ ruby-version: [2.6]
13
+ include:
14
+ - gemfile: "5.0"
15
+ ruby-version: 2.7
16
+ - gemfile: "5.1"
17
+ ruby-version: 2.6
18
+ - gemfile: "5.1"
19
+ ruby-version: 2.7
20
+ - gemfile: "5.2"
21
+ ruby-version: 2.6
22
+ - gemfile: "5.2"
23
+ ruby-version: 2.7
24
+ - gemfile: "6.0"
25
+ ruby-version: 2.6
26
+ - gemfile: "6.0"
27
+ ruby-version: 2.7
28
+ - gemfile: "6.1"
29
+ ruby-version: 2.7
30
+ - gemfile: "6.1"
31
+ ruby-version: '3.0'
32
+ - gemfile: "7.0"
33
+ ruby-version: 3.1
34
+ - gemfile: "7.0"
35
+ ruby-version: 3.2
36
+
37
+ env:
38
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
39
+ WKHTMLTOPDF_BIN: /usr/bin/wkhtmltopdf
40
+
41
+ steps:
42
+ - uses: actions/checkout@v3
43
+
44
+ - name: Install OS dependencies
45
+ run: |
46
+ sudo apt-get update -y -qq
47
+ sudo apt-get install -y wkhtmltopdf
48
+
49
+ - name: Install Ruby ${{ matrix.ruby-version }}
50
+ uses: ruby/setup-ruby@v1
51
+ with:
52
+ ruby-version: ${{ matrix.ruby-version }}
53
+ bundler-cache: true
54
+
55
+ - name: Run tests with Ruby ${{ matrix.ruby-version }} and Rails ${{ matrix.gemfile }}
56
+ run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,15 +1,71 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.2
4
+ NewCops: disable
5
+ SuggestExtensions: false
6
+ TargetRubyVersion: 2.6
5
7
  Exclude:
6
8
  - 'gemfiles/bin/*'
7
9
  - 'test/dummy/**/*'
10
+ - 'vendor/**/*'
11
+
12
+ Metrics/PerceivedComplexity:
13
+ Enabled: false
14
+
15
+ Gemspec/RequiredRubyVersion:
16
+ Enabled: false
17
+
18
+ Bundler/OrderedGems:
19
+ Enabled: false
20
+
21
+ Style/FrozenStringLiteralComment:
22
+ Enabled: false
23
+
24
+ Style/RedundantBegin:
25
+ Enabled: false
26
+
27
+ Style/NumericPredicate:
28
+ Enabled: false
29
+
30
+ Style/RedundantRegexpEscape:
31
+ Enabled: false
32
+
33
+ Style/SafeNavigation:
34
+ Enabled: false
35
+
36
+ Lint/SendWithMixinArgument:
37
+ Enabled: false
38
+
39
+ Lint/RedundantCopDisableDirective:
40
+ Enabled: false
41
+
42
+ Metrics/AbcSize:
43
+ Enabled: false
44
+
45
+ Style/StringConcatenation:
46
+ Enabled: false
47
+
48
+ Style/RedundantFetchBlock:
49
+ Enabled: false
50
+
51
+ Style/CaseLikeIf:
52
+ Enabled: false
53
+
54
+ Style/SoleNestedConditional:
55
+ Enabled: false
56
+
57
+ Style/RedundantReturn:
58
+ Enabled: false
8
59
 
9
60
  Metrics/BlockLength:
10
61
  Exclude:
11
62
  - 'wicked_pdf.gemspec'
12
63
 
64
+ Metrics/ModuleLength:
65
+ Exclude:
66
+ # Excluding to keep the logic in one module for the time being.
67
+ - 'lib/wicked_pdf/wicked_pdf_helper/assets.rb'
68
+
13
69
  # I'd like wicked_pdf to keep Ruby 1.8 compatibility for now
14
70
  Style/HashSyntax:
15
71
  EnforcedStyle: hash_rockets
data/.rubocop_todo.yml CHANGED
@@ -1,103 +1,39 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-10-02 17:54:14 +0200 using RuboCop version 0.68.1.
3
+ # on 2023-01-24 11:24:49 UTC using RuboCop version 1.44.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 9
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: TreatCommentsAsGroupSeparators, Include.
12
- # Include: **/*.gemfile, **/Gemfile, **/gems.rb
13
- Bundler/OrderedGems:
14
- Exclude:
15
- - 'gemfiles/4.0.gemfile'
16
- - 'gemfiles/4.1.gemfile'
17
- - 'gemfiles/4.2.gemfile'
18
- - 'gemfiles/5.0.gemfile'
19
- - 'gemfiles/5.1.gemfile'
20
- - 'gemfiles/5.2.gemfile'
21
- - 'gemfiles/6.0.gemfile'
22
- - 'gemfiles/rails_edge.gemfile'
23
-
24
- # Offense count: 2
25
- # Cop supports --auto-correct.
26
- # Configuration parameters: TreatCommentsAsGroupSeparators, Include.
27
- # Include: **/*.gemspec
28
- Gemspec/OrderedDependencies:
29
- Exclude:
30
- - 'wicked_pdf.gemspec'
31
-
32
- # Offense count: 16
33
- # Cop supports --auto-correct.
34
- Layout/EmptyLineAfterGuardClause:
35
- Exclude:
36
- - 'Rakefile'
37
- - 'lib/wicked_pdf.rb'
38
- - 'lib/wicked_pdf/pdf_helper.rb'
39
- - 'lib/wicked_pdf/wicked_pdf_helper/assets.rb'
40
-
41
- # Offense count: 2
42
- # Cop supports --auto-correct.
43
- Layout/LeadingBlankLines:
44
- Exclude:
45
- - 'test/unit/wkhtmltopdf_location_test.rb'
46
- - 'wicked_pdf.gemspec'
47
-
48
- # Offense count: 1
49
- # Cop supports --auto-correct.
50
- Layout/RescueEnsureAlignment:
51
- Exclude:
52
- - 'lib/wicked_pdf.rb'
53
-
54
- # Offense count: 1
55
- # Cop supports --auto-correct.
56
- # Configuration parameters: EnforcedStyle.
57
- # SupportedStyles: final_newline, final_blank_line
58
- Layout/TrailingBlankLines:
59
- Exclude:
60
- - 'gemfiles/4.0.gemfile'
61
-
62
- # Offense count: 11
63
- Metrics/AbcSize:
64
- Max: 45
65
-
66
9
  # Offense count: 2
67
- # Configuration parameters: CountComments.
10
+ # Configuration parameters: CountComments, CountAsOne.
68
11
  Metrics/ClassLength:
69
- Max: 292
12
+ Max: 203
70
13
 
71
14
  # Offense count: 7
15
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
72
16
  Metrics/CyclomaticComplexity:
73
- Max: 11
17
+ Max: 13
74
18
 
75
19
  # Offense count: 17
76
- # Configuration parameters: CountComments, ExcludedMethods.
20
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
77
21
  Metrics/MethodLength:
78
- Max: 30
22
+ Max: 34
79
23
 
80
- # Offense count: 2
81
- # Configuration parameters: CountComments.
24
+ # Offense count: 1
25
+ # Configuration parameters: CountComments, CountAsOne.
82
26
  Metrics/ModuleLength:
83
- Max: 147
84
-
85
- # Offense count: 6
86
- Metrics/PerceivedComplexity:
87
- Max: 12
27
+ Max: 104
88
28
 
89
- # Offense count: 2
29
+ # Offense count: 1
90
30
  Naming/AccessorMethodName:
91
31
  Exclude:
92
32
  - 'lib/wicked_pdf/middleware.rb'
93
- - 'lib/wicked_pdf/pdf_helper.rb'
94
-
95
- # Offense count: 1
96
- Security/Open:
97
- Exclude:
98
- - 'lib/wicked_pdf/wicked_pdf_helper/assets.rb'
99
33
 
100
34
  # Offense count: 1
35
+ # This cop supports safe autocorrection (--autocorrect).
36
+ # Configuration parameters: AllowOnConstant, AllowOnSelfClass.
101
37
  Style/CaseEquality:
102
38
  Exclude:
103
39
  - 'lib/wicked_pdf/wicked_pdf_helper.rb'
@@ -107,14 +43,17 @@ Style/ClassVars:
107
43
  Exclude:
108
44
  - 'lib/wicked_pdf.rb'
109
45
 
110
- # Offense count: 10
46
+ # Offense count: 13
47
+ # Configuration parameters: AllowedConstants.
111
48
  Style/Documentation:
112
49
  Exclude:
113
50
  - 'spec/**/*'
114
51
  - 'test/**/*'
115
52
  - 'generators/wicked_pdf/wicked_pdf_generator.rb'
116
53
  - 'lib/wicked_pdf.rb'
54
+ - 'lib/wicked_pdf/binary.rb'
117
55
  - 'lib/wicked_pdf/middleware.rb'
56
+ - 'lib/wicked_pdf/option_parser.rb'
118
57
  - 'lib/wicked_pdf/pdf_helper.rb'
119
58
  - 'lib/wicked_pdf/progress.rb'
120
59
  - 'lib/wicked_pdf/railtie.rb'
@@ -123,71 +62,44 @@ Style/Documentation:
123
62
  - 'lib/wicked_pdf/wicked_pdf_helper/assets.rb'
124
63
 
125
64
  # Offense count: 2
126
- # Cop supports --auto-correct.
65
+ # This cop supports safe autocorrection (--autocorrect).
127
66
  Style/ExpandPathArguments:
128
67
  Exclude:
129
68
  - 'test/test_helper.rb'
130
69
  - 'wicked_pdf.gemspec'
131
70
 
132
- # Offense count: 8
133
- # Cop supports --auto-correct.
134
- # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
71
+ # Offense count: 4
72
+ # This cop supports safe autocorrection (--autocorrect).
73
+ # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
135
74
  # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
75
+ # SupportedShorthandSyntax: always, never, either, consistent
136
76
  Style/HashSyntax:
137
77
  Exclude:
138
- - 'gemfiles/4.0.gemfile'
139
- - 'gemfiles/4.1.gemfile'
140
- - 'gemfiles/4.2.gemfile'
141
78
  - 'gemfiles/5.0.gemfile'
142
79
  - 'gemfiles/5.1.gemfile'
143
80
  - 'gemfiles/5.2.gemfile'
144
81
  - 'gemfiles/6.0.gemfile'
145
- - 'gemfiles/rails_edge.gemfile'
146
-
147
- # Offense count: 3
148
- # Cop supports --auto-correct.
149
- Style/IfUnlessModifier:
150
- Exclude:
151
- - 'Rakefile'
152
- - 'lib/wicked_pdf.rb'
153
- - 'lib/wicked_pdf/railtie.rb'
154
82
 
155
83
  # Offense count: 2
156
- # Cop supports --auto-correct.
84
+ # This cop supports unsafe autocorrection (--autocorrect-all).
157
85
  # Configuration parameters: EnforcedStyle.
158
86
  # SupportedStyles: literals, strict
159
87
  Style/MutableConstant:
160
88
  Exclude:
161
89
  - 'lib/wicked_pdf/wicked_pdf_helper/assets.rb'
162
90
 
163
- # Offense count: 6
164
- # Cop supports --auto-correct.
91
+ # Offense count: 5
92
+ # This cop supports safe autocorrection (--autocorrect).
165
93
  # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
166
94
  # SupportedStyles: slashes, percent_r, mixed
167
95
  Style/RegexpLiteral:
168
96
  Exclude:
169
97
  - 'lib/wicked_pdf/middleware.rb'
170
98
  - 'lib/wicked_pdf/wicked_pdf_helper/assets.rb'
171
- - 'test/unit/wicked_pdf_test.rb'
172
-
173
- # Offense count: 1
174
- # Cop supports --auto-correct.
175
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
176
- # SupportedStyles: single_quotes, double_quotes
177
- Style/StringLiterals:
178
- Exclude:
179
- - 'gemfiles/4.0.gemfile'
180
-
181
- # Offense count: 29
182
- # Cop supports --auto-correct.
183
- # Configuration parameters: MinSize.
184
- # SupportedStyles: percent, brackets
185
- Style/SymbolArray:
186
- EnforcedStyle: brackets
187
99
 
188
- # Offense count: 111
189
- # Cop supports --auto-correct.
190
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
100
+ # Offense count: 18
101
+ # This cop supports safe autocorrection (--autocorrect).
102
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
191
103
  # URISchemes: http, https
192
- Metrics/LineLength:
104
+ Layout/LineLength:
193
105
  Max: 563
data/CHANGELOG.md CHANGED
@@ -1,14 +1,118 @@
1
1
  # Change Log
2
- All notable changes to this project will be documented in this file.
3
- This project adheres to [Semantic Versioning](http://semver.org/).
2
+ All notable changes to this project should be documented in this file.
3
+ This project attempts to adhere to [Semantic Versioning](http://semver.org/).
4
4
 
5
- ## [master branch] - Unreleased
5
+ ## [[master branch] - Unreleased changes](https://github.com/mileszs/wicked_pdf/compare/2.8.2...HEAD)
6
6
  ### Breaking Changes
7
- - None
8
7
  ### New Features
9
- - None
10
8
  ### Fixes
11
- - None
9
+
10
+ ## [2.8.2]
11
+ ### Fixes
12
+ - [Fix for frozen_string_literal in Ruby 3.4](https://github.com/mileszs/wicked_pdf/pull/1118)
13
+ - [Add OpenStruct dependency explicitly for Ruby 3.5](https://github.com/mileszs/wicked_pdf/pull/1131)
14
+
15
+ ## [2.8.1]
16
+ ### Fixes
17
+ - [Explicitly require OpenStruct, which isn't loaded by default anymore in new versions of Rake](https://github.com/mileszs/wicked_pdf/pull/1110)
18
+ - [Ensure assets without extensions are handled correctly](https://github.com/mileszs/wicked_pdf/pull/1115)
19
+
20
+ ## [2.8.0]
21
+ ### New Features
22
+ - [Add New config option `raise_on_missing_assets`](https://github.com/mileszs/wicked_pdf/pull/1094)
23
+ - [Add support for truffleruby (22.1.0) on Linux](https://github.com/mileszs/wicked_pdf/pull/1028)
24
+
25
+ ### Fixes
26
+ - [Fix Propshaft encoding issue](https://github.com/mileszs/wicked_pdf/pull/1096)
27
+ - [Fix Webpacker & Shakapacker compatibility issue](https://github.com/mileszs/wicked_pdf/pull/1099)
28
+
29
+ ## [2.7.0]
30
+ ### New Features
31
+ - [Support Shakapacker 7](https://github.com/mileszs/wicked_pdf/pull/1067)
32
+ - [Add option `delete_temporary_files` to keep the temporary files generated by `pdf_from_string` method](https://github.com/mileszs/wicked_pdf/pull/1068)
33
+ - [Add support for --allow flag](https://github.com/mileszs/wicked_pdf/pull/1030)
34
+
35
+ ## Fixes
36
+ - [Add require for `stringio`, which is no longer loaded by default in Ruby 3.1+](https://github.com/mileszs/wicked_pdf/pull/1062)
37
+ - [Fix CI build.](https://github.com/mileszs/wicked_pdf/pull/1055)
38
+ - [Fix Header/footer temporary file is removed before `wkhtmltopdf` is called](https://github.com/mileszs/wicked_pdf/pull/1039)
39
+ - [Bump rubocop to 1.46](https://github.com/mileszs/wicked_pdf/pull/1051)
40
+ - [Add Ruby 3.2 to the test matrix](https://github.com/mileszs/wicked_pdf/pull/1046)
41
+
42
+ ## [2.6.3]
43
+ ### Fixes
44
+ - [Fix typo of #possible_binary_locations](https://github.com/mileszs/wicked_pdf/pull/1025)
45
+ - [Drop unused executables gemspec directive](https://github.com/mileszs/wicked_pdf/pull/1024)
46
+
47
+ ## [2.6.2]
48
+ ### Fixes
49
+ - [Fix undefined local variable or method 'block' for render_to_string](https://github.com/mileszs/wicked_pdf/pull/962)
50
+ - [Add require for `delegate`, which is no longer loaded by default in Ruby 2.7+](https://github.com/mileszs/wicked_pdf/pull/1019)
51
+ ## [2.6.0]
52
+ ### New Features
53
+ - [Support Propshaft in find_asset helper](https://github.com/mileszs/wicked_pdf/pull/1010)
54
+ ### Fixes
55
+ - [Update Changelog with changes from 2.1.0](https://github.com/mileszs/wicked_pdf/pull/1013)
56
+ - [Fix CI build for Rails 7.](https://github.com/mileszs/wicked_pdf/pull/1014)
57
+
58
+ ## [2.5.4] December 20th 2021 769f9df487f3c1e31dc91431666baa78d2aa24fb
59
+ ### New Features
60
+ - [Test with Rails 7](https://github.com/mileszs/wicked_pdf/pull/998)
61
+ ### Fixes
62
+ - [Include view helper on view load.](https://github.com/mileszs/wicked_pdf/pull/992)
63
+
64
+ ## [2.5.3] December 15th 2021 7991877de634067b4245fb47fdad65da43761887
65
+ - [Fix check for webpacker version](https://github.com/mileszs/wicked_pdf/pull/964)
66
+ - [Complete transition to Github actions](https://github.com/mileszs/wicked_pdf/pull/987)
67
+
68
+ ## [2.5.2] November 2021 - fix webpacker_source_url bdd0ca3eca759e277ce5461141b1506f56fefcd1
69
+ - [fix: `webpacker_source_url`](https://github.com/mileszs/wicked_pdf/pull/993)
70
+ - [update README](https://github.com/mileszs/wicked_pdf/pull/968)
71
+
72
+ ## [2.5.1] September 2021 - fix webpacker helper, github actions and Readme updates ae725e8055dc8f51a392c27767b4dcdcfffe155d
73
+ - [Add comment about enable_local_file_access to README](https://github.com/mileszs/wicked_pdf/commit/2dc96dde2e0fd7362395064f2480cac1edcc1f48)
74
+ - [README updates](https://github.com/mileszs/wicked_pdf/pull/974) &&
75
+ - [Github actions](https://github.com/mileszs/wicked_pdf/pull/986)
76
+ - [Screencast links](https://github.com/mileszs/wicked_pdf/pull/976)
77
+ - [fix url generating in webpacker helper](https://github.com/mileszs/wicked_pdf/pull/973)
78
+
79
+ ## [2.5.0] November 2020 Release - 2b1d47a84fce3600e7cbe2f50843af1a7b84d4a6
80
+ - [Remove code for unsupported rails and ruby versions](https://github.com/mileszs/wicked_pdf/pull/925)
81
+
82
+ ## [2.4.1] b56c46a05895def395ebc75ed8e822551c2c478f
83
+ - [Extract reading in chunk](https://github.com/mileszs/wicked_pdf/pull/951)
84
+ - [add ruby 2.7 to the test matrix](https://github.com/mileszs/wicked_pdf/pull/952)
85
+
86
+ ## [2.4.0] 8c007a77057e1a6680469d1ef53aa19a108fe209
87
+ ### New Features
88
+ - [Do not unlink HTML temp files immediately (to enable HTML tempfile inspection)](https://github.com/mileszs/wicked_pdf/pull/950)
89
+ - [Read HTML string and generated PDF file in chunks (to reduce memory overhead of generating large PDFs)](https://github.com/mileszs/wicked_pdf/pull/949)
90
+ - [Add `wicked_pdf_url_base64` helper](https://github.com/mileszs/wicked_pdf/pull/947)
91
+
92
+ ## [2.3.1] - Allow bundler 2.x ee6a5e1f807c872af37c1382f629dd4cac3040a8
93
+ - [Adjust gemspec development dependencies](https://github.com/mileszs/wicked_pdf/pull/814)
94
+
95
+ ## [2.3.0] - Remove support for Ruby 1.x and Rails 2.x 66149c67e54cd3a63dd27528f5b78255fdd5ac43
96
+ - [Remove support for Ruby 1.x and Rails 2.x](https://github.com/mileszs/wicked_pdf/pull/859)
97
+
98
+ ## [2.2.0] - October 2020 release f8abe706f5eb6dba2fcded473c81f2176e9d717e
99
+ ### Fixes
100
+ - [Make CI green again](https://github.com/mileszs/wicked_pdf/pull/939)
101
+ - [rubocop fixes](https://github.com/mileszs/wicked_pdf/pull/945)
102
+ ### New Features
103
+ - [Add support for --keep-relative-links flag](https://github.com/mileszs/wicked_pdf/pull/930)
104
+ - [Encapsulate binary path and version handling](https://github.com/mileszs/wicked_pdf/pull/816) && [#815](https://github.com/mileszs/wicked_pdf/pull/815)
105
+
106
+
107
+ ## [2.1.0] - 2020-06-14
108
+ ### Fixes
109
+ - [Document no_stop_slow_scripts in README](https://github.com/mileszs/wicked_pdf/pull/905)
110
+ - [Document how to use locals in README](https://github.com/mileszs/wicked_pdf/pull/915)
111
+
112
+ ### New Features
113
+ - [Improved support for Webpacker assets with `wicked_pdf_asset_pack_path`](https://github.com/mileszs/wicked_pdf/pull/896)
114
+ - [Support enabling/disabling local file access compatible with wkhtmltopdf 0.12.6](https://github.com/mileszs/wicked_pdf/pull/920)
115
+ - [Add option `use_xvfb` to emulate an X server](https://github.com/mileszs/wicked_pdf/pull/909)
12
116
 
13
117
  ## [2.0.2] - 2020-03-17
14
118
  ### Fixes
@@ -148,12 +252,3 @@ This project adheres to [Semantic Versioning](http://semver.org/).
148
252
  - Issues with `url()` references and embedded `data:base64` assets in stylesheets rendered with `wicked_pdf_stylesheet_link_tag`
149
253
  - Asset helpers no longer add a file extension if it already is specified with one
150
254
 
151
- # Compare Releases
152
- - [2.0.2...HEAD (unreleased changes)](https://github.com/mileszs/wicked_pdf/compare/2.0.2...HEAD)
153
- - [2.0.0...2.0.2](https://github.com/mileszs/wicked_pdf/compare/2.0.0...2.0.2)
154
- - [1.4.0...2.0.0](https://github.com/mileszs/wicked_pdf/compare/1.4.0...2.0.0)
155
- - [1.3.0...1.4.0](https://github.com/mileszs/wicked_pdf/compare/1.3.0...1.4.0)
156
- - [1.2.0...1.3.0](https://github.com/mileszs/wicked_pdf/compare/1.2.0...1.3.0)
157
- - [1.1.0...1.2.0](https://github.com/mileszs/wicked_pdf/compare/1.1.0...1.2.0)
158
- - [1.0.0...1.1.0](https://github.com/mileszs/wicked_pdf/compare/1.0.0...1.0.0)
159
- - [0.11.0...1.0.0](https://github.com/mileszs/wicked_pdf/compare/0.11.0...1.0.0)
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # Wicked PDF [![Gem Version](https://badge.fury.io/rb/wicked_pdf.svg)](http://badge.fury.io/rb/wicked_pdf) [![Build Status](https://secure.travis-ci.org/mileszs/wicked_pdf.svg)](http://travis-ci.org/mileszs/wicked_pdf) [![Code Climate](https://codeclimate.com/github/mileszs/wicked_pdf/badges/gpa.svg)](https://codeclimate.com/github/mileszs/wicked_pdf) [![Open Source Helpers](https://www.codetriage.com/mileszs/wicked_pdf/badges/users.svg)](https://www.codetriage.com/mileszs/wicked_pdf)
1
+ # Wicked PDF [![Gem Version](https://badge.fury.io/rb/wicked_pdf.svg)](http://badge.fury.io/rb/wicked_pdf) [![Build Status](https://github.com/mileszs/wicked_pdf/actions/workflows/ci.yml/badge.svg)](https://github.com/mileszs/wicked_pdf/actions/workflows/ci.yml) [![Code Climate](https://codeclimate.com/github/mileszs/wicked_pdf/badges/gpa.svg)](https://codeclimate.com/github/mileszs/wicked_pdf) [![Open Source Helpers](https://www.codetriage.com/mileszs/wicked_pdf/badges/users.svg)](https://www.codetriage.com/mileszs/wicked_pdf)
2
2
 
3
3
  ## A PDF generation plugin for Ruby on Rails
4
4
 
5
5
  Wicked PDF uses the shell utility [wkhtmltopdf](http://wkhtmltopdf.org) to serve a PDF file to a user from HTML. In other words, rather than dealing with a PDF generation DSL of some sort, you simply write an HTML view as you would normally, then let Wicked PDF take care of the hard stuff.
6
6
 
7
- _Wicked PDF has been verified to work on Ruby versions 2.2 through 2.6; Rails 4 through 6.1_
7
+ _Wicked PDF has been verified to work on Ruby versions 2.2 through 3.2; Rails 4 through 7.0_
8
8
 
9
9
  ### Installation
10
10
 
@@ -42,9 +42,10 @@ You can see what flags are supported for the current version in [wkhtmltopdf's a
42
42
  If your wkhtmltopdf executable is not on your webserver's path, you can configure it in an initializer:
43
43
 
44
44
  ```ruby
45
- WickedPdf.config = {
46
- exe_path: '/usr/local/bin/wkhtmltopdf'
47
- }
45
+ WickedPdf.configure do |c|
46
+ c.exe_path = '/usr/local/bin/wkhtmltopdf'
47
+ c.enable_local_file_access = true
48
+ end
48
49
  ```
49
50
 
50
51
  For more information about `wkhtmltopdf`, see the project's [homepage](http://wkhtmltopdf.org/).
@@ -109,10 +110,11 @@ Using wicked_pdf_helpers with asset pipeline raises `Asset names passed to helpe
109
110
 
110
111
  #### Webpacker usage
111
112
 
112
- wicked_pdf supports webpack stylesheets and javascript assets.
113
+ wicked_pdf supports webpack assets.
113
114
 
114
- Use `wicked_pdf_stylesheet_pack_tag` for stylesheets
115
- Use `wicked_pdf_javascript_pack_tag` for javascripts
115
+ - Use `wicked_pdf_stylesheet_pack_tag` for stylesheets
116
+ - Use `wicked_pdf_javascript_pack_tag` for javascripts
117
+ - Use `wicked_pdf_asset_pack_path` to access an asset directly, for example: `image_tag wicked_pdf_asset_pack_path("media/images/foobar.png")`
116
118
 
117
119
  #### Asset pipeline usage
118
120
 
@@ -124,11 +126,11 @@ It is best to precompile assets used in PDF views. This will help avoid issues w
124
126
 
125
127
  In this case, you can use that standard Rails helpers and point to the current CDN for whichever framework you are using. For jQuery, it would look somethng like this, given the current versions at the time of this writing.
126
128
  ```html
127
- <!doctype html>
128
- <html>
129
- <head>
130
- <%= javascript_include_tag "http://code.jquery.com/jquery-1.10.0.min.js" %>
131
- <%= javascript_include_tag "http://code.jquery.com/ui/1.10.3/jquery-ui.min.js" %>
129
+ <!doctype html>
130
+ <html>
131
+ <head>
132
+ <%= javascript_include_tag "http://code.jquery.com/jquery-1.10.0.min.js" %>
133
+ <%= javascript_include_tag "http://code.jquery.com/ui/1.10.3/jquery-ui.min.js" %>
132
134
  ```
133
135
 
134
136
  ### Advanced Usage with all available options
@@ -144,6 +146,7 @@ class ThingsController < ApplicationController
144
146
  render pdf: 'file_name',
145
147
  disposition: 'attachment', # default 'inline'
146
148
  template: 'things/show',
149
+ locals: {foo: @bar},
147
150
  file: "#{Rails.root}/files/foo.erb",
148
151
  inline: '<!doctype html><html><head></head><body>INLINE HTML</body></html>',
149
152
  layout: 'pdf', # for a pdf.pdf.erb file
@@ -182,14 +185,23 @@ class ThingsController < ApplicationController
182
185
  enable_plugins: true,
183
186
  disable_internal_links: true,
184
187
  disable_external_links: true,
188
+ keep_relative_links: true,
185
189
  print_media_type: true,
190
+
191
+ # define as true the key 'disable_local_file_access' or 'enable_local_file_access', not both
192
+ disable_local_file_access: true,
193
+ enable_local_file_access: false, # must be true when using wkhtmltopdf > 0.12.6
194
+ allow: ["#{Rails.root}/public"], # could be an array or a single string
195
+
186
196
  disable_smart_shrinking: true,
187
197
  use_xserver: true,
188
198
  background: false, # background needs to be true to enable background colors to render
189
199
  no_background: true,
200
+ no_stop_slow_scripts: false,
190
201
  viewport_size: 'TEXT', # available only with use_xserver or patched QT
191
202
  extra: '', # directly inserted into the command to wkhtmltopdf
192
203
  raise_on_all_errors: nil, # raise error for any stderr output. Such as missing media, image assets
204
+ raise_on_missing_assets: nil, # raise when trying to access a missing asset
193
205
  log_level: 'info', # Available values: none, error, warn, or info - only available with wkhtmltopdf 0.12.5+
194
206
  quiet: false, # `false` is same as `log_level: 'info'`, `true` is same as `log_level: 'none'`
195
207
  outline: { outline: true,
@@ -248,7 +260,8 @@ class ThingsController < ApplicationController
248
260
  disable_toc_links: true,
249
261
  disable_back_links:true,
250
262
  xsl_style_sheet: 'file.xsl'}, # optional XSLT stylesheet to use for styling table of contents
251
- progress: proc { |output| puts output } # proc called when console output changes
263
+ progress: proc { |output| puts output }, # proc called when console output changes
264
+ delete_temporary_files: true # explicitly delete temporary files, default false
252
265
  end
253
266
  end
254
267
  end
@@ -283,14 +296,14 @@ pdf = WickedPdf.new.pdf_from_html_file('/your/absolute/path/here')
283
296
  # create a pdf from a URL
284
297
  pdf = WickedPdf.new.pdf_from_url('https://github.com/mileszs/wicked_pdf')
285
298
 
286
- # create a pdf from string using templates, layouts and content option for header or footer
299
+ # create a pdf from string using templates, layouts, and content option for header or footer
287
300
  pdf = WickedPdf.new.pdf_from_string(
288
301
  render_to_string('templates/pdf', layout: 'pdfs/layout_pdf.html'),
289
302
  footer: {
290
303
  content: render_to_string(
291
- 'templates/footer',
292
- layout: 'pdfs/layout_pdf.html'
293
- )
304
+ 'templates/footer',
305
+ layout: 'pdfs/layout_pdf.html'
306
+ )
294
307
  }
295
308
  )
296
309
 
@@ -421,8 +434,22 @@ JESii's post [WickedPDF, wkhtmltopdf, and Heroku...a tricky combination](http://
421
434
 
422
435
  Berislav Babic's post [Send PDF attachments from Rails with WickedPdf and ActionMailer](http://berislavbabic.com/send-pdf-attachments-from-rails-with-wickedpdf-and-actionmailer/)
423
436
 
437
+ Corsego's 2021 post [Complete guide to generating PDFs with gem wicked_pdf](https://blog.corsego.com/gem-wicked-pdf)
438
+
439
+ PDFTron's post [How to Generate PDFs With Ruby on Rails](https://www.pdftron.com/blog/rails/how-to-generate-pdf-with-ruby-on-rails/)
440
+
424
441
  StackOverflow [questions with the tag "wicked-pdf"](http://stackoverflow.com/questions/tagged/wicked-pdf)
425
442
 
443
+ ### Screencasts
444
+
445
+ * SupeRails Screencast [EN]
446
+
447
+ [![Ruby on Rails #17 generate, save, send PDFs with gem wicked_pdf](https://i3.ytimg.com/vi/tFvtwEmW-GE/hqdefault.jpg)](https://youtu.be/tFvtwEmW-GE)
448
+
449
+ * codigofacilito Screencast [ES]
450
+
451
+ [![Generar PDF con Ruby on Rails - Tutorial](https://i3.ytimg.com/vi/jeWM_gusmJc/hqdefault.jpg)](https://youtu.be/jeWM_gusmJc)
452
+
426
453
  ### Debugging
427
454
 
428
455
  Now you can use a debug param on the URL that shows you the content of the pdf in plain html to design it faster.
@@ -433,7 +460,7 @@ http://localhost:3001/CONTROLLER/X.pdf?debug
433
460
 
434
461
  However, the wicked_pdf_* helpers will use file:/// paths for assets when using :show_as_html, and your browser's cross-domain safety feature will kick in, and not render them. To get around this, you can load your assets like so in your templates:
435
462
  ```html
436
- <%= params.key?('debug') ? image_tag('foo') : wicked_pdf_image_tag('foo') %>
463
+ <%= params.key?('debug') ? image_tag('foo') : wicked_pdf_image_tag('foo') %>
437
464
  ```
438
465
 
439
466
  #### Gotchas
@@ -442,6 +469,22 @@ If one image from your HTML cannot be found (relative or wrong path for example)
442
469
 
443
470
  wkhtmltopdf may render at different resolutions on different platforms. For example, Linux prints at 75 dpi (native for WebKit) while on Windows it's at the desktop's DPI (which is normally 96 dpi). [Use `:zoom => 0.78125`](https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2184) (75/96) to match Linux rendering to Windows.
444
471
 
472
+ ### Security considerations
473
+
474
+ WickedPdf renders page content on the server by saving HTML and assets to temporary files on disk, then executing `wkhtmltopdf` to convert that HTML to a PDF file.
475
+
476
+ It is highly recommended if you allow user-generated HTML/CSS/JS to be converted to PDF, you sanitize it first, or at least disallow requesting content from internal IP addresses and hostnames.
477
+
478
+ For example, these could potentially leak internal AWS metadata:
479
+ ```html
480
+ <iframe src="http://169.254.169.254/latest/meta-data/"></iframe>
481
+ <object data="http://169.254.169.254/latest/meta-data/" type="text/html">
482
+ ```
483
+
484
+ Thank you to Adam Gold from [Snyk](https://snyk.io) for reporting this.
485
+ We are considering adding host allow & block lists and/or potentially HTML element sanitizing.
486
+ Please open an issue or PR to help us out with this.
487
+
445
488
  ### Inspiration
446
489
 
447
490
  You may have noticed: this plugin is heavily inspired by the PrinceXML plugin [princely](http://github.com/mbleigh/princely/tree/master). PrinceXML's cost was prohibitive for me. So, with a little help from some friends (thanks [jqr](http://github.com/jqr)), I tracked down wkhtmltopdf, and here we are.