p3x-html-pdf 2025.4.155 → 2025.4.157
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 +13 -4
- package/package.json +1 -1
- package/src/header-footer.html +7 -5
- package/test/test.js +12 -2
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.157
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -215,9 +215,11 @@ Headers and footers in `p3x-html-pdf` are managed via HTML templates. You can:
|
|
|
215
215
|
- **Header IDs**:
|
|
216
216
|
- `p3x-header`: The default header for all pages.
|
|
217
217
|
- `p3x-header-<page>`: A header for a specific page (e.g., `p3x-header-1` for the first page).
|
|
218
|
+
- `p3x-header-last`: Last header for last page.
|
|
218
219
|
- **Footer IDs**:
|
|
219
220
|
- `p3x-footer`: The default footer for all pages.
|
|
220
221
|
- `p3x-footer-<page>`: A footer for a specific page.
|
|
222
|
+
- `p3x-footer-last`: Last footer for last page.
|
|
221
223
|
- **`data-height`**: Specifies the height of the header/footer (in millimeters). Ensure this matches the expected content size to prevent overlap.
|
|
222
224
|
|
|
223
225
|
---
|
|
@@ -245,7 +247,14 @@ The following example demonstrates a **custom header** for the first page and a
|
|
|
245
247
|
<div style="display: table; width: 100%; height: 40mm; text-align: right;">
|
|
246
248
|
<div style="display: table-cell; vertical-align: middle; text-align: right;">
|
|
247
249
|
<h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Invoice</h1>
|
|
248
|
-
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
<div id="p3x-header-last" data-height="40mm" >
|
|
255
|
+
<div style="display: table; width: 100%; height: 40mm; text-align: right;">
|
|
256
|
+
<div style="display: table-cell; vertical-align: middle; text-align: right;">
|
|
257
|
+
<h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Final Notes </h1>
|
|
249
258
|
</div>
|
|
250
259
|
</div>
|
|
251
260
|
</div>
|
|
@@ -315,7 +324,7 @@ When designing headers and footers:
|
|
|
315
324
|
`p3x-html-pdf` supports indexed headers and footers, allowing unique designs for specific pages. For example, `p3x-header-1` can define a header for the first page, while `p3x-header` applies to subsequent pages. Similarly, `p3x-footer-1` can be used for a custom first-page footer.
|
|
316
325
|
|
|
317
326
|
##### Key Points:
|
|
318
|
-
1. **Indexed IDs**: Use `p3x-header-1`, `p3x-footer-1`, etc., for specific pages. Default headers (`p3x-header`) and footers (`p3x-footer`) are used when no specific index is found
|
|
327
|
+
1. **Indexed IDs**: Use `p3x-header-1`, `p3x-footer-1`, etc., for specific pages. Default headers (`p3x-header`) and footers (`p3x-footer`) are used when no specific index is found and there is `p3x-header-last` or `p3x-footer-last`.
|
|
319
328
|
2. **Consistent Heights**: All headers and footers must share the same `data-height` (e.g., `40mm` for headers, `10mm` for footers) to ensure proper alignment and accurate page calculations.
|
|
320
329
|
3. **Dynamic Content**: Use placeholders like `${page}` and `${pages}` to display page-specific data dynamically.
|
|
321
330
|
|
|
@@ -509,7 +518,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht
|
|
|
509
518
|
---
|
|
510
519
|
|
|
511
520
|
|
|
512
|
-
[**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.
|
|
521
|
+
[**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.157
|
|
513
522
|
|
|
514
523
|
[](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)
|
|
515
524
|
|
package/package.json
CHANGED
package/src/header-footer.html
CHANGED
|
@@ -30,14 +30,16 @@
|
|
|
30
30
|
<body>
|
|
31
31
|
|
|
32
32
|
<script>
|
|
33
|
-
var itemName = baseSelector + '-' + vars.page;
|
|
33
|
+
var itemName = baseSelector + '-' + vars.page; // Default: current page-specific header/footer
|
|
34
|
+
if (vars.page == vars.pages) { // Check if it's the last page
|
|
35
|
+
itemName = baseSelector + '-last'; // Use the last page-specific header/footer
|
|
36
|
+
} else if (!items.hasOwnProperty(itemName)) { // Fallback to the default header/footer
|
|
37
|
+
itemName = baseSelector;
|
|
38
|
+
}
|
|
34
39
|
var item = '';
|
|
35
40
|
if (items.hasOwnProperty(itemName)) {
|
|
36
|
-
item = items[itemName]
|
|
37
|
-
} else {
|
|
38
|
-
item = items[baseSelector];
|
|
41
|
+
item = items[itemName];
|
|
39
42
|
}
|
|
40
|
-
;
|
|
41
43
|
// lodash-template-hack //
|
|
42
44
|
var $item = $(item);
|
|
43
45
|
var $body = $('body');
|
package/test/test.js
CHANGED
|
@@ -49,7 +49,13 @@ const fs = require('fs');
|
|
|
49
49
|
<div style="display: table; width: 100%; height: 40mm; text-align: right;">
|
|
50
50
|
<div style="display: table-cell; vertical-align: middle; text-align: right;">
|
|
51
51
|
<h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Invoice </h1>
|
|
52
|
-
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div id="p3x-header-last" data-height="40mm" >
|
|
56
|
+
<div style="display: table; width: 100%; height: 40mm; text-align: right;">
|
|
57
|
+
<div style="display: table-cell; vertical-align: middle; text-align: right;">
|
|
58
|
+
<h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Final Notes </h1>
|
|
53
59
|
</div>
|
|
54
60
|
</div>
|
|
55
61
|
</div>
|
|
@@ -58,6 +64,11 @@ const fs = require('fs');
|
|
|
58
64
|
Page \${page} of \${pages}
|
|
59
65
|
</div>
|
|
60
66
|
</div>
|
|
67
|
+
<div id="p3x-footer-last" data-height="10mm">
|
|
68
|
+
<div style="text-align: right; font-size: 12px; color: #777;">
|
|
69
|
+
Final \${page} of \${pages}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
61
72
|
<div>
|
|
62
73
|
<h2 style="color: #222;">Invoice Content</h2>
|
|
63
74
|
<p style="font-size: 14px; color: #555;">This invoice showcases structured content on a single page for detailed clarity.</p>
|
|
@@ -106,7 +117,6 @@ const fs = require('fs');
|
|
|
106
117
|
</div>
|
|
107
118
|
<div class="ng-template-page-break"></div>
|
|
108
119
|
<div>
|
|
109
|
-
<h2 style="color: #222;">Final Notes</h2>
|
|
110
120
|
<p style="font-size: 14px; color: #555;">Thank you for your business! We hope to work with you again in the future. Stay tuned for updates on our services and offerings by visiting our website or subscribing to our newsletter.</p>
|
|
111
121
|
</div>
|
|
112
122
|
`,
|