ferrum_pdf 3.0.1 → 3.1.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 +4 -4
- data/README.md +2 -0
- data/lib/ferrum_pdf/version.rb +1 -1
- data/lib/ferrum_pdf.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '09655ccad2a5a6cbf6fa1d2d2e4bb34443a0bf29501265571207079b7a689482'
|
|
4
|
+
data.tar.gz: 06f33b09c785e64e1c99dd68ef98ae2d7ea28b9460350d5d6d34e54efce3e1d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09d27b9a48ef1c126b473930e300b8ae62339404a1a7593910eae32a679106c0a9b5479d8d66ec101ca6ce7a62741665a7d350527f6990600e12181b38544c35'
|
|
7
|
+
data.tar.gz: e0d5644936b52536b70c39c96d42e7a73f4548096797bab50d076fca3dd4068fad3fa7b03c54249d87f01c3c3ca5faa03d85ba28643fff1111f38fb8dfe4a355
|
data/README.md
CHANGED
|
@@ -75,6 +75,7 @@ FerrumPdf.render_pdf(
|
|
|
75
75
|
authorize: { user: "username", password: "password" }, # Used for authenticating with basic auth
|
|
76
76
|
wait_for_idle_options: { connections: 0, duration: 0.05, timeout: 5 }, # Used for setting network wait_for_idle options
|
|
77
77
|
timeout_if_open_connections: true,
|
|
78
|
+
viewport: { width: 1200, height: 800, scale_factor: 3 } # Used for setting the viewport dimensions and device scale factor (DPR) when rendering the page
|
|
78
79
|
|
|
79
80
|
pdf_options: {
|
|
80
81
|
landscape: false, # paper orientation
|
|
@@ -190,6 +191,7 @@ FerrumPdf.configure do |config|
|
|
|
190
191
|
config.page_options.authorize = { user: "username", password: "password" }
|
|
191
192
|
config.page_options.wait_for_idle_options = { timeout: 90 }
|
|
192
193
|
config.page_options.retries = 3
|
|
194
|
+
config.page_options.viewport = { width: 1200, height: 800, scale_factor: 3 }
|
|
193
195
|
|
|
194
196
|
config.pdf_options.margin_top = 0.2
|
|
195
197
|
config.pdf_options.margin_bottom = 0.2
|
data/lib/ferrum_pdf/version.rb
CHANGED
data/lib/ferrum_pdf.rb
CHANGED
|
@@ -87,18 +87,20 @@ module FerrumPdf
|
|
|
87
87
|
|
|
88
88
|
# Loads page into the browser to be used for rendering PDFs or screenshots
|
|
89
89
|
#
|
|
90
|
-
def load_page(url: nil, html: nil, display_url: nil, authorize: nil, wait_for_idle_options: nil, timeout_if_open_connections: nil, browser: nil, retries: nil)
|
|
90
|
+
def load_page(url: nil, html: nil, display_url: nil, authorize: nil, wait_for_idle_options: nil, timeout_if_open_connections: nil, browser: nil, retries: nil, viewport: nil)
|
|
91
91
|
try ||= 0
|
|
92
92
|
authorize ||= config.dig(:page_options, :authorize)
|
|
93
93
|
retries ||= config.page_options.fetch(:retries, 1)
|
|
94
94
|
wait_for_idle_options = config.page_options.fetch(:wait_for_idle_options, {}).merge(wait_for_idle_options || {})
|
|
95
95
|
timeout_if_open_connections = config.page_options.fetch(:timeout_if_open_connections, true) if timeout_if_open_connections.nil?
|
|
96
|
+
viewport ||= config.dig(:page_options, :viewport)
|
|
96
97
|
|
|
97
98
|
with_browser(browser) do |browser|
|
|
98
99
|
# Closes page automatically after block finishes
|
|
99
100
|
# https://github.com/rubycdp/ferrum/blob/main/lib/ferrum/browser.rb#L169
|
|
100
101
|
browser.create_page do |page|
|
|
101
102
|
page.network.authorize(**authorize) { |req| req.continue } if authorize
|
|
103
|
+
page.set_viewport(**viewport) if viewport
|
|
102
104
|
|
|
103
105
|
# Load content
|
|
104
106
|
if html
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ferrum_pdf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Oliver
|
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
73
|
version: '0'
|
|
74
74
|
requirements: []
|
|
75
|
-
rubygems_version:
|
|
75
|
+
rubygems_version: 4.0.2
|
|
76
76
|
specification_version: 4
|
|
77
77
|
summary: PDFs & screenshots for Rails using Ferrum & headless Chrome
|
|
78
78
|
test_files: []
|