chromium-pdf 1.0.0 → 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9323ff5057cfb25e57f78723a2473a62c5ffeb8cf5bf2fb5516b8bdee9f01f81
|
|
4
|
+
data.tar.gz: 4e052603a0f4502b3cd9bbb52ad7419faf3aaef9c9ad912d48127fa10f06e2f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 781265b0efe0f85fc2209dc7727f32b0631c950bf6b98a0e5078427f51c9bf06a693136acb1930add92a030c4f93dd223a9a36f704ddf631a3ef9064736d9c37
|
|
7
|
+
data.tar.gz: 48a5f8b0b35edcde9df13c641a06b65fbd208d2bab986ab7e2b37f21c18e36753f4f91ee2501eef306661aa1f467942fc3b58105abe6ed839f9c0a83138104e5
|
data/lib/chromium/pdf/version.rb
CHANGED
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:
|
|
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
|
-
|
|
43
|
+
block&.call(file, filename)
|
|
35
44
|
end
|
|
36
45
|
end
|
|
37
46
|
end
|
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.
|
|
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:
|
|
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:
|
|
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: []
|