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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efe120091d2cc3eaaf6ce3e7fc5ccb3c34d3fabe59570986fa5b08d89295b58a
4
- data.tar.gz: b3923cb2306e1cd27023725ddb088ae9f6ed290aab538db1e0d27bdb032d79cd
3
+ metadata.gz: '09655ccad2a5a6cbf6fa1d2d2e4bb34443a0bf29501265571207079b7a689482'
4
+ data.tar.gz: 06f33b09c785e64e1c99dd68ef98ae2d7ea28b9460350d5d6d34e54efce3e1d0
5
5
  SHA512:
6
- metadata.gz: 4e44f85006fc98e28298c2e3720b3066bc59611c32b439791df54d5b70e4dae5eaa62fabe1499d75f7f85599ff79e52ffee60485556f3b1167a1082aeb381702
7
- data.tar.gz: 86ad9105c1a8e2bf3c867a91e0a409d045d5ffdbc6755bdfa5af02a7948271c32ab063a138f3ff09903daa3f100642ef8f328aea154cb4e316add75944d07680
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
@@ -1,3 +1,3 @@
1
1
  module FerrumPdf
2
- VERSION = "3.0.1"
2
+ VERSION = "3.1.0"
3
3
  end
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.1
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: 3.6.9
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: []