n8n-nodes-pdfbro 0.1.21 → 0.1.22

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.
@@ -312,11 +312,11 @@ class PdfBro {
312
312
  const htmlToPdfmake = require('html-to-pdfmake');
313
313
  const PdfPrinter = require('pdfmake');
314
314
  const juice = require('juice');
315
- // Strip all font-family declarations from HTML/CSS before processing
316
- // This prevents pdfmake from crashing on undefined fonts like Arial, Helvetica
315
+ // Strip font-family declarations from CSS (more careful regex)
316
+ // Matches: font-family: value; or font-family: value (end of style)
317
317
  const htmlWithoutFonts = htmlContent
318
- .replace(/font-family\s*:\s*[^;}"']+[;]?/gi, '')
319
- .replace(/font-family\s*:\s*[^;}"']+/gi, '');
318
+ .replace(/font-family\s*:[^;}"']*;/gi, '') // font-family: ...; (with semicolon)
319
+ .replace(/;\s*font-family\s*:[^;}"']*/gi, ''); // ; font-family: ... (at end)
320
320
  // Use juice to inline all CSS (from <style> tags and classes) into style attributes
321
321
  const inlinedHtml = juice(htmlWithoutFonts, {
322
322
  removeStyleTags: true,
@@ -336,31 +336,36 @@ class PdfBro {
336
336
  // Convert inlined HTML to pdfmake format (requires window)
337
337
  const { window } = new JSDOM('');
338
338
  const docDefContent = htmlToPdfmake(inlinedHtml, { window });
339
- // Recursively remove/override all font properties to prevent undefined font errors
340
- const sanitizeFonts = (obj) => {
339
+ // Recursively sanitize pdfmake content: remove fonts and fix NaN values
340
+ const sanitizeContent = (obj) => {
341
341
  if (Array.isArray(obj)) {
342
- return obj.map(sanitizeFonts);
342
+ return obj.map(sanitizeContent);
343
343
  }
344
344
  if (obj && typeof obj === 'object') {
345
345
  const result = {};
346
346
  for (const key of Object.keys(obj)) {
347
347
  if (key === 'font') {
348
- // Skip font property entirely - defaultStyle will handle it
348
+ // Skip font property - defaultStyle handles it
349
349
  continue;
350
350
  }
351
- else if (key === 'style' && typeof obj[key] === 'string') {
351
+ const val = obj[key];
352
+ // Fix NaN numeric values (width, height, margin, etc.)
353
+ if (typeof val === 'number' && isNaN(val)) {
354
+ continue; // Skip NaN values
355
+ }
356
+ if (key === 'style' && typeof val === 'string') {
352
357
  // Remove font-family from inline style strings
353
- result[key] = obj[key].replace(/font-family\s*:\s*[^;]+;?/gi, '');
358
+ result[key] = val.replace(/font-family\s*:[^;]*;?/gi, '');
354
359
  }
355
360
  else {
356
- result[key] = sanitizeFonts(obj[key]);
361
+ result[key] = sanitizeContent(val);
357
362
  }
358
363
  }
359
364
  return result;
360
365
  }
361
366
  return obj;
362
367
  };
363
- const sanitizedContent = sanitizeFonts(docDefContent);
368
+ const sanitizedContent = sanitizeContent(docDefContent);
364
369
  const docDefinition = {
365
370
  content: sanitizedContent,
366
371
  defaultStyle: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pdfbro",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Offline PDF utility node for n8n",
5
5
  "keywords": [
6
6
  "n8n-community-node"