chromium-pdf 1.0.1 → 1.0.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: c8ac78e20c8c455a1100a3eb965357a9541b886e5d5ce991ae372dae6bc10db3
4
- data.tar.gz: '03822ffe3628b0c2675050a5160b759cdbc6671c4fd1a6429d09f9267f67c566'
3
+ metadata.gz: 9323ff5057cfb25e57f78723a2473a62c5ffeb8cf5bf2fb5516b8bdee9f01f81
4
+ data.tar.gz: 4e052603a0f4502b3cd9bbb52ad7419faf3aaef9c9ad912d48127fa10f06e2f3
5
5
  SHA512:
6
- metadata.gz: 721bd85e611f1515f557e3b6ecf125dd98369605ef0220cdcc9cf63cb6fa2f4a5a94285a1d653938b1ce1e4989752bf7ec91cba3b2ea97f777c28526f7045307
7
- data.tar.gz: 3b712f971ffcfcbfcc7fd297e2ec52f117789e2b4b3731a7fceb695f997c7ff687bde3acc2f5830a8dbc8594d631e13f38fed04266705ef278430edba201a6d0
6
+ metadata.gz: 781265b0efe0f85fc2209dc7727f32b0631c950bf6b98a0e5078427f51c9bf06a693136acb1930add92a030c4f93dd223a9a36f704ddf631a3ef9064736d9c37
7
+ data.tar.gz: 48a5f8b0b35edcde9df13c641a06b65fbd208d2bab986ab7e2b37f21c18e36753f4f91ee2501eef306661aa1f467942fc3b58105abe6ed839f9c0a83138104e5
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Chromium
4
4
  module Pdf
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
  end
7
7
  end
data/lib/chromium/pdf.rb CHANGED
@@ -8,30 +8,39 @@ module Chromium
8
8
  module Pdf
9
9
  extend ActiveSupport::Concern
10
10
 
11
+ DEFAULT_CHROME_ARGUMENTS = [
12
+ '--headless',
13
+ '--disable-gpu',
14
+ '--no-pdf-header-footer',
15
+ '--run-all-compositor-stages-before-draw',
16
+ '--no-sandbox',
17
+ '--disable-dev-shm-usage',
18
+ '--disable-background-networking'
19
+ ].freeze
20
+
11
21
  ##
12
22
  # @param unescaped_filename [String] The filename to save the PDF as.
13
23
  # @param print_url [String] The URL of the page you want to be processed.
14
24
  # @param arguments [Array<String>] An array of arguments to pass to the Chrome binary.
15
25
  # @yield [file, filename] Yields the file object and the filename to the block.
16
26
  #
17
- def generate_pdf!(unescaped_filename, print_url, arguments: ['--headless --disable-gpu'])
27
+ def generate_pdf!(unescaped_filename, print_url, arguments: DEFAULT_CHROME_ARGUMENTS, &block)
18
28
  chrome_path = ENV.fetch('GOOGLE_CHROME_BIN', nil)
19
29
  filename = unescaped_filename.gsub('&', 'and')
20
30
 
21
31
  Dir.mktmpdir do |path|
22
32
  filepath = "#{path}/#{filename}"
23
-
24
- chrome_print chrome_path, print_url, filename, filepath, arguments
33
+ chrome_print chrome_path, print_url, filename, filepath, arguments, &block
25
34
  end
26
35
  end
27
36
 
28
37
  protected
29
38
 
30
- def chrome_print(chrome_path, print_url, filename, filepath, arguments)
31
- system("LD_PRELOAD='' #{chrome_path} --print-to-pdf='#{filepath}' #{arguments.join(' ')} #{print_url}")
39
+ def chrome_print(chrome_path, print_url, filename, filepath, arguments, &block)
40
+ Kernel.system("LD_PRELOAD='' #{chrome_path} --print-to-pdf='#{filepath}' #{arguments.join(' ')} #{print_url}")
32
41
 
33
42
  File.open(filepath) do |file|
34
- yield file, filename
43
+ block&.call(file, filename)
35
44
  end
36
45
  end
37
46
  end
@@ -12,7 +12,7 @@ class GeneratePdfJob < ApplicationJob
12
12
  good_job_control_concurrency_with(
13
13
  enqueue_limit: 1,
14
14
  perform_limit: 1,
15
- key: arguments.first.id
15
+ key: -> { "generate_pdf_#{arguments.first.id}" }
16
16
  )
17
17
 
18
18
  around_perform do |_job, block|
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chromium-pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - RoleModel Software
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-09-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Add support for generating PDFs with chrome to a rails app
14
13
  email:
@@ -38,7 +37,6 @@ metadata:
38
37
  source_code_uri: https://github.com/RoleModel/chromium-pdf
39
38
  changelog_uri: https://github.com/RoleModel/chromium-pdf/blob/main/CHANGELOG.md
40
39
  rubygems_mfa_required: 'true'
41
- post_install_message:
42
40
  rdoc_options: []
43
41
  require_paths:
44
42
  - lib
@@ -53,8 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
51
  - !ruby/object:Gem::Version
54
52
  version: '0'
55
53
  requirements: []
56
- rubygems_version: 3.5.11
57
- signing_key:
54
+ rubygems_version: 4.0.2
58
55
  specification_version: 4
59
56
  summary: A wrapper around headless Chrome's print-to-pdf functionality.
60
57
  test_files: []