Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Puppeteer to 18 + Typescript 4.9.5 + node 18 lts #51

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
},
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
]
}
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## ⚠️ Caution!

Currently, this package is not catching up with docusaurus v2 HTML markup, so command may not find the correct HTML to loop through docs. Please modify the command to find correct HTML markup by yourself.

## 📌 Introduction

This is a PDF generator from document website such as `docusaurus`, `vuepress`, `mkdocs`.


## ⚡ Usage

For [docusaurus v1](https://v1.docusaurus.io/docs/en/installation)
Expand All @@ -16,21 +16,21 @@ npx mr-pdf --initialDocURLs="https://v1.docusaurus.io/docs/en/installation" --pa

## 🍗 CLI Options

| Option | Required | Description |
| ---------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--initialDocURLs` | Yes | set URL to start generating PDF from. |
| `--contentSelector` | Yes | used to find the part of main content |
| `--paginationSelector` | Yes | CSS Selector used to find next page to be printed for looping. |
| `--excludeURLs` | No | URLs to be excluded in PDF |
| `--excludeSelectors` | No | exclude selectors from PDF. Separate each selector **with comma and no space**. But you can use space in each selector. ex: `--excludeSelectors=".nav,.next > a"` |
| `--cssStyle` | No | CSS style to adjust PDF output ex: `--cssStyle="body{padding-top: 0;}"` \*If you're project owner you can use `@media print { }` to edit CSS for PDF. |
| `--outputPDFFilename` | No | name of the output PDF file. Default is `mr-pdf.pdf` |
| `--pdfMargin` | No | set margin around PDF file. Separate each margin **with comma and no space**. ex: `--pdfMargin="10,20,30,40"`. This sets margin `top: 10px, right: 20px, bottom: 30px, left: 40px` |
| `--pdfFormat` | No | pdf format ex: `--pdfFormat="A3"`. Please check this link for available formats [Puppeteer document](https://pptr.dev/#?product=Puppeteer&version=v5.2.1&show=api-pagepdfoptions) |
| `--disableTOC` | No | Optional toggle to show the table of contents or not |
| `--coverTitle` | No | Title for the PDF cover. |
| `--coverImage` | No | `<src>` Image for PDF cover (does not support SVG) |
| `--coverSub` | No | Subtitle the for PDF cover. Add `<br/>` tags for multiple lines. |
| Option | Required | Description |
| ---------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--initialDocURLs` | Yes | set URL to start generating PDF from. |
| `--contentSelector` | Yes | used to find the part of main content |
| `--paginationSelector` | Yes | CSS Selector used to find next page to be printed for looping. |
| `--excludeURLs` | No | URLs to be excluded in PDF |
| `--excludeSelectors` | No | exclude selectors from PDF. Separate each selector **with comma and no space**. But you can use space in each selector. ex: `--excludeSelectors=".nav,.next > a"` |
| `--cssStyle` | No | CSS style to adjust PDF output ex: `--cssStyle="body{padding-top: 0;}"` \*If you're project owner you can use `@media print { }` to edit CSS for PDF. |
| `--outputPDFFilename` | No | name of the output PDF file. Default is `mr-pdf.pdf` |
| `--pdfMargin` | No | set margin around PDF file. Separate each margin **with comma and no space**. ex: `--pdfMargin="10,20,30,40"`. This sets margin `top: 10px, right: 20px, bottom: 30px, left: 40px` |
| `--paperFormat` | No | pdf format ex: `--paperFormat="A3"`. Please check this link for available formats [Puppeteer document](https://pptr.dev/#?product=Puppeteer&version=v5.2.1&show=api-pagepdfoptions) |
| `--disableTOC` | No | Optional toggle to show the table of contents or not |
| `--coverTitle` | No | Title for the PDF cover. |
| `--coverImage` | No | `<src>` Image for PDF cover (does not support SVG) |
| `--coverSub` | No | Subtitle the for PDF cover. Add `<br/>` tags for multiple lines. |
| `--headerTemplate` | No | HTML template for the print header. Please check this link for details of injecting values [Puppeteer document](https://pptr.dev/#?product=Puppeteer&show=api-pagepdfoptions) |
| `--footerTemplate` | No | HTML template for the print footer. Please check this link for details of injecting values [Puppeteer document](https://pptr.dev/#?product=Puppeteer&show=api-pagepdfoptions) |
| | | |
Expand Down Expand Up @@ -127,6 +127,7 @@ npx mr-pdf --initialDocURLs="https://squidfunk.github.io/mkdocs-material/getting
#### PR to add new docs is welcome here... 😸

## 📄 How `mr-pdf` works

1. [puppter](https://pptr.dev/) can make html to PDF like you can print HTML page in chrome browser
2. so, the idea of mr-pdf is **generating one big HTML through looping page link, then run [`page.pdf()`](https://github.com/puppeteer/puppeteer/blob/v13.1.3/docs/api.md#pagepdfoptions)** from puppter to generate PDF.

Expand Down
Loading