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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ae377666e9721fcf26fda08d4791500e0d8e28e6eaddcbac702e1238c5815d9
4
- data.tar.gz: e749a87289fa44a1ce4e47c7549855932400512b0877bd72e9e32eb606652ce1
3
+ metadata.gz: 98f332cd6e3854f2d3d5c4df1947f4aa6c0195e39439d22f9d9766f461e16951
4
+ data.tar.gz: ea268c17bc32203477eb74502c404d6563fa83fe5967184a59a0c0f53418d889
5
5
  SHA512:
6
- metadata.gz: c3dac5f68aa57d4f32781b7937b27b5dadb7cda557e6d802c9c1015bf23a78a4db952a797ca9e15a5f4db142a34de6b3a6fae48cae229a6358c7140a3df0811b
7
- data.tar.gz: 78bb021dcac458206a562b8dc6a423823765f591d69a86f76dd1eb7cca10e5141e733a0fd8e40bb4f43c38b1e98a0c70c2d9fdfa64edcbf399f0e2df04cb5b2f
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).
@@ -1,3 +1,3 @@
1
1
  module PdfGem
2
- VERSION = '1.0.9'
2
+ VERSION = '1.0.10'
3
3
  end
@@ -6,12 +6,19 @@ const path = require('path');
6
6
  (async () => {
7
7
 
8
8
  var stdinBuffer = fs.readFileSync(0);
9
- const filename = path.join(path.dirname(__filename), 'tmp', crypto.randomBytes(40).toString('hex')+ '.pdf');
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: 'networkidle2', timeout: (params.timeout == null ? 30000 : params.timeout)});
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.9
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-28 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails