p3x-html-pdf 2025.4.127 → 2025.4.129

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 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.127
9
+ # 📃 Generates PDF from HTML with custom headers and footers with wkhtmltopdf v2025.4.129
10
10
 
11
11
 
12
12
 
@@ -203,9 +203,9 @@ Download the binary manually and place it there:
203
203
  ## 🖼️ Example Output
204
204
 
205
205
  Check out an example output PDF:
206
- [Example PDF](https://cdn.corifeus.com/git/html-pdf/assets/test-output.pdf).
206
+ [Example PDF](https://cdn.corifeus.com/git/html-pdf/assets/p3x-html-pdf-output.pdf).
207
207
 
208
- ![Example Output](https://cdn.corifeus.com/git/html-pdf/assets/test-output.png)
208
+ ![Example Output](https://cdn.corifeus.com/git/html-pdf/assets/p3x-html-pdf-output.png)
209
209
 
210
210
  ---
211
211
 
@@ -380,7 +380,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht
380
380
  ---
381
381
 
382
382
 
383
- [**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.127
383
+ [**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.129
384
384
 
385
385
  [![NPM](https://img.shields.io/npm/v/p3x-html-pdf.svg)](https://www.npmjs.com/package/p3x-html-pdf) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software)
386
386
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "p3x-html-pdf",
3
- "version": "2025.4.127",
3
+ "version": "2025.4.129",
4
4
  "corifeus": {
5
5
  "prefix": "p3x-",
6
6
  "publish": true,
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Copyright 2010 wkhtmltopdf authors
3
+ *
4
+ * This file is part of wkhtmltopdf.
5
+ *
6
+ * wkhtmltopdf is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * wkhtmltopdf is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with wkhtmltopdf. If not, see <http: *www.gnu.org/licenses/>.
18
+ */
19
+
20
+ #ifndef __WKHTMLTOPDF_DLLBEGIN__
21
+ #define __WKHTMLTOPDF_DLLBEGIN__
22
+
23
+ #if defined _WIN32 || defined __CYGWIN__
24
+ #ifdef BUILDING_DLL
25
+ #define DLL_PUBLIC __declspec(dllexport)
26
+ #else
27
+ #define DLL_PUBLIC __declspec(dllimport)
28
+ #endif
29
+ #define DLL_LOCAL
30
+ #else
31
+ #if __GNUC__ >= 4
32
+ #define DLL_PUBLIC __attribute__ ((visibility("default")))
33
+ #define DLL_LOCAL __attribute__ ((visibility("hidden")))
34
+ #else
35
+ #define DLL_PUBLIC
36
+ #define DLL_LOCAL
37
+ #endif
38
+ #endif
39
+
40
+ #if defined _WIN32
41
+ #define CALLTYPE __stdcall
42
+ #else
43
+ #define CALLTYPE
44
+ #endif
45
+
46
+ #ifdef __cplusplus
47
+ #define CAPI(type) extern "C" DLL_PUBLIC type CALLTYPE
48
+ #else
49
+ #define CAPI(type) DLL_PUBLIC type CALLTYPE
50
+ #endif
51
+
52
+ #endif /*__WKHTMLTOPDF_DLLBEGIN__*/
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright 2010 wkhtmltopdf authors
3
+ *
4
+ * This file is part of wkhtmltopdf.
5
+ *
6
+ * wkhtmltopdf is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * wkhtmltopdf is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with wkhtmltopdf. If not, see <http: *www.gnu.org/licenses/>.
18
+ */
19
+
20
+ #ifdef __WKHTMLTOPDF_DLLBEGIN__
21
+
22
+ #undef __WKHTMLTOPDF_DLLBEGIN__
23
+ #undef DLL_PUBLIC
24
+ #undef DLL_LOCAL
25
+ #undef CAPI
26
+ #undef CALLTYPE
27
+
28
+ #endif /*__WKHTMLTOPDF_DLLBEGIN__*/
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright 2010 wkhtmltopdf authors
3
+ *
4
+ * This file is part of wkhtmltopdf.
5
+ *
6
+ * wkhtmltopdf is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * wkhtmltopdf is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with wkhtmltopdf. If not, see <http: *www.gnu.org/licenses/>.
18
+ */
19
+
20
+ #ifndef __IMAGE_H__
21
+ #define __IMAGE_H__
22
+ #include <wkhtmltox/dllbegin.inc>
23
+
24
+ struct wkhtmltoimage_global_settings;
25
+ typedef struct wkhtmltoimage_global_settings wkhtmltoimage_global_settings;
26
+
27
+ struct wkhtmltoimage_converter;
28
+ typedef struct wkhtmltoimage_converter wkhtmltoimage_converter;
29
+
30
+ typedef void (*wkhtmltoimage_str_callback)(wkhtmltoimage_converter * converter, const char * str);
31
+ typedef void (*wkhtmltoimage_int_callback)(wkhtmltoimage_converter * converter, const int val);
32
+ typedef void (*wkhtmltoimage_void_callback)(wkhtmltoimage_converter * converter);
33
+
34
+ CAPI(int) wkhtmltoimage_init(int use_graphics);
35
+ CAPI(int) wkhtmltoimage_deinit();
36
+ CAPI(int) wkhtmltoimage_extended_qt();
37
+ CAPI(const char *)wkhtmltoimage_version();
38
+
39
+ CAPI(wkhtmltoimage_global_settings *) wkhtmltoimage_create_global_settings();
40
+
41
+ CAPI(int) wkhtmltoimage_set_global_setting(wkhtmltoimage_global_settings * settings, const char * name, const char * value);
42
+ CAPI(int) wkhtmltoimage_get_global_setting(wkhtmltoimage_global_settings * settings, const char * name, char * value, int vs);
43
+
44
+ CAPI(wkhtmltoimage_converter *) wkhtmltoimage_create_converter(wkhtmltoimage_global_settings * settings, const char * data);
45
+ CAPI(void) wkhtmltoimage_destroy_converter(wkhtmltoimage_converter * converter);
46
+
47
+ CAPI(void) wkhtmltoimage_set_warning_callback(wkhtmltoimage_converter * converter, wkhtmltoimage_str_callback cb);
48
+ CAPI(void) wkhtmltoimage_set_error_callback(wkhtmltoimage_converter * converter, wkhtmltoimage_str_callback cb);
49
+ CAPI(void) wkhtmltoimage_set_phase_changed_callback(wkhtmltoimage_converter * converter, wkhtmltoimage_void_callback cb);
50
+ CAPI(void) wkhtmltoimage_set_progress_changed_callback(wkhtmltoimage_converter * converter, wkhtmltoimage_int_callback cb);
51
+ CAPI(void) wkhtmltoimage_set_finished_callback(wkhtmltoimage_converter * converter, wkhtmltoimage_int_callback cb);
52
+ CAPI(int) wkhtmltoimage_convert(wkhtmltoimage_converter * converter);
53
+ /* CAPI(void) wkhtmltoimage_begin_conversion(wkhtmltoimage_converter * converter); */
54
+ /* CAPI(void) wkhtmltoimage_cancel(wkhtmltoimage_converter * converter); */
55
+
56
+ CAPI(int) wkhtmltoimage_current_phase(wkhtmltoimage_converter * converter);
57
+ CAPI(int) wkhtmltoimage_phase_count(wkhtmltoimage_converter * converter);
58
+ CAPI(const char *) wkhtmltoimage_phase_description(wkhtmltoimage_converter * converter, int phase);
59
+ CAPI(const char *) wkhtmltoimage_progress_string(wkhtmltoimage_converter * converter);
60
+ CAPI(int) wkhtmltoimage_http_error_code(wkhtmltoimage_converter * converter);
61
+ CAPI(long) wkhtmltoimage_get_output(wkhtmltoimage_converter * converter, const unsigned char **);
62
+
63
+ #include <wkhtmltox/dllend.inc>
64
+ #endif /*__IMAGE_H__*/
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Copyright 2010 wkhtmltopdf authors
3
+ *
4
+ * This file is part of wkhtmltopdf.
5
+ *
6
+ * wkhtmltopdf is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * wkhtmltopdf is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with wkhtmltopdf. If not, see <http: *www.gnu.org/licenses/>.
18
+ */
19
+
20
+ #ifndef __PDF_H__
21
+ #define __PDF_H__
22
+ #include <wkhtmltox/dllbegin.inc>
23
+
24
+ struct wkhtmltopdf_global_settings;
25
+ typedef struct wkhtmltopdf_global_settings wkhtmltopdf_global_settings;
26
+
27
+ struct wkhtmltopdf_object_settings;
28
+ typedef struct wkhtmltopdf_object_settings wkhtmltopdf_object_settings;
29
+
30
+ struct wkhtmltopdf_converter;
31
+ typedef struct wkhtmltopdf_converter wkhtmltopdf_converter;
32
+
33
+ typedef void (*wkhtmltopdf_str_callback)(wkhtmltopdf_converter * converter, const char * str);
34
+ typedef void (*wkhtmltopdf_int_callback)(wkhtmltopdf_converter * converter, const int val);
35
+ typedef void (*wkhtmltopdf_void_callback)(wkhtmltopdf_converter * converter);
36
+
37
+ CAPI(int) wkhtmltopdf_init(int use_graphics);
38
+ CAPI(int) wkhtmltopdf_deinit();
39
+ CAPI(int) wkhtmltopdf_extended_qt();
40
+ CAPI(const char *) wkhtmltopdf_version();
41
+
42
+ CAPI(wkhtmltopdf_global_settings *) wkhtmltopdf_create_global_settings();
43
+ CAPI(void) wkhtmltopdf_destroy_global_settings(wkhtmltopdf_global_settings *);
44
+
45
+ CAPI(wkhtmltopdf_object_settings *) wkhtmltopdf_create_object_settings();
46
+ CAPI(void) wkhtmltopdf_destroy_object_settings(wkhtmltopdf_object_settings *);
47
+
48
+ CAPI(int) wkhtmltopdf_set_global_setting(wkhtmltopdf_global_settings * settings, const char * name, const char * value);
49
+ CAPI(int) wkhtmltopdf_get_global_setting(wkhtmltopdf_global_settings * settings, const char * name, char * value, int vs);
50
+ CAPI(int) wkhtmltopdf_set_object_setting(wkhtmltopdf_object_settings * settings, const char * name, const char * value);
51
+ CAPI(int) wkhtmltopdf_get_object_setting(wkhtmltopdf_object_settings * settings, const char * name, char * value, int vs);
52
+
53
+
54
+ CAPI(wkhtmltopdf_converter *) wkhtmltopdf_create_converter(wkhtmltopdf_global_settings * settings);
55
+ CAPI(void) wkhtmltopdf_destroy_converter(wkhtmltopdf_converter * converter);
56
+
57
+ CAPI(void) wkhtmltopdf_set_warning_callback(wkhtmltopdf_converter * converter, wkhtmltopdf_str_callback cb);
58
+ CAPI(void) wkhtmltopdf_set_error_callback(wkhtmltopdf_converter * converter, wkhtmltopdf_str_callback cb);
59
+ CAPI(void) wkhtmltopdf_set_phase_changed_callback(wkhtmltopdf_converter * converter, wkhtmltopdf_void_callback cb);
60
+ CAPI(void) wkhtmltopdf_set_progress_changed_callback(wkhtmltopdf_converter * converter, wkhtmltopdf_int_callback cb);
61
+ CAPI(void) wkhtmltopdf_set_finished_callback(wkhtmltopdf_converter * converter, wkhtmltopdf_int_callback cb);
62
+ /* CAPI(void) wkhtmltopdf_begin_conversion(wkhtmltopdf_converter * converter); */
63
+ /* CAPI(void) wkhtmltopdf_cancel(wkhtmltopdf_converter * converter); */
64
+ CAPI(int) wkhtmltopdf_convert(wkhtmltopdf_converter * converter);
65
+ CAPI(void) wkhtmltopdf_add_object(
66
+ wkhtmltopdf_converter * converter, wkhtmltopdf_object_settings * setting, const char * data);
67
+
68
+ CAPI(int) wkhtmltopdf_current_phase(wkhtmltopdf_converter * converter);
69
+ CAPI(int) wkhtmltopdf_phase_count(wkhtmltopdf_converter * converter);
70
+ CAPI(const char *) wkhtmltopdf_phase_description(wkhtmltopdf_converter * converter, int phase);
71
+ CAPI(const char *) wkhtmltopdf_progress_string(wkhtmltopdf_converter * converter);
72
+ CAPI(int) wkhtmltopdf_http_error_code(wkhtmltopdf_converter * converter);
73
+ CAPI(long) wkhtmltopdf_get_output(wkhtmltopdf_converter * converter, const unsigned char **);
74
+
75
+ #include <wkhtmltox/dllend.inc>
76
+ #endif /*__PDF_H__*/
package/test/test.js ADDED
@@ -0,0 +1,107 @@
1
+ // Import necessary modules
2
+ const { generate } = require('../src/index');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ (async () => {
7
+ try {
8
+ // Delete the output file if it already exists
9
+ const outputPath = path.resolve(__dirname, '..', 'assets', 'p3x-html-pdf-output.pdf');
10
+ if (fs.existsSync(outputPath)) {
11
+ fs.unlinkSync(outputPath);
12
+ }
13
+
14
+ // Define options for PDF generation
15
+ const options = {
16
+ settings: {
17
+ save: true,
18
+ template: {
19
+ format: 'A4',
20
+ marginLeft: 10,
21
+ marginRight: 10,
22
+ fixedWidth: null,
23
+ fixedHeight: null,
24
+ copies: 1,
25
+ orientation: 'portrait',
26
+ },
27
+ html: `
28
+ <div id="p3x-header" data-height="40mm"">
29
+ <div style="width: 100%; padding: 0px; display: table;">
30
+ <div style="display: table-cell; vertical-align: middle;">
31
+ <img src="http://cdn.corifeus.com/assets/png/patrikx3.png" alt="Header Logo" style="height:40mm; margin:0;"/>
32
+ </div>
33
+ <div style="display: table-cell; vertical-align: middle; text-align: right; width: 100%;">
34
+ <h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Invoice</h1>
35
+ <p style="margin: 5px 0 0; font-size: 14px; color: #555;">Generated: ${new Date().toLocaleDateString()}</p>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ <div id="p3x-footer" data-height="10mm" >
40
+ <div style="text-align: right; font-size: 12px; color: #777;">Page \${page} of \${pages}</div>
41
+ </div>
42
+ <div>
43
+ <h2 style="color: #222;">Invoice Content</h2>
44
+ <p style="font-size: 14px; color: #555;">This invoice showcases structured content on a single page for detailed clarity.</p>
45
+ <table style="width:100%; border-collapse: collapse; margin: 10px 0; font-size: 14px;">
46
+ <tr>
47
+ <th style="border: 1px solid #ddd; padding: 8px; background-color: #f4f4f4;">Item</th>
48
+ <th style="border: 1px solid #ddd; padding: 8px; background-color: #f4f4f4;">Quantity</th>
49
+ <th style="border: 1px solid #ddd; padding: 8px; background-color: #f4f4f4;">Price</th>
50
+ <th style="border: 1px solid #ddd; padding: 8px; background-color: #f4f4f4;">Total</th>
51
+ </tr>
52
+ ${Array.from({ length: 27 }).map((_, i) => {
53
+ const price = (i + 1) * 10;
54
+ const quantity = (i % 5) + 1;
55
+ const total = price * quantity;
56
+ return `<tr>
57
+ <td style="border: 1px solid #ddd; padding: 8px;">Product ${String.fromCharCode(65 + (i % 26))}</td>
58
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right;">${quantity}</td>
59
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right;">$${price}.00</td>
60
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right;">$${total}.00</td>
61
+ </tr>`;
62
+ }).join('')}
63
+ <tr>
64
+ <td colspan="3" style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">Subtotal</td>
65
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">$${Array.from({ length: 15 }).reduce((acc, _, i) => acc + ((i + 1) * 10 * ((i % 5) + 1)), 0)}.00</td>
66
+ </tr>
67
+ <tr>
68
+ <td colspan="3" style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">VAT (20%)</td>
69
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">$${(Array.from({ length: 15 }).reduce((acc, _, i) => acc + ((i + 1) * 10 * ((i % 5) + 1)), 0) * 0.2).toFixed(2)}</td>
70
+ </tr>
71
+ <tr>
72
+ <td colspan="3" style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">Total</td>
73
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">$${(Array.from({ length: 15 }).reduce((acc, _, i) => acc + ((i + 1) * 10 * ((i % 5) + 1)), 0) * 1.2).toFixed(2)}</td>
74
+ </tr>
75
+ </table>
76
+ </div>
77
+ <div class="ng-template-page-break"></div>
78
+ <div>
79
+ <h2 style="color: #222;">Additional Information</h2>
80
+ <p style="font-size: 14px; color: #555;">This page provides further details about the invoice, payment methods, and terms. Below is a breakdown of important notes:</p>
81
+ <ul style="font-size: 14px; color: #555;">
82
+ <li>Payments are due within 30 days of receipt.</li>
83
+ <li>Accepted payment methods include credit card, bank transfer, and PayPal.</li>
84
+ <li>Please ensure that all transactions reference the invoice number provided above.</li>
85
+ </ul>
86
+ <p style="font-size: 14px; color: #555;">If you have any questions, feel free to contact our support team at <a href="mailto:support@p3x.com">support@p3x.com</a>.</p>
87
+ </div>
88
+ <div class="ng-template-page-break"></div>
89
+ <div>
90
+ <h2 style="color: #222;">Final Notes</h2>
91
+ <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>
92
+ </div>
93
+ `,
94
+ },
95
+ title: 'P3X-HTML-PDF Detailed Invoice',
96
+ debug: false,
97
+ saveFile: outputPath,
98
+ };
99
+
100
+ // Generate the PDF
101
+ await generate(options);
102
+
103
+ console.log('PDF generation successful! Check test-output.pdf.');
104
+ } catch (error) {
105
+ console.error('PDF generation failed:', error);
106
+ }
107
+ })();