pdfgen 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/javascript_bin/make_pdf.js +6 -0
- data/lib/pdfgen.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 590a851860d5f2838dddc23fd7140f6cfb388339
|
4
|
+
data.tar.gz: 100f36d71b3b3944a4f007554ebcace4a2ff3ba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d612a4ce6c8996cbfde86d36e170325646a72b06190fa23f20eca14b70153ca6babad62737b7bf30159e93d578e3fc583999e78d20a28cfd7121c8f24f83195
|
7
|
+
data.tar.gz: 87554103bf9bad7cd4265f608891418d9bce8e13b65e66f7da4860a861c25d9b93d5395c5c6f99406b6100ab41bcaa0a980014714db8f3fbf9d27413bfa68dff
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -18,6 +18,7 @@ stdin.on('end', function () {
|
|
18
18
|
var viewport_options = options['viewport_options'];
|
19
19
|
var media_type = options['emulate_media'];
|
20
20
|
var launch_options = options['launch_options'];
|
21
|
+
var wait_for_timeout = options['wait_for_timeout'];
|
21
22
|
|
22
23
|
module.paths.push(current_path + '/node_modules');
|
23
24
|
|
@@ -30,6 +31,7 @@ stdin.on('end', function () {
|
|
30
31
|
const page = await browser.newPage();
|
31
32
|
|
32
33
|
await page.setContent(html);
|
34
|
+
|
33
35
|
if (typeof media_type !== 'undefined' && media_type) {
|
34
36
|
await page.emulateMedia(media_type);
|
35
37
|
}
|
@@ -38,6 +40,10 @@ stdin.on('end', function () {
|
|
38
40
|
await page.setViewport(viewport_options);
|
39
41
|
}
|
40
42
|
|
43
|
+
if (typeof wait_for_timeout !== 'undefined' && wait_for_timeout) {
|
44
|
+
await page.waitFor(wait_for_timeout);
|
45
|
+
}
|
46
|
+
|
41
47
|
const pdf_output = await page.pdf(pdf_options);
|
42
48
|
stdout.write(pdf_output);
|
43
49
|
await browser.close();
|
data/lib/pdfgen.rb
CHANGED
@@ -14,6 +14,7 @@ class Pdfgen
|
|
14
14
|
@viewport_options = nil
|
15
15
|
@emulate_media = nil
|
16
16
|
@launch_options = Hash.new
|
17
|
+
@wait_for_timeout = nil
|
17
18
|
end
|
18
19
|
|
19
20
|
def set_viewport(viewport_options)
|
@@ -31,6 +32,12 @@ class Pdfgen
|
|
31
32
|
self
|
32
33
|
end
|
33
34
|
|
35
|
+
def wait_for_timeout(wait_for_timeout)
|
36
|
+
raise TypeError.new("Timeout must be an integer or respond to #to_i") unless wait_for_timeout.kind_of?(Integer) || (wait_for_timeout.respond_to?(:to_i) && wait_for_timeout.to_i)
|
37
|
+
@wait_for_timeout = wait_for_timeout
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
34
41
|
def to_pdf(opts = {})
|
35
42
|
stdin_options = { pdf_options: opts, current_path: Dir.pwd, launch_options: @launch_options }
|
36
43
|
stdin_options = stdin_options.merge(viewport_options: @viewport_options) if @viewport_options
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdfgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Fox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|