p3x-html-pdf 2025.4.124 → 2025.4.126

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.124
9
+ # 📃 Generates PDF from HTML with custom headers and footers with wkhtmltopdf v2025.4.126
10
10
 
11
11
 
12
12
 
@@ -69,7 +69,7 @@ const { generate } = require('p3x-html-pdf');
69
69
  ## 🛠️ Features
70
70
 
71
71
  - 📜 **Custom Headers and Footers**: Create professional headers and footers with dynamic placeholders.
72
- - 📏 **Flexible Page Settings**: Set paper size, orientation, margins, and more.
72
+ - 🔀 **Flexible Page Settings**: Set paper size, orientation, margins, and more.
73
73
  - ⚡ **Async/Await Support**: Fully compatible with modern JavaScript workflows.
74
74
  - 📊 **Dynamic Tables and Content**: Generate tables and other dynamic HTML content easily.
75
75
 
@@ -96,7 +96,7 @@ const path = require('path');
96
96
  <h1>Header Content</h1>
97
97
  </div>
98
98
  <div id="p3x-footer" data-height="15mm">
99
- <p>Page ${page} of ${pages}</p>
99
+ <p>Page \${page} of \${pages}</p>
100
100
  </div>
101
101
  <div>
102
102
  <h2>Content</h2>
@@ -152,26 +152,29 @@ const path = require('path');
152
152
  - `html`: HTML content with placeholders.
153
153
  - **title**: PDF document title.
154
154
  - **saveFile**: Path for saving the PDF.
155
+ - **base** The HTML base href is other then current directory, it can be online as well.
156
+ - **css**: Customize the CSS for serving, by default it is in `src/ng-html-template.css`
157
+ - **jquery**: The latest that works with webkit is jQuery v1.12.4
158
+ - **javascriptDelay**: The delay before the PDF is generated as default is 1000 ms.
155
159
 
156
- For more options, check the official [wkhtmltopdf usage guide](https://wkhtmltopdf.org/usage/wkhtmltopdf.txt).
160
+ For more options, check the official [wkhtmltopdf usage guide](https://wkhtmltopdf.org/usage/wkhtmltopdf.txt).
161
+
162
+ Unfortunately the version latest HTTS is not working, so it is better to use inline images or using HTTP as that is dated but with HTTP in local filesystem is perfect.
157
163
 
158
164
  ---
159
165
 
160
166
  ## 🌟 Placeholders
161
167
 
162
- You can use placeholders in your HTML for dynamic data:
168
+ You can use placeholders in your HTML for dynamic data (only these, but it is enough, the rest you can generate in HTML):
163
169
 
164
170
  - `${page}`: Current page.
165
171
  - `${pages}`: Total pages.
166
- - `${date}`: Current date.
167
- - `${isodate}`: ISO date format.
168
- - `${time}`: Current time.
169
172
 
170
173
  Example:
171
174
 
172
175
  ```html
173
176
  <div id="p3x-footer" data-height="15mm">
174
- <p>Page ${page} of ${pages} - Generated on ${date}</p>
177
+ <p>Page ${page} of ${pages}</p>
175
178
  </div>
176
179
  ```
177
180
 
@@ -200,7 +203,71 @@ Download the binary manually and place it there:
200
203
  ## 🖼️ Example Output
201
204
 
202
205
  Check out an example output PDF:
203
- [Example PDF](https://cdn.corifeus.com/git/html-pdf/test-output.pdf).
206
+ [Example PDF](https://cdn.corifeus.com/git/html-pdf/assets/test-output.pdf).
207
+
208
+ ![Example Output](https://cdn.corifeus.com/git/html-pdf/assets/test-output.png)
209
+ ---
210
+
211
+ ## 🔬 Legacy Rendering with Webkit
212
+
213
+ This library uses `wkhtmltopdf`, which relies on an older version of Webkit. As such, it does not support modern CSS features like `flexbox`. Instead, older solutions such as `float` and `table`-based layouts must be used for alignment. While these approaches are not modern, they are efficient and compatible with the rendering engine.
214
+
215
+ For instance, the following layout works seamlessly:
216
+
217
+ ```html
218
+ <div id="p3x-header" data-height="40mm">
219
+ <div style="width: 100%; padding: 0px; display: table;">
220
+ <div style="display: table-cell; vertical-align: middle;">
221
+ <img src="http://cdn.corifeus.com/assets/png/patrikx3.png" alt="Header Logo" style="height:40mm; margin:0;"/>
222
+ </div>
223
+ <div style="display: table-cell; vertical-align: middle; text-align: right; width: 100%;">
224
+ <h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Invoice</h1>
225
+ <p style="margin: 5px 0 0; font-size: 14px; color: #555;">Generated: 2023-10-01</p>
226
+ </div>
227
+ </div>
228
+ </div>
229
+ ```
230
+
231
+ ---
232
+
233
+ ## Node.js Test Example
234
+
235
+ The `node ./test/test.js` script demonstrates how to generate the example PDF:
236
+
237
+ ```javascript
238
+ const { generate } = require('../src/index');
239
+ const path = require('path');
240
+ const fs = require('fs');
241
+
242
+ (async () => {
243
+ try {
244
+ const outputPath = path.resolve(__dirname, '..', 'test-output.pdf');
245
+ if (fs.existsSync(outputPath)) {
246
+ fs.unlinkSync(outputPath);
247
+ }
248
+
249
+ const options = {
250
+ settings: {
251
+ save: true,
252
+ template: {
253
+ format: 'A4',
254
+ orientation: 'portrait',
255
+ marginLeft: 10,
256
+ marginRight: 10,
257
+ },
258
+ html: '<h1>Hello PDF</h1>',
259
+ },
260
+ title: 'Test PDF',
261
+ saveFile: outputPath,
262
+ };
263
+
264
+ await generate(options);
265
+ console.log('PDF generated!');
266
+ } catch (error) {
267
+ console.error('Error:', error);
268
+ }
269
+ })();
270
+ ```
204
271
 
205
272
  ---
206
273
 
@@ -312,7 +379,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht
312
379
  ---
313
380
 
314
381
 
315
- [**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.124
382
+ [**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.126
316
383
 
317
384
  [![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)
318
385
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "p3x-html-pdf",
3
- "version": "2025.4.124",
3
+ "version": "2025.4.126",
4
4
  "corifeus": {
5
5
  "prefix": "p3x-",
6
6
  "publish": true,
package/test-output.pdf DELETED
Binary file