p3x-html-pdf 2025.4.117 → 2025.4.119
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.
- package/README.md +61 -17
- package/package.json +1 -1
- package/test-output.pdf +0 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
# 📃 Generates PDF from HTML with custom headers and footers with wkhtmltopdf v2025.4.
|
|
9
|
+
# 📃 Generates PDF from HTML with custom headers and footers with wkhtmltopdf v2025.4.119
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -35,13 +35,15 @@ v22.13.0
|
|
|
35
35
|
[//]: #@corifeus-header:end
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
**p3x-html-pdf** is a Node.js package that generates PDFs from HTML with custom headers and footers using `wkhtmltopdf`. It is a robust tool for creating professional-grade PDFs with features like:
|
|
39
39
|
|
|
40
40
|
- 📜 **Dynamic Headers and Footers**: Add placeholders for page numbers, dates, and more.
|
|
41
41
|
- 🛠️ **Customizable Layouts**: Configure margins, orientation, and paper size.
|
|
42
42
|
- ⚡ **Async/Await Support**: Modern JavaScript compatibility for efficient workflows.
|
|
43
43
|
- 🔄 **Dynamic Content**: Render data-driven tables and content dynamically.
|
|
44
44
|
|
|
45
|
+
---
|
|
46
|
+
|
|
45
47
|
## 🚀 Installation
|
|
46
48
|
|
|
47
49
|
Install via Yarn:
|
|
@@ -50,18 +52,28 @@ Install via Yarn:
|
|
|
50
52
|
yarn add p3x-html-pdf
|
|
51
53
|
```
|
|
52
54
|
|
|
55
|
+
Or install via npm:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install p3x-html-pdf
|
|
59
|
+
```
|
|
60
|
+
|
|
53
61
|
Import in your project:
|
|
54
62
|
|
|
55
63
|
```javascript
|
|
56
64
|
const { generate } = require('p3x-html-pdf');
|
|
57
65
|
```
|
|
58
66
|
|
|
67
|
+
---
|
|
68
|
+
|
|
59
69
|
## 🛠️ Features
|
|
60
70
|
|
|
61
|
-
- 📜 **Custom Headers and Footers
|
|
62
|
-
- 📏 **Flexible Page Settings
|
|
63
|
-
- ⚡ **Async/Await Support
|
|
64
|
-
- 📊 **Dynamic Tables and Content
|
|
71
|
+
- 📜 **Custom Headers and Footers**: Create professional headers and footers with dynamic placeholders.
|
|
72
|
+
- 📏 **Flexible Page Settings**: Set paper size, orientation, margins, and more.
|
|
73
|
+
- ⚡ **Async/Await Support**: Fully compatible with modern JavaScript workflows.
|
|
74
|
+
- 📊 **Dynamic Tables and Content**: Generate tables and other dynamic HTML content easily.
|
|
75
|
+
|
|
76
|
+
---
|
|
65
77
|
|
|
66
78
|
## 📖 Usage Example
|
|
67
79
|
|
|
@@ -116,12 +128,16 @@ const path = require('path');
|
|
|
116
128
|
try {
|
|
117
129
|
await generate(options);
|
|
118
130
|
console.log('✅ PDF generated successfully!');
|
|
131
|
+
// or options.save = false
|
|
132
|
+
const buffer = await generate(options);
|
|
119
133
|
} catch (err) {
|
|
120
134
|
console.error('❌ Error generating PDF:', err);
|
|
121
135
|
}
|
|
122
136
|
})();
|
|
123
137
|
```
|
|
124
138
|
|
|
139
|
+
---
|
|
140
|
+
|
|
125
141
|
## 🔧 Configuration
|
|
126
142
|
|
|
127
143
|
### Options
|
|
@@ -131,11 +147,19 @@ const path = require('path');
|
|
|
131
147
|
- `template.format`: Page size, e.g., `A4`, `Letter`.
|
|
132
148
|
- `template.orientation`: Page orientation (`portrait` or `landscape`).
|
|
133
149
|
- `template.marginLeft`, `template.marginRight`: Margins in mm.
|
|
150
|
+
- `template.copies`: Copies to generate.
|
|
151
|
+
- `template.fixedWidth` and `template.fixedHeight`: If above zero, generates in millimeters.
|
|
134
152
|
- `html`: HTML content with placeholders.
|
|
135
153
|
- **title**: PDF document title.
|
|
136
154
|
- **saveFile**: Path for saving the PDF.
|
|
137
155
|
|
|
138
|
-
|
|
156
|
+
For more options, check the official [wkhtmltopdf usage guide](https://wkhtmltopdf.org/usage/wkhtmltopdf.txt).
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 🌟 Placeholders
|
|
161
|
+
|
|
162
|
+
You can use placeholders in your HTML for dynamic data:
|
|
139
163
|
|
|
140
164
|
- `${page}`: Current page.
|
|
141
165
|
- `${pages}`: Total pages.
|
|
@@ -143,30 +167,50 @@ const path = require('path');
|
|
|
143
167
|
- `${isodate}`: ISO date format.
|
|
144
168
|
- `${time}`: Current time.
|
|
145
169
|
|
|
170
|
+
Example:
|
|
171
|
+
|
|
172
|
+
```html
|
|
173
|
+
<div id="p3x-footer" data-height="15mm">
|
|
174
|
+
<p>Page ${page} of ${pages} - Generated on ${date}</p>
|
|
175
|
+
</div>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
146
180
|
## 📊 Advanced Features
|
|
147
181
|
|
|
148
182
|
- **Debugging**: Use `debug: true` to enable detailed logs.
|
|
149
|
-
- **Header/Footer Templates**:
|
|
183
|
+
- **Header/Footer Templates**: Create rich HTML templates for headers/footers.
|
|
184
|
+
- **Dynamic Content**: Inject dynamic tables, invoices, or other content into the PDF.
|
|
185
|
+
|
|
186
|
+
---
|
|
150
187
|
|
|
151
|
-
##
|
|
188
|
+
## 🌍 Architecture
|
|
152
189
|
|
|
153
|
-
|
|
190
|
+
`p3x-html-pdf` works seamlessly on Linux and Windows.
|
|
154
191
|
|
|
155
|
-
|
|
192
|
+
### ARM64 Support
|
|
156
193
|
|
|
157
|
-
|
|
194
|
+
If `os.arch() === 'arm64'`, the package automatically sets the `wkhtmltopdf` path to `/usr/local/bin/wkhtmltopdf-arm64`.
|
|
195
|
+
Download the binary manually and place it there:
|
|
196
|
+
[wkhtmltopdf-arm64 binary](https://github.com/houseoftech/wkhtmltopdf-arm64/raw/refs/heads/master/bin/wkhtmltopdf-arm64).
|
|
158
197
|
|
|
159
198
|
---
|
|
160
199
|
|
|
161
|
-
|
|
200
|
+
## 🖼️ Example Output
|
|
201
|
+
|
|
202
|
+
Check out an example output PDF:
|
|
203
|
+
[Example PDF](https://cdn.corifeus.com/git/html-pdf/test-output.pdf).
|
|
162
204
|
|
|
163
205
|
---
|
|
164
206
|
|
|
165
|
-
##
|
|
166
|
-
|
|
167
|
-
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
This project is licensed under the MIT License.
|
|
168
210
|
|
|
211
|
+
---
|
|
169
212
|
|
|
213
|
+
**Happy PDF Generating!** 🎉
|
|
170
214
|
|
|
171
215
|
[//]: #@corifeus-footer
|
|
172
216
|
|
|
@@ -218,7 +262,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.hu](ht
|
|
|
218
262
|
---
|
|
219
263
|
|
|
220
264
|
|
|
221
|
-
[**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.
|
|
265
|
+
[**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.119
|
|
222
266
|
|
|
223
267
|
[](https://www.npmjs.com/package/p3x-html-pdf) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [](https://www.patrikx3.com/en/front/contact) [](https://www.facebook.com/corifeus.software)
|
|
224
268
|
|
package/package.json
CHANGED
package/test-output.pdf
CHANGED
|
Binary file
|