n8n-nodes-pdfops 0.4.0 → 0.5.0

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.
@@ -4,7 +4,10 @@ exports.Pdfops = void 0;
4
4
  const n8n_workflow_1 = require("n8n-workflow");
5
5
  const decodeApiError_1 = require("./decodeApiError");
6
6
  const BASE_URL = 'https://pdfops.dev';
7
- const NODE_PACKAGE_VERSION = '0.4.0';
7
+ const NODE_PACKAGE_VERSION = '0.5.0';
8
+ function headerTrue(value) {
9
+ return typeof value === 'string' && value.split(',')[0].trim().toLowerCase() === 'true';
10
+ }
8
11
  function withApiMessage(wrapped, apiError, itemIndex) {
9
12
  var _a;
10
13
  if (itemIndex !== undefined)
@@ -26,7 +29,13 @@ const DOC_OPS = {
26
29
  protect: { path: 'protect', output: 'pdf', defaultFile: 'protected.pdf' },
27
30
  metadata: { path: 'metadata', output: 'json', defaultFile: '' },
28
31
  setMetadata: { path: 'set-metadata', output: 'pdf', defaultFile: 'metadata-updated.pdf' },
32
+ addFields: { path: 'add-fields', output: 'pdf', defaultFile: 'fields-added.pdf' },
33
+ attach: { path: 'attach', output: 'pdf', defaultFile: 'attached.pdf' },
34
+ edit: { path: 'edit', output: 'pdf', defaultFile: 'edited.pdf' },
35
+ extractText: { path: 'extract-text', output: 'extract', defaultFile: 'tables.xlsx' },
36
+ findText: { path: 'find-text', output: 'json', defaultFile: '' },
29
37
  };
38
+ const XLSX_MIME_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
30
39
  const OPERATION_PROPERTIES = [
31
40
  {
32
41
  displayName: 'Operation',
@@ -76,12 +85,15 @@ const OPERATION_PROPERTIES = [
76
85
  displayOptions: { show: { '@version': [2] } },
77
86
  options: [
78
87
  { name: 'Account', value: 'account' },
88
+ { name: 'Attachment', value: 'attachment' },
89
+ { name: 'Convert', value: 'convert' },
79
90
  { name: 'Document', value: 'document' },
80
91
  { name: 'Form', value: 'form' },
81
92
  { name: 'Invoice', value: 'invoice' },
82
93
  { name: 'Metadata', value: 'metadata' },
83
94
  { name: 'Security', value: 'security' },
84
95
  { name: 'Stamp', value: 'stamp' },
96
+ { name: 'Text', value: 'text' },
85
97
  ],
86
98
  default: 'form',
87
99
  },
@@ -101,6 +113,50 @@ const OPERATION_PROPERTIES = [
101
113
  ],
102
114
  default: 'usage',
103
115
  },
116
+ {
117
+ displayName: 'Operation',
118
+ name: 'operation',
119
+ type: 'options',
120
+ noDataExpression: true,
121
+ displayOptions: { show: { '@version': [2], resource: ['attachment'] } },
122
+ options: [
123
+ {
124
+ name: 'Attach',
125
+ value: 'attach',
126
+ action: 'Attach files to a PDF',
127
+ description: 'Embed files (an XML invoice, a spreadsheet, a source file) inside a PDF and output the updated PDF',
128
+ },
129
+ ],
130
+ default: 'attach',
131
+ },
132
+ {
133
+ displayName: 'Operation',
134
+ name: 'operation',
135
+ type: 'options',
136
+ noDataExpression: true,
137
+ displayOptions: { show: { '@version': [2], resource: ['convert'] } },
138
+ options: [
139
+ {
140
+ name: 'HTML to PDF',
141
+ value: 'htmlToPdf',
142
+ action: 'Convert HTML to a PDF',
143
+ description: 'Render an HTML string to a PDF with a headless browser, so CSS, images and web fonts come out as in a browser print. Each call counts as 5 requests against your quota.',
144
+ },
145
+ {
146
+ name: 'Images to PDF',
147
+ value: 'imageToPdf',
148
+ action: 'Convert images to a PDF',
149
+ description: 'Turn the JPG or PNG images from all incoming items (in item order) into one PDF, one image per page',
150
+ },
151
+ {
152
+ name: 'Text to PDF',
153
+ value: 'textToPdf',
154
+ action: 'Convert text to a PDF',
155
+ description: 'Turn Markdown, plain text or CSV into a PDF on A4 or Letter pages, without a template',
156
+ },
157
+ ],
158
+ default: 'htmlToPdf',
159
+ },
104
160
  {
105
161
  displayName: 'Operation',
106
162
  name: 'operation',
@@ -148,6 +204,12 @@ const OPERATION_PROPERTIES = [
148
204
  noDataExpression: true,
149
205
  displayOptions: { show: { '@version': [2], resource: ['form'] } },
150
206
  options: [
207
+ {
208
+ name: 'Add Fields',
209
+ value: 'addFields',
210
+ action: 'Add form fields to a PDF',
211
+ description: 'Create fillable form fields (text, checkbox, radio group, dropdown, signature box) at exact positions in a PDF',
212
+ },
151
213
  {
152
214
  name: 'Fill',
153
215
  value: 'fill',
@@ -242,9 +304,37 @@ const OPERATION_PROPERTIES = [
242
304
  action: 'Add a text watermark to a PDF',
243
305
  description: 'Stamp diagonal or horizontal text (DRAFT, CONFIDENTIAL, a name) over the pages of a PDF and output the watermarked PDF',
244
306
  },
307
+ {
308
+ name: 'Edit',
309
+ value: 'edit',
310
+ action: 'Add text images or barcodes to a PDF',
311
+ description: 'Draw text, images (a logo, a signature), QR codes and barcodes at exact positions on the pages of a PDF and output the edited PDF',
312
+ },
245
313
  ],
246
314
  default: 'watermark',
247
315
  },
316
+ {
317
+ displayName: 'Operation',
318
+ name: 'operation',
319
+ type: 'options',
320
+ noDataExpression: true,
321
+ displayOptions: { show: { '@version': [2], resource: ['text'] } },
322
+ options: [
323
+ {
324
+ name: 'Extract',
325
+ value: 'extractText',
326
+ action: 'Extract text and tables from a PDF',
327
+ description: 'Read the text of a PDF with a text layer, page by page, plus the tables found on the pages, as JSON, plain text or an Excel workbook. Scanned pages are not read (no OCR).',
328
+ },
329
+ {
330
+ name: 'Find',
331
+ value: 'findText',
332
+ action: 'Find text in a PDF',
333
+ description: 'Search a PDF with a text layer for a word, phrase or pattern and return every hit with its page and its box in PDF points',
334
+ },
335
+ ],
336
+ default: 'extractText',
337
+ },
248
338
  ];
249
339
  class Pdfops {
250
340
  constructor() {
@@ -256,7 +346,7 @@ class Pdfops {
256
346
  version: [1, 2],
257
347
  defaultVersion: 2,
258
348
  subtitle: '={{ ($parameter["resource"] ? $parameter["resource"] + ": " : "") + $parameter["operation"] }}',
259
- description: 'Fill, merge, split, rotate, watermark, number, protect, unlock and read PDFs and generate invoices. Works without an API key (100 calls/month).',
349
+ description: 'Fill, merge, split, rotate, watermark, number, protect, unlock, edit, read and search PDFs, add form fields and attachments, convert HTML, text and images to PDF, and generate invoices. Works without an API key (100 calls/month).',
260
350
  defaults: {
261
351
  name: 'PDFops',
262
352
  },
@@ -280,10 +370,19 @@ class Pdfops {
280
370
  hint: 'The name of the input item’s binary field containing the PDF',
281
371
  displayOptions: {
282
372
  show: {
283
- operation: ['fill', 'inspect', 'merge', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'metadata', 'setMetadata'],
373
+ operation: ['fill', 'inspect', 'merge', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'metadata', 'setMetadata', 'addFields', 'attach', 'edit', 'extractText', 'findText'],
284
374
  },
285
375
  },
286
376
  },
377
+ {
378
+ displayName: 'Input Binary Field',
379
+ name: 'binaryPropertyName',
380
+ type: 'string',
381
+ default: 'data',
382
+ required: true,
383
+ hint: 'The name of the input item’s binary field containing the image (JPG or PNG)',
384
+ displayOptions: { show: { operation: ['imageToPdf'] } },
385
+ },
287
386
  {
288
387
  displayName: 'Fields',
289
388
  name: 'fields',
@@ -320,6 +419,11 @@ class Pdfops {
320
419
  'protect',
321
420
  'metadata',
322
421
  'setMetadata',
422
+ 'addFields',
423
+ 'attach',
424
+ 'edit',
425
+ 'extractText',
426
+ 'findText',
323
427
  ],
324
428
  },
325
429
  },
@@ -351,7 +455,7 @@ class Pdfops {
351
455
  default: '',
352
456
  placeholder: 'e.g. 1-3,5 (empty = all pages)',
353
457
  description: '1-based page spec such as "1-3,5". Leave empty to apply to every page.',
354
- displayOptions: { show: { operation: ['rotate', 'watermark', 'pageNumbers'] } },
458
+ displayOptions: { show: { operation: ['rotate', 'watermark', 'pageNumbers', 'extractText', 'findText'] } },
355
459
  },
356
460
  {
357
461
  displayName: 'Degrees',
@@ -527,7 +631,7 @@ class Pdfops {
527
631
  type: 'string',
528
632
  typeOptions: { password: true },
529
633
  default: '',
530
- description: 'Password required to open the output PDF (at most 128 characters). Set this and/or the Owner Password; at least one is required.',
634
+ description: 'Password required to open the output PDF (1-32 characters, Latin-1 only). Set this and/or the Owner Password; at least one is required.',
531
635
  displayOptions: { show: { operation: ['protect'] } },
532
636
  },
533
637
  {
@@ -536,7 +640,7 @@ class Pdfops {
536
640
  type: 'string',
537
641
  typeOptions: { password: true },
538
642
  default: '',
539
- description: 'Password that lifts the permission restrictions (at most 128 characters). Restrictions only bind a viewer when an owner password is set.',
643
+ description: 'Password that lifts the permission restrictions (1-32 characters, Latin-1 only). Restrictions only bind a viewer when an owner password is set.',
540
644
  displayOptions: { show: { operation: ['protect'] } },
541
645
  },
542
646
  {
@@ -585,19 +689,471 @@ class Pdfops {
585
689
  { displayName: 'Title', name: 'title', type: 'string', default: '' },
586
690
  ],
587
691
  },
692
+ {
693
+ displayName: 'Fields to Add',
694
+ name: 'formFields',
695
+ type: 'json',
696
+ default: '[\n { "type": "text", "name": "customer_name", "page": 1, "x": 72, "y": 700, "width": 200, "height": 20 }\n]',
697
+ required: true,
698
+ description: 'JSON array (up to 200 entries) of fields to create. Every entry needs type (text, checkbox, radio, dropdown or signature), name (1-200 characters, no dot, unique, also against fields already in the PDF) and page (1-based). Every type except radio also needs x, y, width and height in PDF points from the bottom-left of the page as displayed; the box must lie inside the page. Optional on all types: required, read_only, border, background. text takes multiline, max_length, default, font_size (1-200 or "auto"); checkbox takes checked; radio takes options[] of { value, x, y, width, height } and default; dropdown takes options[] of strings, default, font_size.',
699
+ displayOptions: { show: { operation: ['addFields'] } },
700
+ },
701
+ {
702
+ displayName: 'Files to Attach',
703
+ name: 'attachments',
704
+ type: 'fixedCollection',
705
+ typeOptions: { multipleValues: true },
706
+ placeholder: 'Add File',
707
+ default: {},
708
+ required: true,
709
+ description: 'Files to embed, in order (1 to 10, up to 3 MB combined). Each one is read from a binary field of the input item.',
710
+ displayOptions: { show: { operation: ['attach'] } },
711
+ options: [
712
+ {
713
+ displayName: 'File',
714
+ name: 'file',
715
+ values: [
716
+ {
717
+ displayName: 'Binary Field',
718
+ name: 'binaryPropertyName',
719
+ type: 'string',
720
+ default: 'attachment',
721
+ required: true,
722
+ description: 'The name of the input item’s binary field holding the file to embed',
723
+ },
724
+ {
725
+ displayName: 'Description',
726
+ name: 'description',
727
+ type: 'string',
728
+ default: '',
729
+ description: 'Free text description stored with the file (optional)',
730
+ },
731
+ {
732
+ displayName: 'MIME Type',
733
+ name: 'mimeType',
734
+ type: 'string',
735
+ default: '',
736
+ placeholder: 'e.g. text/xml',
737
+ description: 'Defaults to the MIME type of the binary data',
738
+ },
739
+ {
740
+ displayName: 'Name',
741
+ name: 'name',
742
+ type: 'string',
743
+ default: '',
744
+ placeholder: 'e.g. factur-x.xml',
745
+ description: 'File name inside the PDF (1-255 characters, no / or \\). Defaults to the binary data’s file name. Must be unique within the PDF.',
746
+ },
747
+ {
748
+ displayName: 'Relationship',
749
+ name: 'relationship',
750
+ type: 'options',
751
+ options: [
752
+ { name: 'Alternative', value: 'Alternative' },
753
+ { name: 'Data', value: 'Data' },
754
+ { name: 'Source', value: 'Source' },
755
+ { name: 'Supplement', value: 'Supplement' },
756
+ { name: 'Unspecified', value: 'Unspecified' },
757
+ ],
758
+ default: 'Unspecified',
759
+ description: 'PDF/A-3 relationship of the file to the document',
760
+ },
761
+ ],
762
+ },
763
+ ],
764
+ },
765
+ {
766
+ displayName: 'Items',
767
+ name: 'editItems',
768
+ type: 'json',
769
+ default: '[\n { "type": "text", "page": 1, "x": 72, "y": 720, "text": "Approved", "size": 14 }\n]',
770
+ required: true,
771
+ description: 'JSON array (up to 100 entries) of things to draw, in order (later ones draw on top). x and y are PDF points from the bottom-left of the page as displayed. type "text": page, x, y, text (WinAnsi characters only), optional size, color, font, opacity, rotation, maxWidth, lineHeight. type "image": page, x, y, image (the Field Name of one of the Image Files below), optional width, height, opacity. type "barcode": page, x, y, format (qrcode, datamatrix, pdf417, azteccode, code128, code39, ean13, ean8, upca, itf14, interleaved2of5, gs1-128), value, optional width, height, color, background, includeText, errorCorrection, opacity.',
772
+ displayOptions: { show: { operation: ['edit'] } },
773
+ },
774
+ {
775
+ displayName: 'Image Files',
776
+ name: 'imageFiles',
777
+ type: 'fixedCollection',
778
+ typeOptions: { multipleValues: true },
779
+ placeholder: 'Add Image',
780
+ default: {},
781
+ description: 'PNG or JPEG images that "image" items refer to (up to 10, 2 MB each). Only needed when Items contains image entries.',
782
+ displayOptions: { show: { operation: ['edit'] } },
783
+ options: [
784
+ {
785
+ displayName: 'Image',
786
+ name: 'image',
787
+ values: [
788
+ {
789
+ displayName: 'Binary Field',
790
+ name: 'binaryPropertyName',
791
+ type: 'string',
792
+ default: 'logo',
793
+ required: true,
794
+ description: 'The name of the input item’s binary field holding the PNG or JPEG',
795
+ },
796
+ {
797
+ displayName: 'Field Name',
798
+ name: 'fieldName',
799
+ type: 'string',
800
+ default: 'logo',
801
+ required: true,
802
+ description: 'The name an Items entry uses in its "image" property to refer to this file. Must not be pdf, password or items.',
803
+ },
804
+ ],
805
+ },
806
+ ],
807
+ },
808
+ {
809
+ displayName: 'Query',
810
+ name: 'query',
811
+ type: 'string',
812
+ default: '',
813
+ required: true,
814
+ description: 'Text to find, or a regular expression when the Regex option is on. A match never spans two lines. Regex uses a safe subset of JavaScript syntax: backreferences, lookahead, lookbehind, named groups and inline flags are rejected.',
815
+ displayOptions: { show: { operation: ['findText'] } },
816
+ },
817
+ {
818
+ displayName: 'Find Options',
819
+ name: 'findOptions',
820
+ type: 'collection',
821
+ placeholder: 'Add Option',
822
+ default: {},
823
+ displayOptions: { show: { operation: ['findText'] } },
824
+ options: [
825
+ {
826
+ displayName: 'Case Sensitive',
827
+ name: 'case_sensitive',
828
+ type: 'boolean',
829
+ default: false,
830
+ description: 'Whether upper and lower case must match (off by default)',
831
+ },
832
+ {
833
+ displayName: 'Max Hits',
834
+ name: 'max_hits',
835
+ type: 'number',
836
+ typeOptions: { minValue: 1, maxValue: 1000 },
837
+ default: 100,
838
+ description: 'Most hits to return (1-1000). When the result has truncated true and nextPage is not null, the search stopped early: run it again with the same Query and options and Pages set to nextPage followed by a dash (for example 4-), keeping any page filter you used before and dropping pages below nextPage. No hit is repeated. Check pagesSkipped on every response: a page listed there held more hits than Max Hits (or was too large), only its first hits were returned, and no later request returns the rest, so raise Max Hits or narrow the Query for that page.',
839
+ },
840
+ {
841
+ displayName: 'Regex',
842
+ name: 'regex',
843
+ type: 'boolean',
844
+ default: false,
845
+ description: 'Whether the Query is a regular expression instead of literal text',
846
+ },
847
+ {
848
+ displayName: 'Whole Word',
849
+ name: 'whole_word',
850
+ type: 'boolean',
851
+ default: false,
852
+ description: 'Whether a hit must not touch a letter, digit or underscore on either side',
853
+ },
854
+ ],
855
+ },
856
+ {
857
+ displayName: 'Result Format',
858
+ name: 'textFormat',
859
+ type: 'options',
860
+ options: [
861
+ {
862
+ name: 'JSON (Pages, Lines and Tables)',
863
+ value: 'json',
864
+ description: 'Returns pageCount, pages[] (text, lines with positions, tables as rows), pagesWithoutText and truncated',
865
+ },
866
+ {
867
+ name: 'Plain Text',
868
+ value: 'text',
869
+ description: 'The text of all pages in the item JSON field "text", pages separated by a form feed',
870
+ },
871
+ ],
872
+ default: 'json',
873
+ displayOptions: { show: { operation: ['extractText'] } },
874
+ },
875
+ {
876
+ displayName: 'Tables As',
877
+ name: 'tablesFormat',
878
+ type: 'options',
879
+ options: [
880
+ {
881
+ name: 'CSV (Added to Each Table in the JSON)',
882
+ value: 'csv',
883
+ description: 'Each table also carries a "csv" string (RFC 4180); rows is unchanged',
884
+ },
885
+ {
886
+ name: 'Excel Workbook (Binary Output)',
887
+ value: 'xlsx',
888
+ description: 'Returns one .xlsx workbook as binary data instead of JSON: one sheet per table, every cell text. Fails with no_tables when the selected pages hold no table.',
889
+ },
890
+ {
891
+ name: 'JSON Rows',
892
+ value: 'json',
893
+ description: 'Tables as rows of cells in the JSON',
894
+ },
895
+ ],
896
+ default: 'json',
897
+ displayOptions: { show: { operation: ['extractText'], textFormat: ['json'] } },
898
+ },
899
+ {
900
+ displayName: 'HTML',
901
+ name: 'html',
902
+ type: 'string',
903
+ typeOptions: { rows: 8 },
904
+ default: '<h1>Hello</h1>\n<p>Rendered by PDFops.</p>',
905
+ required: true,
906
+ description: 'The HTML document to render, up to 1 MB. Text only: there is no URL input and JavaScript is switched off. External images, stylesheets and fonts load over https from public hosts only; data: URIs are the safest way to include images.',
907
+ displayOptions: { show: { operation: ['htmlToPdf'] } },
908
+ },
909
+ {
910
+ displayName: 'HTML Options',
911
+ name: 'htmlOptions',
912
+ type: 'collection',
913
+ placeholder: 'Add Option',
914
+ default: {},
915
+ displayOptions: { show: { operation: ['htmlToPdf'] } },
916
+ options: [
917
+ {
918
+ displayName: 'Landscape',
919
+ name: 'landscape',
920
+ type: 'boolean',
921
+ default: false,
922
+ description: 'Whether to lay the pages out in landscape',
923
+ },
924
+ {
925
+ displayName: 'Margin',
926
+ name: 'margin',
927
+ type: 'number',
928
+ typeOptions: { minValue: 0, maxValue: 144 },
929
+ default: 36,
930
+ description: 'Page margin in points on all four sides (0-144)',
931
+ },
932
+ {
933
+ displayName: 'Page Size',
934
+ name: 'page_size',
935
+ type: 'options',
936
+ options: [
937
+ { name: 'A4', value: 'a4' },
938
+ { name: 'Letter', value: 'letter' },
939
+ ],
940
+ default: 'letter',
941
+ },
942
+ {
943
+ displayName: 'Print Background',
944
+ name: 'print_background',
945
+ type: 'boolean',
946
+ default: true,
947
+ description: 'Whether to print CSS backgrounds and background images',
948
+ },
949
+ {
950
+ displayName: 'Scale',
951
+ name: 'scale',
952
+ type: 'number',
953
+ typeOptions: { minValue: 0.1, maxValue: 2, numberPrecision: 2 },
954
+ default: 1,
955
+ description: 'Rendering scale from 0.1 to 2',
956
+ },
957
+ ],
958
+ },
959
+ {
960
+ displayName: 'Content',
961
+ name: 'content',
962
+ type: 'string',
963
+ typeOptions: { rows: 8 },
964
+ default: '',
965
+ required: true,
966
+ description: 'The document, up to 512 KiB of UTF-8. Latin (WinAnsi) characters only; other scripts are rejected with the character and its line and column named. Not HTML: use HTML to PDF for that.',
967
+ displayOptions: { show: { operation: ['textToPdf'] } },
968
+ },
969
+ {
970
+ displayName: 'Text Options',
971
+ name: 'textOptions',
972
+ type: 'collection',
973
+ placeholder: 'Add Option',
974
+ default: {},
975
+ displayOptions: { show: { operation: ['textToPdf'] } },
976
+ options: [
977
+ {
978
+ displayName: 'Font Size',
979
+ name: 'font_size',
980
+ type: 'number',
981
+ typeOptions: { minValue: 6, maxValue: 36 },
982
+ default: 11,
983
+ description: 'Body text size in points (6-36)',
984
+ },
985
+ {
986
+ displayName: 'Format',
987
+ name: 'format',
988
+ type: 'options',
989
+ options: [
990
+ {
991
+ name: 'CSV',
992
+ value: 'csv',
993
+ description: 'A table whose first row is the header',
994
+ },
995
+ {
996
+ name: 'Markdown',
997
+ value: 'markdown',
998
+ description: 'Headings, lists, tables, code blocks and links',
999
+ },
1000
+ {
1001
+ name: 'Plain Text',
1002
+ value: 'text',
1003
+ description: 'Spaces and line breaks kept exactly',
1004
+ },
1005
+ ],
1006
+ default: 'markdown',
1007
+ },
1008
+ {
1009
+ displayName: 'Margin',
1010
+ name: 'margin',
1011
+ type: 'number',
1012
+ typeOptions: { minValue: 18, maxValue: 144 },
1013
+ default: 54,
1014
+ description: 'Page margin in points on all four sides (18-144)',
1015
+ },
1016
+ {
1017
+ displayName: 'Monospace',
1018
+ name: 'monospace',
1019
+ type: 'boolean',
1020
+ default: false,
1021
+ description: 'Whether to set plain text in Courier (Plain Text format only)',
1022
+ },
1023
+ {
1024
+ displayName: 'Page Numbers',
1025
+ name: 'page_numbers',
1026
+ type: 'boolean',
1027
+ default: false,
1028
+ description: 'Whether to print "Page n of N" in the bottom margin',
1029
+ },
1030
+ {
1031
+ displayName: 'Page Size',
1032
+ name: 'page_size',
1033
+ type: 'options',
1034
+ options: [
1035
+ { name: 'A4', value: 'a4' },
1036
+ { name: 'Letter', value: 'letter' },
1037
+ ],
1038
+ default: 'letter',
1039
+ },
1040
+ {
1041
+ displayName: 'Title',
1042
+ name: 'title',
1043
+ type: 'string',
1044
+ default: '',
1045
+ description: 'PDF title metadata, up to 200 characters. Not printed on the page.',
1046
+ },
1047
+ ],
1048
+ },
1049
+ {
1050
+ displayName: 'Image Options',
1051
+ name: 'imageOptions',
1052
+ type: 'collection',
1053
+ placeholder: 'Add Option',
1054
+ default: {},
1055
+ displayOptions: { show: { operation: ['imageToPdf'] } },
1056
+ options: [
1057
+ {
1058
+ displayName: 'Margin',
1059
+ name: 'margin',
1060
+ type: 'number',
1061
+ typeOptions: { minValue: 0, maxValue: 200 },
1062
+ default: 0,
1063
+ description: 'Margin in points (0-200). The API default is 0 for Fit to Image and 36 for A4 and Letter; for Fit to Image the page grows by the margin on each side.',
1064
+ },
1065
+ {
1066
+ displayName: 'Orientation',
1067
+ name: 'orientation',
1068
+ type: 'options',
1069
+ options: [
1070
+ { name: 'Auto (Per Image)', value: 'auto' },
1071
+ { name: 'Landscape', value: 'landscape' },
1072
+ { name: 'Portrait', value: 'portrait' },
1073
+ ],
1074
+ default: 'auto',
1075
+ description: 'Ignored for Fit to Image',
1076
+ },
1077
+ {
1078
+ displayName: 'Page Size',
1079
+ name: 'page_size',
1080
+ type: 'options',
1081
+ options: [
1082
+ { name: 'A4', value: 'a4' },
1083
+ { name: 'Fit to Image', value: 'fit' },
1084
+ { name: 'Letter', value: 'letter' },
1085
+ ],
1086
+ default: 'fit',
1087
+ description: 'Fit to Image makes each page the size of its image; A4 and Letter scale images down to fit, never up',
1088
+ },
1089
+ ],
1090
+ },
588
1091
  {
589
1092
  displayName: 'Invoice',
590
1093
  name: 'invoice',
591
1094
  type: 'json',
592
1095
  default: '{\n "from": "Acme Inc",\n "to": "Customer LLC",\n "items": [\n { "description": "Consulting", "quantity": 2, "unit_price": 100 }\n ]\n}',
593
1096
  required: true,
594
- description: 'Invoice data: from, to, items[] (description, quantity?, unit_price), and optionally invoice_number, date, due, currency, tax_rate, notes. Deterministic: the same input produces a byte-identical PDF.',
1097
+ description: 'Invoice data: from, to, items[] (description, quantity?, unit_price), and optionally invoice_number, date, due, currency, tax_rate, notes. Deterministic: the same input produces a byte-identical PDF. For a Factur-X e-invoice (node version 2), from and to also take country, street, postcode, city, vat_id (and from.tax_id with registration_id), and every item needs a unit.',
595
1098
  displayOptions: {
596
1099
  show: {
597
1100
  operation: ['invoice'],
598
1101
  },
599
1102
  },
600
1103
  },
1104
+ {
1105
+ displayName: 'Factur-X E-Invoice',
1106
+ name: 'eInvoice',
1107
+ type: 'boolean',
1108
+ default: false,
1109
+ description: 'Whether to produce a Factur-X (ZUGFeRD) e-invoice: a PDF/A-3 with the invoice data embedded as factur-x.xml, profile EN 16931. Required in the Invoice JSON then: invoice_number, date (YYYY-MM-DD), currency, due or payment_terms, from.country and to.country (ISO 3166-1 alpha-2), from.vat_id (or from.tax_id with from.registration_id; with tax category O, no VAT ID at all and from.registration_id instead), a buyer to.vat_id or to.registration_id for tax category AE, a UN/ECE Recommendation 20 unit on every item (C62 one, HUR hour, KGM kilogram), and tax_category when tax_rate is 0. Text is limited to Latin letters, Latin Extended-A, the euro sign and common punctuation. Tested with the Mustang validator; this is not a statement of legal compliance, and XRechnung and Peppol output are not produced.',
1110
+ displayOptions: { show: { '@version': [2], operation: ['invoice'] } },
1111
+ },
1112
+ {
1113
+ displayName: 'E-Invoice Options',
1114
+ name: 'eInvoiceOptions',
1115
+ type: 'collection',
1116
+ placeholder: 'Add Option',
1117
+ default: {},
1118
+ displayOptions: { show: { '@version': [2], operation: ['invoice'], eInvoice: [true] } },
1119
+ options: [
1120
+ {
1121
+ displayName: 'IBAN',
1122
+ name: 'iban',
1123
+ type: 'string',
1124
+ default: '',
1125
+ description: 'Seller bank account for the payment instructions (spaces are ignored)',
1126
+ },
1127
+ {
1128
+ displayName: 'Payment Terms',
1129
+ name: 'payment_terms',
1130
+ type: 'string',
1131
+ default: '',
1132
+ description: 'Payment terms text. Either this or a due date in the Invoice JSON is required.',
1133
+ },
1134
+ {
1135
+ displayName: 'Tax Category',
1136
+ name: 'tax_category',
1137
+ type: 'options',
1138
+ options: [
1139
+ { name: 'Exempt (E)', value: 'E' },
1140
+ { name: 'Not Subject to VAT (O)', value: 'O' },
1141
+ { name: 'Reverse Charge (AE)', value: 'AE' },
1142
+ { name: 'Standard Rate (S)', value: 'S' },
1143
+ { name: 'Zero Rate (Z)', value: 'Z' },
1144
+ ],
1145
+ default: 'S',
1146
+ description: 'EN 16931 VAT category for the whole invoice. S is the default when tax_rate is above 0; required when tax_rate is 0 or missing.',
1147
+ },
1148
+ {
1149
+ displayName: 'Tax Exemption Reason',
1150
+ name: 'tax_exemption_reason',
1151
+ type: 'string',
1152
+ default: '',
1153
+ description: 'Reason text, required for the Exempt, Reverse Charge and Not Subject to VAT categories',
1154
+ },
1155
+ ],
1156
+ },
601
1157
  {
602
1158
  displayName: 'Flatten',
603
1159
  name: 'flatten',
@@ -618,7 +1174,7 @@ class Pdfops {
618
1174
  hint: 'The name of the output item’s binary field to write the resulting PDF to',
619
1175
  displayOptions: {
620
1176
  show: {
621
- operation: ['fill', 'merge', 'invoice', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'setMetadata'],
1177
+ operation: ['fill', 'merge', 'invoice', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'setMetadata', 'addFields', 'attach', 'edit', 'htmlToPdf', 'imageToPdf', 'textToPdf'],
622
1178
  },
623
1179
  },
624
1180
  },
@@ -631,15 +1187,36 @@ class Pdfops {
631
1187
  description: 'File name for the output PDF. Defaults per operation. For Split PDF it is the prefix: parts are named prefix-1.pdf, prefix-2.pdf and so on',
632
1188
  displayOptions: {
633
1189
  show: {
634
- operation: ['fill', 'merge', 'invoice', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'setMetadata'],
1190
+ operation: ['fill', 'merge', 'invoice', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'setMetadata', 'addFields', 'attach', 'edit', 'htmlToPdf', 'imageToPdf', 'textToPdf'],
635
1191
  },
636
1192
  },
637
1193
  },
1194
+ {
1195
+ displayName: 'Output Binary Field',
1196
+ name: 'outputBinaryPropertyName',
1197
+ type: 'string',
1198
+ default: 'data',
1199
+ hint: 'The name of the output item’s binary field to write the Excel workbook to',
1200
+ displayOptions: {
1201
+ show: { operation: ['extractText'], textFormat: ['json'], tablesFormat: ['xlsx'] },
1202
+ },
1203
+ },
1204
+ {
1205
+ displayName: 'Output File Name',
1206
+ name: 'fileName',
1207
+ type: 'string',
1208
+ default: 'tables.xlsx',
1209
+ placeholder: 'e.g. tables.xlsx',
1210
+ description: 'File name for the output Excel workbook',
1211
+ displayOptions: {
1212
+ show: { operation: ['extractText'], textFormat: ['json'], tablesFormat: ['xlsx'] },
1213
+ },
1214
+ },
638
1215
  ],
639
1216
  };
640
1217
  }
641
1218
  async execute() {
642
- var _a, _b, _c, _d, _e, _f;
1219
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
643
1220
  const items = this.getInputData();
644
1221
  const returnData = [];
645
1222
  const operation = this.getNodeParameter('operation', 0);
@@ -650,6 +1227,7 @@ class Pdfops {
650
1227
  'X-Pdfops-Client': 'n8n',
651
1228
  'X-Pdfops-Client-Version': NODE_PACKAGE_VERSION,
652
1229
  };
1230
+ options.disableFollowRedirect = true;
653
1231
  if (hasCredential) {
654
1232
  return await this.helpers.httpRequestWithAuthentication.call(this, 'pdfopsApi', options);
655
1233
  }
@@ -673,11 +1251,41 @@ class Pdfops {
673
1251
  }
674
1252
  return value;
675
1253
  };
1254
+ const jsonArrayParam = (name, itemIndex) => {
1255
+ const raw = this.getNodeParameter(name, itemIndex);
1256
+ let value = raw;
1257
+ if (typeof raw === 'string') {
1258
+ try {
1259
+ value = JSON.parse(raw);
1260
+ }
1261
+ catch {
1262
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Parameter "${name}" is not valid JSON`, {
1263
+ itemIndex,
1264
+ });
1265
+ }
1266
+ }
1267
+ if (!Array.isArray(value)) {
1268
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Parameter "${name}" must be a JSON array`, {
1269
+ itemIndex,
1270
+ });
1271
+ }
1272
+ return value;
1273
+ };
676
1274
  const pdfBlob = async (itemIndex, binaryPropertyName) => {
677
1275
  this.helpers.assertBinaryData(itemIndex, binaryPropertyName);
678
1276
  const buffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
679
1277
  return new Blob([new Uint8Array(buffer)], { type: 'application/pdf' });
680
1278
  };
1279
+ const fileBlob = async (itemIndex, binaryPropertyName, mimeType) => {
1280
+ const meta = this.helpers.assertBinaryData(itemIndex, binaryPropertyName);
1281
+ const buffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
1282
+ return {
1283
+ blob: new Blob([new Uint8Array(buffer)], {
1284
+ type: mimeType || meta.mimeType || 'application/octet-stream',
1285
+ }),
1286
+ fileName: meta.fileName || binaryPropertyName,
1287
+ };
1288
+ };
681
1289
  if (operation === 'merge') {
682
1290
  const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
683
1291
  const fileName = this.getNodeParameter('fileName', 0) || 'merged.pdf';
@@ -721,6 +1329,52 @@ class Pdfops {
721
1329
  }
722
1330
  return [returnData];
723
1331
  }
1332
+ if (operation === 'imageToPdf') {
1333
+ const formData = new FormData();
1334
+ try {
1335
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
1336
+ const fileName = this.getNodeParameter('fileName', 0) || 'images.pdf';
1337
+ const outputBinaryPropertyName = this.getNodeParameter('outputBinaryPropertyName', 0);
1338
+ for (let i = 0; i < items.length; i++) {
1339
+ const image = await fileBlob(i, binaryPropertyName);
1340
+ formData.append('pdf', image.blob, image.fileName);
1341
+ }
1342
+ const imageOptions = this.getNodeParameter('imageOptions', 0, {});
1343
+ for (const [k, v] of Object.entries(imageOptions)) {
1344
+ if (v !== undefined && v !== null && v !== '')
1345
+ formData.append(k, String(v));
1346
+ }
1347
+ const response = (await request({
1348
+ method: 'POST',
1349
+ url: `${BASE_URL}/api/image-to-pdf`,
1350
+ body: formData,
1351
+ encoding: 'arraybuffer',
1352
+ }));
1353
+ returnData.push({
1354
+ json: { fileName, imageCount: items.length },
1355
+ binary: {
1356
+ [outputBinaryPropertyName]: await this.helpers.prepareBinaryData(response, fileName, 'application/pdf'),
1357
+ },
1358
+ pairedItem: items.map((_, i) => ({ item: i })),
1359
+ });
1360
+ }
1361
+ catch (error) {
1362
+ const apiError = (0, decodeApiError_1.decodeApiError)(error);
1363
+ if (this.continueOnFail()) {
1364
+ returnData.push({
1365
+ json: {
1366
+ error: (_d = apiError === null || apiError === void 0 ? void 0 : apiError.message) !== null && _d !== void 0 ? _d : error.message,
1367
+ ...((apiError === null || apiError === void 0 ? void 0 : apiError.details) ? { message: apiError.details } : {}),
1368
+ },
1369
+ pairedItem: items.map((_, i) => ({ item: i })),
1370
+ });
1371
+ }
1372
+ else {
1373
+ throw withApiMessage(new n8n_workflow_1.NodeApiError(this.getNode(), error), apiError);
1374
+ }
1375
+ }
1376
+ return [returnData];
1377
+ }
724
1378
  if (operation === 'usage' && !hasCredential) {
725
1379
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The Get Usage operation requires a PDFops API credential (free key at https://pdfops.dev/pricing)');
726
1380
  }
@@ -728,6 +1382,7 @@ class Pdfops {
728
1382
  let options;
729
1383
  let binaryOut;
730
1384
  let splitOut = false;
1385
+ let textOut = false;
731
1386
  try {
732
1387
  if (operation === 'inspect') {
733
1388
  const formData = new FormData();
@@ -759,10 +1414,19 @@ class Pdfops {
759
1414
  };
760
1415
  }
761
1416
  else if (operation === 'invoice') {
1417
+ const invoiceBody = { ...jsonParam('invoice', i) };
1418
+ if (this.getNodeParameter('eInvoice', i, false)) {
1419
+ invoiceBody.e_invoice = 'factur-x';
1420
+ const eInvoiceOptions = this.getNodeParameter('eInvoiceOptions', i, {});
1421
+ for (const [k, v] of Object.entries(eInvoiceOptions)) {
1422
+ if (v !== undefined && v !== null && v !== '')
1423
+ invoiceBody[k] = v;
1424
+ }
1425
+ }
762
1426
  options = {
763
1427
  method: 'POST',
764
1428
  url: `${BASE_URL}/api/invoice`,
765
- body: jsonParam('invoice', i),
1429
+ body: invoiceBody,
766
1430
  json: true,
767
1431
  encoding: 'arraybuffer',
768
1432
  };
@@ -771,6 +1435,28 @@ class Pdfops {
771
1435
  property: this.getNodeParameter('outputBinaryPropertyName', i),
772
1436
  };
773
1437
  }
1438
+ else if (operation === 'htmlToPdf' || operation === 'textToPdf') {
1439
+ const isHtml = operation === 'htmlToPdf';
1440
+ const body = isHtml
1441
+ ? { html: this.getNodeParameter('html', i) }
1442
+ : { content: this.getNodeParameter('content', i) };
1443
+ const extra = this.getNodeParameter(isHtml ? 'htmlOptions' : 'textOptions', i, {});
1444
+ for (const [k, v] of Object.entries(extra)) {
1445
+ if (v !== undefined && v !== null && v !== '')
1446
+ body[k] = v;
1447
+ }
1448
+ options = {
1449
+ method: 'POST',
1450
+ url: `${BASE_URL}/api/${isHtml ? 'html-to-pdf' : 'text-to-pdf'}`,
1451
+ body,
1452
+ json: true,
1453
+ encoding: 'arraybuffer',
1454
+ };
1455
+ binaryOut = {
1456
+ fileName: this.getNodeParameter('fileName', i) || 'document.pdf',
1457
+ property: this.getNodeParameter('outputBinaryPropertyName', i),
1458
+ };
1459
+ }
774
1460
  else if (DOC_OPS[operation]) {
775
1461
  const spec = DOC_OPS[operation];
776
1462
  const formData = new FormData();
@@ -816,7 +1502,99 @@ class Pdfops {
816
1502
  formData.append(k, String(v !== null && v !== void 0 ? v : ''));
817
1503
  }
818
1504
  }
819
- if (spec.output === 'pdf') {
1505
+ else if (operation === 'addFields') {
1506
+ formData.append('fields', JSON.stringify(jsonArrayParam('formFields', i)));
1507
+ }
1508
+ else if (operation === 'edit') {
1509
+ formData.append('items', JSON.stringify(jsonArrayParam('editItems', i)));
1510
+ const images = this.getNodeParameter('imageFiles', i, {}).image;
1511
+ const seenImageNames = new Set();
1512
+ for (const image of images !== null && images !== void 0 ? images : []) {
1513
+ if (!/^[A-Za-z0-9_.-]{1,64}$/.test((_e = image.fieldName) !== null && _e !== void 0 ? _e : '')) {
1514
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Image field name "${(_f = image.fieldName) !== null && _f !== void 0 ? _f : ''}" is not allowed: use 1-64 letters, digits, "_", "." or "-"`, { itemIndex: i });
1515
+ }
1516
+ if (['pdf', 'password', 'items'].includes(image.fieldName)) {
1517
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Image field name "${image.fieldName}" is reserved; use another name`, { itemIndex: i });
1518
+ }
1519
+ if (seenImageNames.has(image.fieldName)) {
1520
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Image field name "${image.fieldName}" is used twice; each image needs its own name`, { itemIndex: i });
1521
+ }
1522
+ seenImageNames.add(image.fieldName);
1523
+ const file = await fileBlob(i, image.binaryPropertyName);
1524
+ formData.append(image.fieldName, file.blob, file.fileName);
1525
+ }
1526
+ }
1527
+ else if (operation === 'attach') {
1528
+ const files = this.getNodeParameter('attachments', i, {}).file;
1529
+ if (!(files === null || files === void 0 ? void 0 : files.length)) {
1530
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Add at least one file to attach', {
1531
+ itemIndex: i,
1532
+ });
1533
+ }
1534
+ const perFile = [];
1535
+ for (const f of files) {
1536
+ const file = await fileBlob(i, f.binaryPropertyName, f.mimeType);
1537
+ const name = f.name || file.fileName;
1538
+ formData.append('file', file.blob, name);
1539
+ const entry = { name };
1540
+ if (f.mimeType)
1541
+ entry.mime_type = f.mimeType;
1542
+ if (f.description)
1543
+ entry.description = f.description;
1544
+ if (f.relationship)
1545
+ entry.relationship = f.relationship;
1546
+ perFile.push(entry);
1547
+ }
1548
+ formData.append('options', JSON.stringify(perFile));
1549
+ }
1550
+ else if (operation === 'findText') {
1551
+ add('query', this.getNodeParameter('query', i));
1552
+ add('pages', this.getNodeParameter('pages', i));
1553
+ for (const [k, v] of Object.entries(collection('findOptions')))
1554
+ add(k, v);
1555
+ }
1556
+ else if (operation === 'extractText') {
1557
+ add('pages', this.getNodeParameter('pages', i));
1558
+ }
1559
+ if (spec.output === 'extract') {
1560
+ const format = this.getNodeParameter('textFormat', i);
1561
+ const tablesFormat = format === 'json' ? this.getNodeParameter('tablesFormat', i) : 'json';
1562
+ if (format === 'text')
1563
+ formData.append('format', 'text');
1564
+ if (tablesFormat !== 'json')
1565
+ formData.append('tables_format', tablesFormat);
1566
+ if (tablesFormat === 'xlsx') {
1567
+ options = {
1568
+ method: 'POST',
1569
+ url: `${BASE_URL}/api/${spec.path}`,
1570
+ body: formData,
1571
+ encoding: 'arraybuffer',
1572
+ };
1573
+ binaryOut = {
1574
+ fileName: this.getNodeParameter('fileName', i) || spec.defaultFile,
1575
+ property: this.getNodeParameter('outputBinaryPropertyName', i),
1576
+ mimeType: XLSX_MIME_TYPE,
1577
+ };
1578
+ }
1579
+ else if (format === 'text') {
1580
+ textOut = true;
1581
+ options = {
1582
+ method: 'POST',
1583
+ url: `${BASE_URL}/api/${spec.path}`,
1584
+ body: formData,
1585
+ encoding: 'text',
1586
+ };
1587
+ }
1588
+ else {
1589
+ options = {
1590
+ method: 'POST',
1591
+ url: `${BASE_URL}/api/${spec.path}`,
1592
+ body: formData,
1593
+ json: true,
1594
+ };
1595
+ }
1596
+ }
1597
+ else if (spec.output === 'pdf') {
820
1598
  options = {
821
1599
  method: 'POST',
822
1600
  url: `${BASE_URL}/api/${spec.path}`,
@@ -861,7 +1639,7 @@ class Pdfops {
861
1639
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
862
1640
  }
863
1641
  try {
864
- if (binaryOut && !splitOut)
1642
+ if ((binaryOut && !splitOut) || textOut)
865
1643
  options.returnFullResponse = true;
866
1644
  const response = await request(options);
867
1645
  if (splitOut && binaryOut) {
@@ -882,10 +1660,20 @@ class Pdfops {
882
1660
  });
883
1661
  }
884
1662
  }
1663
+ else if (textOut) {
1664
+ const full = response;
1665
+ returnData.push({
1666
+ json: {
1667
+ text: full.body,
1668
+ truncated: headerTrue((_g = full.headers) === null || _g === void 0 ? void 0 : _g['x-pdfops-truncated']),
1669
+ },
1670
+ pairedItem: { item: i },
1671
+ });
1672
+ }
885
1673
  else if (binaryOut) {
886
1674
  const full = response;
887
1675
  const json = { fileName: binaryOut.fileName };
888
- const fieldMap = (_d = full.headers) === null || _d === void 0 ? void 0 : _d['x-pdfops-field-map'];
1676
+ const fieldMap = (_h = full.headers) === null || _h === void 0 ? void 0 : _h['x-pdfops-field-map'];
889
1677
  if (fieldMap) {
890
1678
  try {
891
1679
  json.field_map = JSON.parse(fieldMap);
@@ -894,13 +1682,58 @@ class Pdfops {
894
1682
  json.field_map = fieldMap;
895
1683
  }
896
1684
  }
897
- const note = (_e = full.headers) === null || _e === void 0 ? void 0 : _e['x-pdfops-note'];
1685
+ const note = (_j = full.headers) === null || _j === void 0 ? void 0 : _j['x-pdfops-note'];
898
1686
  if (note)
899
1687
  json.note = note;
1688
+ if (operation === 'attach') {
1689
+ let keys = [];
1690
+ try {
1691
+ const parsed = JSON.parse(String((_k = full.headers) === null || _k === void 0 ? void 0 : _k['x-pdfops-attachment-keys']));
1692
+ if (Array.isArray(parsed)) {
1693
+ keys = parsed
1694
+ .filter((e) => typeof (e === null || e === void 0 ? void 0 : e.name) === 'string' && typeof (e === null || e === void 0 ? void 0 : e.key) === 'string')
1695
+ .map((e) => ({ name: e.name, key: e.key }));
1696
+ }
1697
+ }
1698
+ catch {
1699
+ keys = [];
1700
+ }
1701
+ json.attachment_keys = keys;
1702
+ }
1703
+ if (operation === 'extractText') {
1704
+ if (headerTrue((_l = full.headers) === null || _l === void 0 ? void 0 : _l['x-pdfops-truncated'])) {
1705
+ json.truncated = true;
1706
+ const truncatedBy = (_m = full.headers) === null || _m === void 0 ? void 0 : _m['x-pdfops-truncated-by'];
1707
+ if (typeof truncatedBy === 'string' && truncatedBy) {
1708
+ json.truncated_by = truncatedBy.split(',');
1709
+ }
1710
+ }
1711
+ if (headerTrue((_o = full.headers) === null || _o === void 0 ? void 0 : _o['x-pdfops-cells-truncated']))
1712
+ json.cells_truncated = true;
1713
+ const body = Buffer.from(full.body);
1714
+ if (body.length < 4 || body.readUInt32BE(0) !== 0x504b0304) {
1715
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The API did not return an Excel workbook (the response is not a zip file)', { itemIndex: i });
1716
+ }
1717
+ }
1718
+ if (operation === 'addFields') {
1719
+ const warning = (_p = full.headers) === null || _p === void 0 ? void 0 : _p['x-pdfops-warning'];
1720
+ if (typeof warning === 'string' && warning)
1721
+ json.warning = warning;
1722
+ }
1723
+ if (operation === 'htmlToPdf') {
1724
+ for (const [header, key] of [
1725
+ ['x-pdfops-pages', 'pages'],
1726
+ ['x-pdfops-blocked-requests', 'blocked_requests'],
1727
+ ]) {
1728
+ const value = (_q = full.headers) === null || _q === void 0 ? void 0 : _q[header];
1729
+ if (typeof value === 'string' && /^\d+$/.test(value))
1730
+ json[key] = Number(value);
1731
+ }
1732
+ }
900
1733
  returnData.push({
901
1734
  json,
902
1735
  binary: {
903
- [binaryOut.property]: await this.helpers.prepareBinaryData(full.body, binaryOut.fileName, 'application/pdf'),
1736
+ [binaryOut.property]: await this.helpers.prepareBinaryData(full.body, binaryOut.fileName, (_r = binaryOut.mimeType) !== null && _r !== void 0 ? _r : 'application/pdf'),
904
1737
  },
905
1738
  pairedItem: { item: i },
906
1739
  });
@@ -914,7 +1747,7 @@ class Pdfops {
914
1747
  if (this.continueOnFail()) {
915
1748
  returnData.push({
916
1749
  json: {
917
- error: (_f = apiError === null || apiError === void 0 ? void 0 : apiError.message) !== null && _f !== void 0 ? _f : error.message,
1750
+ error: (_s = apiError === null || apiError === void 0 ? void 0 : apiError.message) !== null && _s !== void 0 ? _s : error.message,
918
1751
  ...((apiError === null || apiError === void 0 ? void 0 : apiError.details) ? { message: apiError.details } : {}),
919
1752
  },
920
1753
  pairedItem: { item: i },