p3x-html-pdf 2025.4.161 → 2025.4.163

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.
Files changed (2) hide show
  1. package/README.md +86 -22
  2. package/package.json +1 -1
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.161
9
+ # 📃 Generates PDF from HTML with custom headers and footers with wkhtmltopdf v2025.4.163
10
10
 
11
11
 
12
12
 
@@ -73,47 +73,111 @@ const { generate } = require('p3x-html-pdf');
73
73
  const path = require('path');
74
74
 
75
75
  (async () => {
76
+ const outputPath = path.join(process.cwd(), 'p3x-html-pdf-output.pdf');
77
+
76
78
  const options = {
77
79
  settings: {
78
80
  save: true,
79
81
  template: {
80
82
  format: 'A4',
81
- orientation: 'portrait',
82
83
  marginLeft: 10,
83
84
  marginRight: 10,
85
+ fixedWidth: null,
86
+ fixedHeight: null,
87
+ copies: 1,
88
+ orientation: 'portrait',
84
89
  },
85
90
  html: `
86
- <div id="p3x-header" data-height="20mm">
87
- <h1>Header Content</h1>
91
+ <div id="p3x-header-1" data-height="40mm">
92
+ <div style="width: 100%; padding: 0px; display: table;">
93
+ <div style="display: table-cell; vertical-align: middle;">
94
+ <img src="http://cdn.corifeus.com/assets/png/patrikx3.png" alt="Header Logo" style="height:40mm; margin:0;"/>
95
+ </div>
96
+ <div style="display: table-cell; vertical-align: middle; text-align: right; width: 100%;">
97
+ <h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Invoice - First Page</h1>
98
+ <p style="margin: 5px 0 0; font-size: 14px; color: #555;">Generated: ${new Date().toLocaleDateString()}</p>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ <div id="p3x-header" data-height="40mm" >
103
+ <div style="display: table; width: 100%; height: 40mm; text-align: right;">
104
+ <div style="display: table-cell; vertical-align: middle; text-align: right;">
105
+ <h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Invoice </h1>
106
+ </div>
107
+ </div>
88
108
  </div>
89
- <div id="p3x-footer" data-height="15mm">
90
- <p>Page \${page} of \${pages}</p>
109
+ <div id="p3x-header-last" data-height="40mm" >
110
+ <div style="display: table; width: 100%; height: 40mm; text-align: right;">
111
+ <div style="display: table-cell; vertical-align: middle; text-align: right;">
112
+ <h1 style="margin: 0; font-size: 20px; color: #333;">P3X HTML Final Notes </h1>
113
+ </div>
114
+ </div>
115
+ </div>
116
+ <div id="p3x-footer" data-height="10mm">
117
+ <div style="text-align: right; font-size: 12px; color: #777;">
118
+ Page \${page} of \${pages}
119
+ </div>
120
+ </div>
121
+ <div id="p3x-footer-last" data-height="10mm">
122
+ <div style="text-align: right; font-size: 12px; color: #777;">
123
+ Final \${page} of \${pages}
124
+ </div>
91
125
  </div>
92
126
  <div>
93
- <h2>Content</h2>
94
- <p>This is a test PDF document.</p>
95
- <table width="100%" align="left" border="1">
127
+ <h2 style="color: #222;">Invoice Content</h2>
128
+ <p style="font-size: 14px; color: #555;">This invoice showcases structured content on a single page for detailed clarity.</p>
129
+ <table style="width:100%; border-collapse: collapse; margin: 10px 0; font-size: 14px;">
96
130
  <tr>
97
- <th align="left">Header 1</th>
98
- <th align="left">Header 2</th>
99
- <th align="left">Header 3</th>
131
+ <th style="border: 1px solid #ddd; padding: 8px; background-color: #f4f4f4;">Item</th>
132
+ <th style="border: 1px solid #ddd; padding: 8px; background-color: #f4f4f4;">Quantity</th>
133
+ <th style="border: 1px solid #ddd; padding: 8px; background-color: #f4f4f4;">Price</th>
134
+ <th style="border: 1px solid #ddd; padding: 8px; background-color: #f4f4f4;">Total</th>
100
135
  </tr>
136
+ ${Array.from({ length: 26 }).map((_, i) => {
137
+ const price = (i + 1) * 10;
138
+ const quantity = (i % 5) + 1;
139
+ const total = price * quantity;
140
+ return `<tr>
141
+ <td style="border: 1px solid #ddd; padding: 8px;">Product ${String.fromCharCode(65 + (i % 26))}</td>
142
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right;">${quantity}</td>
143
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right;">$${price}.00</td>
144
+ <td style="border: 1px solid #ddd; padding: 8px; text-align: right;">$${total}.00</td>
145
+ </tr>`;
146
+ }).join('')}
101
147
  <tr>
102
- <td>Data 1</td>
103
- <td>Data 2</td>
104
- <td>Data 3</td>
148
+ <td colspan="3" style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">Subtotal</td>
149
+ <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>
105
150
  </tr>
106
151
  <tr>
107
- <td>Data 4</td>
108
- <td>Data 5</td>
109
- <td>Data 6</td>
152
+ <td colspan="3" style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">VAT (20%)</td>
153
+ <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>
154
+ </tr>
155
+ <tr>
156
+ <td colspan="3" style="border: 1px solid #ddd; padding: 8px; text-align: right; font-weight: bold;">Total</td>
157
+ <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>
110
158
  </tr>
111
159
  </table>
112
160
  </div>
113
- `,
161
+ <div class="ng-template-page-break"></div>
162
+ <div>
163
+ <h2 style="color: #222;">Additional Information</h2>
164
+ <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>
165
+ <ul style="font-size: 14px; color: #555;">
166
+ <li>Payments are due within 30 days of receipt.</li>
167
+ <li>Accepted payment methods include credit card, bank transfer, and PayPal.</li>
168
+ <li>Please ensure that all transactions reference the invoice number provided above.</li>
169
+ </ul>
170
+ <p style="font-size: 14px; color: #555;">If you have any questions, feel free to contact our support team at <a href="mailto:support@patrikx3.com">support@patrikx3.com</a>.</p>
171
+ </div>
172
+ <div class="ng-template-page-break"></div>
173
+ <div>
174
+ <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>
175
+ </div>
176
+ `,
114
177
  },
115
- title: 'Sample PDF',
116
- saveFile: path.resolve(__dirname, 'output.pdf'),
178
+ title: 'P3X-HTML-PDF Detailed Invoice',
179
+ debug: true,
180
+ saveFile: outputPath,
117
181
  };
118
182
 
119
183
  try {
@@ -518,7 +582,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht
518
582
  ---
519
583
 
520
584
 
521
- [**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.161
585
+ [**P3X-HTML-PDF**](https://corifeus.com/html-pdf) Build v2025.4.163
522
586
 
523
587
  [![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)
524
588
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "p3x-html-pdf",
3
- "version": "2025.4.161",
3
+ "version": "2025.4.163",
4
4
  "corifeus": {
5
5
  "prefix": "p3x-",
6
6
  "publish": true,