pdf_gem 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/pdf_gem/version.rb +1 -1
- data/lib/pdf_generator.js +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98f332cd6e3854f2d3d5c4df1947f4aa6c0195e39439d22f9d9766f461e16951
|
4
|
+
data.tar.gz: ea268c17bc32203477eb74502c404d6563fa83fe5967184a59a0c0f53418d889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90043a43775a11bdac9d658c1fa3f57b2528839ee517adc30ac7a79ce152caf02875a284b571656aca0d6e637bcaad8c2948750afeefb0f84186bae83cca8af8
|
7
|
+
data.tar.gz: 552baaa16c13c45ffc648b2291cc9f6f3cb275b5b7bd37b782c6834d67bd5fefec219a19ec80391172aa3a800701f53a3879dddbd64e060820dd5ea246bb8da1
|
data/README.md
CHANGED
@@ -71,6 +71,11 @@ PdfGem.pdf_from_string(options)
|
|
71
71
|
- `options` <[Object]> Options object which might have the following properties:
|
72
72
|
- `url` <[string]> (Used only for PdfGem.pdf_from_url) This is the url to render.
|
73
73
|
- `timeout` <[number]> Maximum navigation time in ms, default is 3000 ms.
|
74
|
+
- `waitUntil` <[string]|[Array]<[string]>> When to consider navigation succeeded, defaults to `load`. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:
|
75
|
+
- `load` - consider navigation to be finished when the `load` event is fired.
|
76
|
+
- `domcontentloaded` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
|
77
|
+
- `networkidle0` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
|
78
|
+
- `networkidle2` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
|
74
79
|
- `html` <[string]> (Used only for PdfGem.pdf_from_string) This is the html string to render.
|
75
80
|
- `disposition` <[string]> (Use only for controller render) Disposition string (inline/attachment).
|
76
81
|
- `formats` <[string]> (Use only for controller render) Force to load view of a particular format (pdf, html, xml).
|
data/lib/pdf_gem/version.rb
CHANGED
data/lib/pdf_generator.js
CHANGED
@@ -6,12 +6,19 @@ const path = require('path');
|
|
6
6
|
(async () => {
|
7
7
|
|
8
8
|
var stdinBuffer = fs.readFileSync(0);
|
9
|
-
|
9
|
+
|
10
|
+
var tmp = path.join(path.dirname(__filename), 'tmp');
|
11
|
+
|
12
|
+
if (!fs.existsSync(tmp)){
|
13
|
+
fs.mkdirSync(tmp);
|
14
|
+
}
|
15
|
+
|
16
|
+
const filename = path.join(tmp, crypto.randomBytes(40).toString('hex')+ '.pdf');
|
10
17
|
const browser = await puppeteer.launch();
|
11
18
|
try{
|
12
19
|
const params = {...JSON.parse(Buffer.from(stdinBuffer.toString(), 'base64').toString('utf-8')), ...{path: filename}};
|
13
20
|
const page = await browser.newPage();
|
14
|
-
await page.goto(params.url, {waitUntil: '
|
21
|
+
await page.goto(params.url, {waitUntil: (params.waitUntil != null ? params.waitUntil : 'load'), timeout: (params.timeout == null ? 30000 : params.timeout)});
|
15
22
|
await page.pdf(params);
|
16
23
|
process.stdout.write(filename)
|
17
24
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdf_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Blasina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|