From bfb77d6b4968c53462a91f4315fe982e892247e4 Mon Sep 17 00:00:00 2001 From: Knut Behrends Date: Sat, 8 Mar 2025 13:41:57 +0100 Subject: [PATCH] docs: update puppeteer launch options in README for clarity and CI/CD usage --- packages/vuepress-plugin-export-pdf-v1/README.md | 13 ++++++++++++- packages/vuepress-plugin-export-pdf-v2/README.md | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/vuepress-plugin-export-pdf-v1/README.md b/packages/vuepress-plugin-export-pdf-v1/README.md index 1634f5e..4858004 100644 --- a/packages/vuepress-plugin-export-pdf-v1/README.md +++ b/packages/vuepress-plugin-export-pdf-v1/README.md @@ -105,7 +105,7 @@ config options: - `outFile` - name of output file (default `vuepress-YYMMDD-HHmmss.pdf`) - `outDir` - Directory of output files (default `package.json` file exists in directory) - `routePatterns` - Specify the patterns of files you want to be exported. The patterns are relative to the source directory (default `["/**", "!/404.html"]`).Patterns to match Route path using [multimatch](https://github.com/sindresorhus/multimatch) -- `puppeteerLaunchOptions` - [Puppeteer launch options object](https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.puppeteerlaunchoptions.md) +- `puppeteerLaunchOptions` - [Puppeteer launch options object](https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.launchoptions.md) - `pdfOptions` - [Valid options to configure PDF generation via Page.pdf()](https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.pdfoptions.md) (default `{ format: 'A4 }`), **`pageNumber` and `totalPages` of `headerTemplate` and `footerTemplate` cannot be used because of [this reason](https://github.com/condorheroblog/vitepress-export-pdf/issues/5)** - `pdfOutlines` - Keep PDF outlines/bookmarks(default `true`) - `urlOrigin`: Change the origin of the print url(Option `displayHeaderFooter` of `pdfOptions` is true) - ([How do I change the URL point to the localhost](https://github.com/condorheroblog/vuepress-plugin-export-pdf/issues/5)) @@ -180,6 +180,17 @@ export default defineUserConfig({ > Note: `!` at the beginning of a pattern will negate the match +### Run in CI/CD environment + +```ts +// In CI/CD pipeline, if Chrome runs as `root` user, set options to avoid permission issues. +export default defineUserConfig({ + // ... + puppeteerLaunchOptions: { headless: true, args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox' ]}, + // ... +}) +``` + ### PDF print style By default, `A4` paper is used for printing, The size of A4 paper is (8.27in x 11.7in), One inch is equal to ninety-six pixels: `1 in = 96 pixel (X)` ,the inch unit of A4 is converted to (793.92px x 1123.2px). diff --git a/packages/vuepress-plugin-export-pdf-v2/README.md b/packages/vuepress-plugin-export-pdf-v2/README.md index cfed60f..97037e5 100644 --- a/packages/vuepress-plugin-export-pdf-v2/README.md +++ b/packages/vuepress-plugin-export-pdf-v2/README.md @@ -106,7 +106,7 @@ config options: - `outFile` - name of output file (default `vuepress-YYMMDD-HHmmss.pdf`) - `outDir` - Directory of output files (default `package.json` file exists in directory) - `routePatterns` - Specify the patterns of files you want to be exported. The patterns are relative to the source directory (default `["/**", "!/404.html"]`).Patterns to match Route path using [multimatch](https://github.com/sindresorhus/multimatch) -- `puppeteerLaunchOptions` - [Puppeteer launch options object](https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.puppeteerlaunchoptions.md) +- `puppeteerLaunchOptions` - [Puppeteer launch options object](https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.launchoptions.md) - `pdfOptions` - [Valid options to configure PDF generation via Page.pdf()](https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.pdfoptions.md) (default `{ format: 'A4 }`), **`pageNumber` and `totalPages` of `headerTemplate` and `footerTemplate` cannot be used because of [this reason](https://github.com/condorheroblog/vitepress-export-pdf/issues/5)** - `pdfOutlines` - Keep PDF outlines/bookmarks(default `true`) - `urlOrigin`: Change the origin of the print url(Option `displayHeaderFooter` of `pdfOptions` is true) - ([How do I change the URL point to the localhost](https://github.com/condorheroblog/vuepress-plugin-export-pdf/issues/5)) @@ -160,6 +160,17 @@ export default defineUserConfig({ > Note: `!` at the beginning of a pattern will negate the match +### Run in CI/CD environment + +```ts +// In CI/CD pipeline, if Chrome runs as `root` user, set options to avoid permission issues. +export default defineUserConfig({ + // ... + puppeteerLaunchOptions: { headless: true, args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox' ]}, + // ... +}) +``` + ### PDF print style By default, `A4` paper is used for printing, The size of A4 paper is (8.27in x 11.7in), One inch is equal to ninety-six pixels: `1 in = 96 pixel (X)` ,the inch unit of A4 is converted to (793.92px x 1123.2px).