Skip to content

Commit 1d32d11

Browse files
committed
chore: updated README.md, add parameters section and descriptions
1 parent 466d389 commit 1d32d11

File tree

1 file changed

+121
-1
lines changed

1 file changed

+121
-1
lines changed

README.md

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Installation
66

77
```sh
8-
npm install pdfweaver
8+
npm install pdfweaver
99
```
1010

1111
## Usage
@@ -41,3 +41,123 @@ async function returnPDFBuffer() {
4141
return pdfBuffer;
4242
}
4343
```
44+
45+
## Parameters
46+
47+
- **`file`** (Type: `Object`)
48+
should contain one of this properties
49+
50+
- **`url`** (Type: `String`)
51+
URL of page you want to generate PDF from
52+
53+
- **`content`** (Type: `String`)
54+
HTML code to generate PDF
55+
56+
- **`options`** (Type: `Object`)
57+
PDFOptions type coming from puppeteer, declares PDF generation rules
58+
- **`path`** (Type: `String`)
59+
The file path to save the generated PDF. If not specified, the PDF is returned as a buffer.
60+
61+
- **`scale`** (Type: `Number`)
62+
The scale of the webpage rendering. Must be between 0.1 and 2.
63+
**Default:** `1`
64+
65+
- **`displayHeaderFooter`** (Type: `Boolean`)
66+
Whether to include headers and footers.
67+
**Default:** `false`
68+
69+
- **`headerTemplate`** (Type: `String`)
70+
The HTML template for the header. Requires `displayHeaderFooter: true`.
71+
72+
- **`footerTemplate`** (Type: `String`)
73+
The HTML template for the footer. Requires `displayHeaderFooter: true`.
74+
75+
- **`printBackground`** (Type: `Boolean`)
76+
Whether to include the background graphics.
77+
**Default:** `false`
78+
79+
- **`landscape`** (Type: `Boolean`)
80+
Whether to generate the PDF in landscape orientation.
81+
**Default:** `false`
82+
83+
- **`pageRanges`** (Type: `String`)
84+
The page ranges to print, e.g., `"1-5, 8, 11-13"`.
85+
**Default:** `"all"`
86+
87+
- **`format`** (Type: `String`)
88+
The paper format (e.g., `"A4"`, `"Letter"`). If set, overrides `width` and `height`.
89+
90+
- **`width`** (Type: `String`)
91+
Paper width, accepts values like `"8.5in"`, `"21cm"`.
92+
93+
- **`height`** (Type: `String`)
94+
Paper height, accepts values like `"11in"`, `"29.7cm"`.
95+
96+
- **`margin`** (Type: `Object`)
97+
Margins for the PDF. Object properties include:
98+
- **`top`** (Type: `String`) | Margin for the top of the page.
99+
- **`right`** (Type: `String`) | Margin for the right of the page.
100+
- **`bottom`** (Type: `String`) | Margin for the bottom of the page.
101+
- **`left`** (Type: `String`) | Margin for the left of the page.
102+
103+
- **`preferCSSPageSize`** (Type: `Boolean`)
104+
Whether to prefer CSS-defined page size over the `width`/`height` or `format`.
105+
**Default:** `false`
106+
107+
- **`omitBackground`** (Type: `Boolean`)
108+
Hides the default white background.
109+
**Default:** `false`
110+
111+
- **`timeout`** (Type: `Number`)
112+
Maximum time (in milliseconds) to wait for the PDF generation.
113+
**Default:** `30000` (30 seconds)
114+
115+
- **`laungOptions`** (Type: `Object`)
116+
puppeteer browser configuration options
117+
- **`headless`** (Type: `Boolean` or `String`)
118+
Whether to run the browser in headless mode.
119+
**Default:** `true`
120+
Can also be set to `"new"` for new headless mode.
121+
122+
- **`executablePath`** (Type: `String`)
123+
Path to a specific browser executable to use.
124+
125+
- **`args`** (Type: `Array<String>`)
126+
Additional arguments to pass to the browser instance.
127+
example:
128+
```js
129+
args: ['--no-sandbox', '--disable-setuid-sandbox']
130+
```
131+
132+
- **`ignoreDefaultArgs`** (Type: `Boolean` or `Array<String>`)
133+
If `true`, Puppeteer won't use its default arguments.
134+
If an array is provided, it filters out specific default arguments.
135+
136+
- **`timeout`** (Type: `Number`)
137+
Maximum time (in milliseconds) to wait for the browser to start.
138+
**Default:** `30000` (30 seconds)
139+
140+
- **`dumpio`** (Type: `Boolean`)
141+
Whether to pipe the browser process stdout and stderr into the parent process.
142+
**Default:** `false`
143+
144+
- **`env`** (Type: `Object`)
145+
Environment variables to pass to the browser instance.
146+
147+
- **`pipe`** (Type: `Boolean`)
148+
Connects to the browser over a pipe instead of a WebSocket.
149+
**Default:** `false`
150+
151+
- **`product`** (Type: `String`)
152+
Specifies which browser to use. Options are `"chrome"` or `"firefox"`.
153+
**Default:** `"chrome"`
154+
155+
- **`extraPrefsFirefox`** (Type: `Object`)
156+
Additional preferences to configure for Firefox. Only applicable when using Firefox.
157+
158+
- **`waitForInitialPage`** (Type: `Boolean`)
159+
Whether to wait for the initial page to load after launching.
160+
**Default:** `true`
161+
162+
- **`userDataDir`** (Type: `String`)
163+
Path to a user data directory to use for the browser session.

0 commit comments

Comments
 (0)