gotenberg-ruby 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- 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/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: 88445f0f58092b9e2d6be42c5cc98a7a89e26690308b11d61b58335f843882c0
|
4
|
+
data.tar.gz: cf50d4938b42a7684d57a377e06743e599a0a3224da06d073a17aeeaee203d87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cc1b8b2e3ef620d6bf6d3468ad65e3f005cbd86d6f658ea908b7acfb4ef584e5f72c85f0f0ffdc22cb39d974d9fa2f9484c087c24154ae88cb80561e32b6e1e
|
7
|
+
data.tar.gz: 44db5856d4e4ca62396296a968d69dde66f547e5e98a012f0ea1061c254ca2a4525ad36b3007c6d5e8dd47e7ab11ea9d7feea924edc9be738db123043b915197
|
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
|
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.12
|
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: 2024-01-26 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.4.10
|
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
|