n8n-nodes-pdfbro 0.1.5 → 0.1.6

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.
@@ -147,18 +147,23 @@ class PdfBro {
147
147
  for (let i = 0; i < items.length; i++) {
148
148
  try {
149
149
  const binaryProps = this.getNodeParameter('binaryProperties', i);
150
+ let propsToMerge = [];
150
151
  if (binaryProps && binaryProps.properties) {
151
- for (const propItem of binaryProps.properties) {
152
- const propName = propItem.property;
153
- // Check if binary data exists
154
- if (!items[i].binary || !items[i].binary[propName]) {
155
- continue;
156
- }
157
- const validBuffer = await this.helpers.getBinaryDataBuffer(i, propName);
158
- const pdf = await pdf_lib_1.PDFDocument.load(validBuffer);
159
- const copiedPages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());
160
- copiedPages.forEach((page) => mergedPdf.addPage(page));
152
+ propsToMerge = binaryProps.properties.map((p) => p.property);
153
+ }
154
+ // Fallback: If no properties specified, try 'data' default
155
+ if (propsToMerge.length === 0) {
156
+ propsToMerge.push('data');
157
+ }
158
+ for (const propName of propsToMerge) {
159
+ // Check if binary data exists
160
+ if (!items[i].binary || !items[i].binary[propName]) {
161
+ continue;
161
162
  }
163
+ const validBuffer = await this.helpers.getBinaryDataBuffer(i, propName);
164
+ const pdf = await pdf_lib_1.PDFDocument.load(validBuffer);
165
+ const copiedPages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());
166
+ copiedPages.forEach((page) => mergedPdf.addPage(page));
162
167
  }
163
168
  }
164
169
  catch (error) {
@@ -168,6 +173,9 @@ class PdfBro {
168
173
  throw error;
169
174
  }
170
175
  }
176
+ if (mergedPdf.getPageCount() === 0) {
177
+ throw new Error('No PDF pages found to merge! Please check your input binary fields.');
178
+ }
171
179
  // Return single item
172
180
  const mergedPdfBuffer = await mergedPdf.save();
173
181
  // Use the first item's JSON as a base, or empty if no items
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pdfbro",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Offline PDF utility node for n8n",
5
5
  "keywords": [
6
6
  "n8n-community-node"