Skip to content

Commit 2a43c35

Browse files
feat: added timeout parameter to pdf generator (#388)
Co-authored-by: Maciej Urbańczyk <[email protected]>
1 parent 18b7ef3 commit 2a43c35

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ npm install -g @asyncapi/generator
4343
| version | Override the version of your application provided under `info.version` location in the specification file. | No | Version is taken from the spec file. | *Any* ([See Semver versioning](https://semver.org/)) | `1.0.0` |
4444
| singleFile | Set output into one html-file with styles and scripts inside | No | `false` | `true`,`false` | `true` |
4545
| outFilename | The filename of the output file. | No | `index.html` | *Any* | `asyncapi.html` |
46-
| pdf | Generates output HTML as PDF | No | `false` | `true,false` | `false` |
46+
| pdf | Generates output HTML as PDF | No | `false` | `true`, `false` | `true` |
47+
| pdfTimeout | Timeout (in ms) used to generate the PDF | No | 30000 | >=0 | 1000 |
4748
| config | Inline stringified JSON or a path to a JSON file to override default React component config. The config override is merged with the default config using the [JSON Merge Patch](https://tools.ietf.org/html/rfc7386) algorithm. | No | `{ "show": { "sidebar": true }, "sidebar": { "showOperations": "byDefault" } }` | [JSON config for the React component](https://github.com/asyncapi/asyncapi-react/blob/next/docs/configuration/config-modification.md#definition) | `{"show":{"sidebar":false}}` |
4849

4950
> **NOTE**: If you only generate an HTML website, set the environment variable `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD` to `true` and the generator will skip downloading chromium.

hooks/99_generatePdf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
toClick && typeof button.dispatchEvent === 'function' && button.dispatchEvent(new Event('click', { bubbles: true }));
3232
}));
3333

34-
await page.pdf({ format: 'A4', path: `${targetDir}/index.pdf`, printBackground: true });
34+
await page.pdf({ format: 'A4', path: `${targetDir}/index.pdf`, printBackground: true, timeout: parseInt(templateParams.pdfTimeout, 10) });
3535
browser.close();
3636
} catch(e) {
3737
console.error(e);

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
"description": "Set to `true` to get index.pdf generated next to your index.html",
105105
"default": false
106106
},
107+
"pdfTimeout": {
108+
"description": "The timeout (in ms) used to generate the pdf",
109+
"default": 30000,
110+
"required": false
111+
},
107112
"config": {
108113
"description": "Stringified JSON or a path to a JSON file to override the default React component config. The config override is merged with the default config using the [JSON Merge Patch](https://tools.ietf.org/html/rfc7386) algorithm.",
109114
"default": "",

0 commit comments

Comments
 (0)