@browserless/pdf 10.10.0 → 10.10.1

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.js +9 -12
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/pdf",
3
3
  "description": "Convert websites to high-quality PDFs with customizable margins, background printing, and optimized scaling.",
4
4
  "homepage": "https://browserless.js.org/#/?id=pdfurl-options",
5
- "version": "10.10.0",
5
+ "version": "10.10.1",
6
6
  "main": "src",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -30,8 +30,8 @@
30
30
  "conversion"
31
31
  ],
32
32
  "dependencies": {
33
- "@browserless/goto": "^10.10.0",
34
- "@browserless/screenshot": "^10.10.0",
33
+ "@browserless/goto": "^10.10.1",
34
+ "@browserless/screenshot": "^10.10.1",
35
35
  "@kikobeats/time-span": "~1.0.11",
36
36
  "debug-logfmt": "~1.4.7",
37
37
  "pretty-ms": "~7.0.1"
@@ -47,5 +47,5 @@
47
47
  "test": "exit 0"
48
48
  },
49
49
  "license": "MIT",
50
- "gitHead": "9b80e677418f2defb804d39043680fe65e3e277b"
50
+ "gitHead": "32f6e72bcb489a83ac9659520a3961aeb97c47b7"
51
51
  }
package/src/index.js CHANGED
@@ -49,23 +49,20 @@ module.exports = ({ goto, ...gotoOpts } = {}) => {
49
49
  do {
50
50
  ++retry
51
51
  const screenshotTime = timeSpan()
52
- ;[isWhite, pdfBuffer] = await Promise.all([
53
- isWhiteScreenshot(
54
- await page.screenshot({
55
- ...opts,
56
- optimizeForSpeed: true,
57
- type: 'jpeg',
58
- quality: 30
59
- })
60
- ),
61
- generatePdf(page),
62
- retry === 1 ? goto.waitUntilAuto(page, { timeout: opts.timeout }) : Promise.resolve()
63
- ])
52
+ const screenshot = await page.screenshot({
53
+ ...opts,
54
+ optimizeForSpeed: true,
55
+ type: 'jpeg',
56
+ quality: 30
57
+ })
58
+ isWhite = await isWhiteScreenshot(screenshot)
59
+ if (retry === 1) await goto.waitUntilAuto(page, { timeout: opts.timeout })
64
60
  debug('retry', { waitUntil, isWhite, retry, duration: screenshotTime() })
65
61
  } while (isWhite && timePdf() < timeout)
66
62
 
67
63
  debug({ waitUntil, isWhite, timeout, duration: require('pretty-ms')(timePdf()) })
68
64
  }
65
+ pdfBuffer = await generatePdf(page)
69
66
  }
70
67
 
71
68
  return pdfBuffer