gotenberg-ruby 1.0.11 → 1.0.13
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 +21 -2
- data/lib/gotenberg/chromium/properties.rb +2 -2
- data/lib/gotenberg/chromium.rb +4 -4
- data/lib/gotenberg/client.rb +4 -3
- data/lib/gotenberg/configuration.rb +6 -5
- data/lib/gotenberg/headers.rb +9 -2
- data/lib/gotenberg/libreoffice.rb +4 -4
- data/lib/gotenberg/pdf_engines.rb +4 -4
- data/lib/gotenberg/version.rb +1 -1
- metadata +3 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d556bb9a188ff71be74c546f2c6743dc697bcf7d251dd8769bc223e6a824a5
|
4
|
+
data.tar.gz: 042a9ebb3f3d8199bd10426a59e6444bbc522e60b051be7bbe76bb6f922a732b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff67ba08d0b16d3e221e00a816434f0136d854a4c7c65b4799ed256894d60dcc67472f8ab4132aede4a5f11c9ac7d3a9d064c1fafeb927f7b07d22027b4f1b81
|
7
|
+
data.tar.gz: c10a242203103d90e3f6c18e75daf211b7b2294083bea0a47847d788b5e37beb004d4a95c7be435a50444f3d1b30a06c723ae85918247256c76de102850ba244
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ version: "3"
|
|
36
36
|
|
37
37
|
services:
|
38
38
|
gotenberg:
|
39
|
-
image: gotenberg/gotenberg:
|
39
|
+
image: gotenberg/gotenberg:8
|
40
40
|
restart: always
|
41
41
|
ports:
|
42
42
|
- 3000:3000
|
@@ -85,6 +85,14 @@ File.open('filename.pdf', 'wb') do |file|
|
|
85
85
|
end
|
86
86
|
```
|
87
87
|
|
88
|
+
Pass additional headers for faraday client instance (Authorization, User-Agent, etc.):
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
document = Gotenberg::Chromium.call(ENV['GOTENBERG_URL'], headers: { 'Authorization': 'Bearer token123' }) do |doc|
|
92
|
+
doc.url 'https://my.url'
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
88
96
|
Available exceptions:
|
89
97
|
|
90
98
|
```ruby
|
@@ -385,7 +393,7 @@ The following classes allow you to inject printing values:
|
|
385
393
|
* No JavaScript.
|
386
394
|
* The CSS properties are independent of the ones from the HTML document.
|
387
395
|
* The footer CSS properties override the ones from the header;
|
388
|
-
* Only fonts installed in the Docker image are loaded - see the [Fonts chapter](https://gotenberg.dev/docs/
|
396
|
+
* Only fonts installed in the Docker image are loaded - see the [Fonts chapter](https://gotenberg.dev/docs/configuration#fonts).
|
389
397
|
* Images only work using a base64 encoded source - i.e., `data:image/png;base64, iVBORw0K....`
|
390
398
|
* `background-color` and color `CSS` properties require an additional `-webkit-print-color-adjust: exact` CSS property in order to work.
|
391
399
|
* Assets are not loaded (i.e., CSS files, scripts, fonts, etc.).
|
@@ -435,6 +443,17 @@ document = Gotenberg::Chromium.call(ENV['GOTENBERG_URL']) do |doc|
|
|
435
443
|
end
|
436
444
|
```
|
437
445
|
|
446
|
+
#### Client Extra HTTP headers
|
447
|
+
|
448
|
+
This method just duplicate way of passing headers into faraday client. Have same purpose:
|
449
|
+
|
450
|
+
```ruby
|
451
|
+
document = Gotenberg::Chromium.call(ENV['GOTENBERG_URL']) do |doc|
|
452
|
+
doc.url 'https://my.url'
|
453
|
+
doc.client_extra_http_headers({ 'Authorization': 'Bearer token123' })
|
454
|
+
end
|
455
|
+
```
|
456
|
+
|
438
457
|
#### Fail on console exceptions
|
439
458
|
|
440
459
|
You may force Gotenberg to return a `409 Conflict` response if there are exceptions in the Chromium console:
|
@@ -83,7 +83,7 @@ module Gotenberg
|
|
83
83
|
self
|
84
84
|
end
|
85
85
|
|
86
|
-
# Overrides the default "User-Agent" header.
|
86
|
+
# DEPRECATED in Gotenberg 8. Overrides the default "User-Agent" header.
|
87
87
|
def user_agent user_agent
|
88
88
|
properties['userAgent'] = user_agent
|
89
89
|
|
@@ -92,7 +92,7 @@ module Gotenberg
|
|
92
92
|
|
93
93
|
# Sets extra HTTP headers that Chromium will send when loading the HTML document.
|
94
94
|
def extra_http_headers headers
|
95
|
-
properties['
|
95
|
+
properties['extraHttpHeaders'] = headers.to_json
|
96
96
|
|
97
97
|
self
|
98
98
|
end
|
data/lib/gotenberg/chromium.rb
CHANGED
@@ -13,11 +13,11 @@ module Gotenberg
|
|
13
13
|
class Chromium
|
14
14
|
include Properties, Files, Headers, Metadata, Tools, Extractors
|
15
15
|
|
16
|
-
attr_accessor :base_path
|
16
|
+
attr_accessor :base_path, :client_headers
|
17
17
|
attr_reader :endpoint, :response, :exception
|
18
18
|
|
19
|
-
def self.call(base_path, &block)
|
20
|
-
new(base_path: base_path, &block).call
|
19
|
+
def self.call(base_path, headers: {}, &block)
|
20
|
+
new(base_path: base_path, client_headers: headers, &block).call
|
21
21
|
end
|
22
22
|
|
23
23
|
def initialize args
|
@@ -73,7 +73,7 @@ module Gotenberg
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def client
|
76
|
-
Client.new(base_path)
|
76
|
+
Client.new(base_path, headers: client_headers)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/lib/gotenberg/client.rb
CHANGED
@@ -3,10 +3,11 @@ require 'faraday/multipart'
|
|
3
3
|
|
4
4
|
module Gotenberg
|
5
5
|
class Client
|
6
|
-
attr_reader :base_path
|
6
|
+
attr_reader :base_path, :headers
|
7
7
|
|
8
|
-
def initialize base_path
|
8
|
+
def initialize base_path, headers: {}
|
9
9
|
@base_path = base_path
|
10
|
+
@headers = headers
|
10
11
|
end
|
11
12
|
|
12
13
|
def adapter
|
@@ -19,7 +20,7 @@ module Gotenberg
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def default_headers
|
22
|
-
{'Content-Type' => 'multipart/form-data'}
|
23
|
+
{'Content-Type' => 'multipart/form-data'}.merge(headers)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -3,11 +3,12 @@ module Gotenberg
|
|
3
3
|
attr_accessor :backtrace_dir, :html_debug
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@backtrace_dir =
|
7
|
-
Rails.root
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
@backtrace_dir =
|
7
|
+
if defined?(Rails) && Rails.respond_to?(:root)
|
8
|
+
Rails.root.join('tmp', 'gotenberg')
|
9
|
+
else
|
10
|
+
Dir.mktmpdir
|
11
|
+
end
|
11
12
|
|
12
13
|
@html_debug = false
|
13
14
|
end
|
data/lib/gotenberg/headers.rb
CHANGED
@@ -28,8 +28,8 @@ module Gotenberg
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Sets the extra HTTP headers that Gotenberg will send alongside the request to the webhook and error webhook.
|
31
|
-
def webhook_extra_http_headers
|
32
|
-
headers['Gotenberg-Webhook-Extra-Http-Headers'] =
|
31
|
+
def webhook_extra_http_headers extra_headers
|
32
|
+
headers['Gotenberg-Webhook-Extra-Http-Headers'] = extra_headers.to_json
|
33
33
|
|
34
34
|
self
|
35
35
|
end
|
@@ -41,6 +41,13 @@ module Gotenberg
|
|
41
41
|
self
|
42
42
|
end
|
43
43
|
|
44
|
+
# Sets the extra HTTP headers for faraday client to make request to gotenberg instance
|
45
|
+
def client_extra_http_headers extra_headers
|
46
|
+
headers.merge!(extra_headers)
|
47
|
+
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
44
51
|
private
|
45
52
|
|
46
53
|
def webhook_request?
|
@@ -11,11 +11,11 @@ module Gotenberg
|
|
11
11
|
class Libreoffice
|
12
12
|
include Properties, Files, Headers, Metadata, Tools
|
13
13
|
|
14
|
-
attr_accessor :base_path
|
14
|
+
attr_accessor :base_path, :client_headers
|
15
15
|
attr_reader :endpoint, :response, :exception
|
16
16
|
|
17
|
-
def self.call(base_path, &block)
|
18
|
-
new(base_path: base_path, &block).call
|
17
|
+
def self.call(base_path, headers: {}, &block)
|
18
|
+
new(base_path: base_path, client_headers: headers, &block).call
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize args
|
@@ -63,7 +63,7 @@ module Gotenberg
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def client
|
66
|
-
Client.new(base_path)
|
66
|
+
Client.new(base_path, headers: client_headers)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -11,11 +11,11 @@ module Gotenberg
|
|
11
11
|
class PdfEngines
|
12
12
|
include Properties, Files, Headers, Metadata, Tools
|
13
13
|
|
14
|
-
attr_accessor :base_path
|
14
|
+
attr_accessor :base_path, :client_headers
|
15
15
|
attr_reader :endpoint, :response, :exception
|
16
16
|
|
17
|
-
def self.call(base_path, &block)
|
18
|
-
new(base_path: base_path, &block).call
|
17
|
+
def self.call(base_path, headers: {}, &block)
|
18
|
+
new(base_path: base_path, client_headers: headers, &block).call
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize args
|
@@ -62,7 +62,7 @@ module Gotenberg
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def client
|
65
|
-
Client.new(base_path)
|
65
|
+
Client.new(base_path, headers: client_headers)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/lib/gotenberg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotenberg-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sanzstez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -59,9 +59,6 @@ dependencies:
|
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.2'
|
62
|
-
- - "<"
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: '3'
|
65
62
|
type: :runtime
|
66
63
|
prerelease: false
|
67
64
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,9 +66,6 @@ dependencies:
|
|
69
66
|
- - ">="
|
70
67
|
- !ruby/object:Gem::Version
|
71
68
|
version: '2.2'
|
72
|
-
- - "<"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '3'
|
75
69
|
description: A gem that provides a client interface for the Gotenberg PDF generate
|
76
70
|
service
|
77
71
|
email:
|
@@ -131,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
125
|
- !ruby/object:Gem::Version
|
132
126
|
version: '0'
|
133
127
|
requirements: []
|
134
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.5.22
|
135
129
|
signing_key:
|
136
130
|
specification_version: 4
|
137
131
|
summary: A gem that provides a client interface for the Gotenberg PDF generate service
|