n8n-nodes-pdf-api-hub 4.0.7 → 4.0.9
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
|
@@ -11,6 +11,8 @@ An n8n community node for **PDF API Hub** (Get your api key from [https://pdfapi
|
|
|
11
11
|
- Lock and unlock password-protected PDFs
|
|
12
12
|
- Convert images to PDF (PNG/WebP/JPG)
|
|
13
13
|
- Convert PDFs to images (PNG/WebP/JPG)
|
|
14
|
+
- Convert Office-like documents to PDF (DOCX/DOC/PPTX/XLSX/etc.)
|
|
15
|
+
- Convert PDFs to DOCX
|
|
14
16
|
- Convert a website URL to a PDF (screenshot)
|
|
15
17
|
- Convert HTML/CSS to a PDF
|
|
16
18
|
- Convert URL/HTML to image
|
|
@@ -33,6 +35,8 @@ An n8n community node for **PDF API Hub** (Get your api key from [https://pdfapi
|
|
|
33
35
|
- [PDF Lock](#pdf-lock)
|
|
34
36
|
- [PDF Unlock](#pdf-unlock)
|
|
35
37
|
- [Image to PDF (PNG/WebP/JPG)](#image-to-pdf-pngwebpjpg)
|
|
38
|
+
- [Document to PDF (DOCX/DOC/PPTX/XLSX/etc.)](#document-to-pdf-docxdocpptxxlsxetc)
|
|
39
|
+
- [PDF to DOCX](#pdf-to-docx)
|
|
36
40
|
- [PDF to Image (PNG/WebP/JPG)](#pdf-to-image-pngwebpjpg)
|
|
37
41
|
- [URL to PDF (Website Screenshot)](#url-to-pdf-website-screenshot)
|
|
38
42
|
- [HTML to PDF](#html-to-pdf)
|
|
@@ -120,7 +124,9 @@ Returns: JSON (extracted text/structure)
|
|
|
120
124
|
|
|
121
125
|
Parameters:
|
|
122
126
|
|
|
123
|
-
- **PDF
|
|
127
|
+
- **PDF Input Type**: `url` or `file`
|
|
128
|
+
- **PDF URL** (default: `https://pdfapihub.com/sample-pdfinvoice-with-image.pdf`) (URL mode)
|
|
129
|
+
- **Binary Property Name**: incoming binary PDF (File mode)
|
|
124
130
|
- **Pages**: page number or `all` (default: `1`, max supported: `8`)
|
|
125
131
|
- **Language**, **DPI**, **PSM**, **OEM**
|
|
126
132
|
|
|
@@ -134,9 +140,10 @@ Returns: JSON (OCR text)
|
|
|
134
140
|
|
|
135
141
|
Parameters:
|
|
136
142
|
|
|
137
|
-
- **Image Input Type**: `url` or `
|
|
143
|
+
- **Image Input Type**: `url`, `base64`, or `file`
|
|
138
144
|
- **Image URL** (default: `https://pdfapihub.com/sample-invoicepage.png`) (URL mode)
|
|
139
145
|
- **Base64 Image** (Base64 mode)
|
|
146
|
+
- **Binary Property Name**: incoming binary image (File mode)
|
|
140
147
|
- **Language**, **PSM**, **OEM**
|
|
141
148
|
|
|
142
149
|
Returns: JSON (OCR text)
|
|
@@ -281,6 +288,37 @@ Parameters:
|
|
|
281
288
|
- **Output Format**: `url` / `base64` / `both` / `file`
|
|
282
289
|
- **Output Filename**
|
|
283
290
|
|
|
291
|
+
### Document to PDF (DOCX/DOC/PPTX/XLSX/etc.)
|
|
292
|
+
|
|
293
|
+
- Endpoint: `POST https://pdfapihub.com/api/v1/convert/document/pdf`
|
|
294
|
+
- Node: **Resource** → Document Conversion
|
|
295
|
+
- Operation: **DOCX / Document to PDF**
|
|
296
|
+
|
|
297
|
+
Parameters:
|
|
298
|
+
|
|
299
|
+
- **Input Type**: `url` / `base64` / `file`
|
|
300
|
+
- **Document URL** (URL mode)
|
|
301
|
+
- **Base64 File** (Base64 mode)
|
|
302
|
+
- **Binary Property Name** (File mode)
|
|
303
|
+
- **Input Format** (optional): `doc`, `docx`, `odt`, `rtf`, `txt`, `ppt`, `pptx`, `odp`, `xls`, `xlsx`, `ods`
|
|
304
|
+
- **Output Format**: `url` / `base64` / `both` / `file`
|
|
305
|
+
- **Output Filename**
|
|
306
|
+
|
|
307
|
+
### PDF to DOCX
|
|
308
|
+
|
|
309
|
+
- Endpoint: `POST https://pdfapihub.com/api/v1/convert/pdf/docx`
|
|
310
|
+
- Node: **Resource** → Document Conversion
|
|
311
|
+
- Operation: **PDF to DOCX**
|
|
312
|
+
|
|
313
|
+
Parameters:
|
|
314
|
+
|
|
315
|
+
- **Input Type**: `url` / `base64` / `file`
|
|
316
|
+
- **PDF URL** (URL mode)
|
|
317
|
+
- **Base64 PDF** (Base64 mode)
|
|
318
|
+
- **Binary Property Name** (File mode)
|
|
319
|
+
- **Output Format**: `url` / `base64` / `both` / `file`
|
|
320
|
+
- **Output Filename**
|
|
321
|
+
|
|
284
322
|
### PDF to Image (PNG/WebP/JPG)
|
|
285
323
|
|
|
286
324
|
- Endpoint: `POST https://pdfapihub.com/api/v1/convert/pdf/image`
|
|
@@ -30,6 +30,11 @@ class PdfSplitMerge {
|
|
|
30
30
|
type: 'options',
|
|
31
31
|
noDataExpression: true,
|
|
32
32
|
options: [
|
|
33
|
+
{
|
|
34
|
+
name: 'Document Conversion',
|
|
35
|
+
value: 'documentConversion',
|
|
36
|
+
description: 'Convert DOCX/Office documents to PDF and PDF to DOCX',
|
|
37
|
+
},
|
|
33
38
|
{
|
|
34
39
|
name: 'Image to PDF',
|
|
35
40
|
value: 'imageToPdf',
|
|
@@ -193,6 +198,32 @@ class PdfSplitMerge {
|
|
|
193
198
|
],
|
|
194
199
|
default: 'pngToPdf',
|
|
195
200
|
},
|
|
201
|
+
{
|
|
202
|
+
displayName: 'Operation',
|
|
203
|
+
name: 'operation',
|
|
204
|
+
type: 'options',
|
|
205
|
+
noDataExpression: true,
|
|
206
|
+
displayOptions: {
|
|
207
|
+
show: {
|
|
208
|
+
resource: ['documentConversion'],
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
options: [
|
|
212
|
+
{
|
|
213
|
+
name: 'DOCX / Document to PDF',
|
|
214
|
+
value: 'docxToPdf',
|
|
215
|
+
description: 'Convert Office-like documents (DOCX, PPTX, XLSX, etc.) to PDF',
|
|
216
|
+
action: 'Convert a document to PDF',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'PDF to DOCX',
|
|
220
|
+
value: 'pdfToDocx',
|
|
221
|
+
description: 'Convert PDF to DOCX',
|
|
222
|
+
action: 'Convert a pdf to docx',
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
default: 'docxToPdf',
|
|
226
|
+
},
|
|
196
227
|
{
|
|
197
228
|
displayName: 'Operation',
|
|
198
229
|
name: 'operation',
|
|
@@ -1286,6 +1317,22 @@ class PdfSplitMerge {
|
|
|
1286
1317
|
},
|
|
1287
1318
|
],
|
|
1288
1319
|
},
|
|
1320
|
+
{
|
|
1321
|
+
displayName: 'PDF Input Type',
|
|
1322
|
+
name: 'ocr_pdf_input_type',
|
|
1323
|
+
type: 'options',
|
|
1324
|
+
options: [
|
|
1325
|
+
{ name: 'URL', value: 'url' },
|
|
1326
|
+
{ name: 'File (Binary)', value: 'file' },
|
|
1327
|
+
],
|
|
1328
|
+
default: 'url',
|
|
1329
|
+
description: 'How to provide the PDF for OCR',
|
|
1330
|
+
displayOptions: {
|
|
1331
|
+
show: {
|
|
1332
|
+
operation: ['pdfOcrParse'],
|
|
1333
|
+
},
|
|
1334
|
+
},
|
|
1335
|
+
},
|
|
1289
1336
|
{
|
|
1290
1337
|
displayName: 'PDF URL',
|
|
1291
1338
|
name: 'ocr_pdf_url',
|
|
@@ -1295,6 +1342,20 @@ class PdfSplitMerge {
|
|
|
1295
1342
|
displayOptions: {
|
|
1296
1343
|
show: {
|
|
1297
1344
|
operation: ['pdfOcrParse'],
|
|
1345
|
+
ocr_pdf_input_type: ['url'],
|
|
1346
|
+
},
|
|
1347
|
+
},
|
|
1348
|
+
},
|
|
1349
|
+
{
|
|
1350
|
+
displayName: 'Binary Property Name',
|
|
1351
|
+
name: 'ocr_pdf_binary_property',
|
|
1352
|
+
type: 'string',
|
|
1353
|
+
default: 'data',
|
|
1354
|
+
description: 'Binary property containing the PDF file',
|
|
1355
|
+
displayOptions: {
|
|
1356
|
+
show: {
|
|
1357
|
+
operation: ['pdfOcrParse'],
|
|
1358
|
+
ocr_pdf_input_type: ['file'],
|
|
1298
1359
|
},
|
|
1299
1360
|
},
|
|
1300
1361
|
},
|
|
@@ -1317,6 +1378,7 @@ class PdfSplitMerge {
|
|
|
1317
1378
|
options: [
|
|
1318
1379
|
{ name: 'URL', value: 'url' },
|
|
1319
1380
|
{ name: 'Base64', value: 'base64' },
|
|
1381
|
+
{ name: 'File (Binary)', value: 'file' },
|
|
1320
1382
|
],
|
|
1321
1383
|
default: 'url',
|
|
1322
1384
|
description: 'How to provide the image',
|
|
@@ -1352,6 +1414,19 @@ class PdfSplitMerge {
|
|
|
1352
1414
|
},
|
|
1353
1415
|
},
|
|
1354
1416
|
},
|
|
1417
|
+
{
|
|
1418
|
+
displayName: 'Binary Property Name',
|
|
1419
|
+
name: 'ocr_image_binary_property',
|
|
1420
|
+
type: 'string',
|
|
1421
|
+
default: 'data',
|
|
1422
|
+
description: 'Binary property containing the image file',
|
|
1423
|
+
displayOptions: {
|
|
1424
|
+
show: {
|
|
1425
|
+
operation: ['imageOcrParse'],
|
|
1426
|
+
ocr_image_input_type: ['file'],
|
|
1427
|
+
},
|
|
1428
|
+
},
|
|
1429
|
+
},
|
|
1355
1430
|
{
|
|
1356
1431
|
displayName: 'Language',
|
|
1357
1432
|
name: 'ocr_lang',
|
|
@@ -1530,6 +1605,206 @@ class PdfSplitMerge {
|
|
|
1530
1605
|
},
|
|
1531
1606
|
},
|
|
1532
1607
|
},
|
|
1608
|
+
{
|
|
1609
|
+
displayName: 'Input Type',
|
|
1610
|
+
name: 'doc2pdf_input_type',
|
|
1611
|
+
type: 'options',
|
|
1612
|
+
options: [
|
|
1613
|
+
{ name: 'URL', value: 'url' },
|
|
1614
|
+
{ name: 'Base64', value: 'base64' },
|
|
1615
|
+
{ name: 'File (Binary)', value: 'file' },
|
|
1616
|
+
],
|
|
1617
|
+
default: 'url',
|
|
1618
|
+
description: 'How to provide the source document',
|
|
1619
|
+
displayOptions: {
|
|
1620
|
+
show: {
|
|
1621
|
+
operation: ['docxToPdf'],
|
|
1622
|
+
},
|
|
1623
|
+
},
|
|
1624
|
+
},
|
|
1625
|
+
{
|
|
1626
|
+
displayName: 'Document URL',
|
|
1627
|
+
name: 'doc2pdf_url',
|
|
1628
|
+
type: 'string',
|
|
1629
|
+
default: '',
|
|
1630
|
+
description: 'Public URL of the source document',
|
|
1631
|
+
placeholder: 'https://example.com/sample.docx',
|
|
1632
|
+
displayOptions: {
|
|
1633
|
+
show: {
|
|
1634
|
+
operation: ['docxToPdf'],
|
|
1635
|
+
doc2pdf_input_type: ['url'],
|
|
1636
|
+
},
|
|
1637
|
+
},
|
|
1638
|
+
},
|
|
1639
|
+
{
|
|
1640
|
+
displayName: 'Base64 File',
|
|
1641
|
+
name: 'doc2pdf_base64_file',
|
|
1642
|
+
type: 'string',
|
|
1643
|
+
default: '',
|
|
1644
|
+
description: 'Base64 encoded source document',
|
|
1645
|
+
displayOptions: {
|
|
1646
|
+
show: {
|
|
1647
|
+
operation: ['docxToPdf'],
|
|
1648
|
+
doc2pdf_input_type: ['base64'],
|
|
1649
|
+
},
|
|
1650
|
+
},
|
|
1651
|
+
},
|
|
1652
|
+
{
|
|
1653
|
+
displayName: 'Binary Property Name',
|
|
1654
|
+
name: 'doc2pdf_file_binary_property',
|
|
1655
|
+
type: 'string',
|
|
1656
|
+
default: 'data',
|
|
1657
|
+
description: 'Binary property containing the source document file',
|
|
1658
|
+
displayOptions: {
|
|
1659
|
+
show: {
|
|
1660
|
+
operation: ['docxToPdf'],
|
|
1661
|
+
doc2pdf_input_type: ['file'],
|
|
1662
|
+
},
|
|
1663
|
+
},
|
|
1664
|
+
},
|
|
1665
|
+
{
|
|
1666
|
+
displayName: 'Input Format',
|
|
1667
|
+
name: 'doc2pdf_input_format',
|
|
1668
|
+
type: 'options',
|
|
1669
|
+
options: [
|
|
1670
|
+
{ name: 'Auto Detect', value: '' },
|
|
1671
|
+
{ name: 'DOC', value: 'doc' },
|
|
1672
|
+
{ name: 'DOCX', value: 'docx' },
|
|
1673
|
+
{ name: 'ODP', value: 'odp' },
|
|
1674
|
+
{ name: 'ODS', value: 'ods' },
|
|
1675
|
+
{ name: 'ODT', value: 'odt' },
|
|
1676
|
+
{ name: 'PPT', value: 'ppt' },
|
|
1677
|
+
{ name: 'PPTX', value: 'pptx' },
|
|
1678
|
+
{ name: 'RTF', value: 'rtf' },
|
|
1679
|
+
{ name: 'TXT', value: 'txt' },
|
|
1680
|
+
{ name: 'XLS', value: 'xls' },
|
|
1681
|
+
{ name: 'XLSX', value: 'xlsx' },
|
|
1682
|
+
],
|
|
1683
|
+
default: '',
|
|
1684
|
+
description: 'Optional source format (recommended for base64 input)',
|
|
1685
|
+
displayOptions: {
|
|
1686
|
+
show: {
|
|
1687
|
+
operation: ['docxToPdf'],
|
|
1688
|
+
},
|
|
1689
|
+
},
|
|
1690
|
+
},
|
|
1691
|
+
{
|
|
1692
|
+
displayName: 'Output Format',
|
|
1693
|
+
name: 'doc2pdf_output',
|
|
1694
|
+
type: 'options',
|
|
1695
|
+
options: [
|
|
1696
|
+
{ name: 'URL', value: 'url' },
|
|
1697
|
+
{ name: 'Base64', value: 'base64' },
|
|
1698
|
+
{ name: 'Both', value: 'both' },
|
|
1699
|
+
{ name: 'File', value: 'file' },
|
|
1700
|
+
],
|
|
1701
|
+
default: 'url',
|
|
1702
|
+
description: 'Format of the output PDF',
|
|
1703
|
+
displayOptions: {
|
|
1704
|
+
show: {
|
|
1705
|
+
operation: ['docxToPdf'],
|
|
1706
|
+
},
|
|
1707
|
+
},
|
|
1708
|
+
},
|
|
1709
|
+
{
|
|
1710
|
+
displayName: 'Output Filename',
|
|
1711
|
+
name: 'doc2pdf_output_filename',
|
|
1712
|
+
type: 'string',
|
|
1713
|
+
default: 'converted.pdf',
|
|
1714
|
+
description: 'Optional output filename (used for file output)',
|
|
1715
|
+
displayOptions: {
|
|
1716
|
+
show: {
|
|
1717
|
+
operation: ['docxToPdf'],
|
|
1718
|
+
},
|
|
1719
|
+
},
|
|
1720
|
+
},
|
|
1721
|
+
{
|
|
1722
|
+
displayName: 'Input Type',
|
|
1723
|
+
name: 'pdf2docx_input_type',
|
|
1724
|
+
type: 'options',
|
|
1725
|
+
options: [
|
|
1726
|
+
{ name: 'URL', value: 'url' },
|
|
1727
|
+
{ name: 'Base64', value: 'base64' },
|
|
1728
|
+
{ name: 'File (Binary)', value: 'file' },
|
|
1729
|
+
],
|
|
1730
|
+
default: 'url',
|
|
1731
|
+
description: 'How to provide the source PDF',
|
|
1732
|
+
displayOptions: {
|
|
1733
|
+
show: {
|
|
1734
|
+
operation: ['pdfToDocx'],
|
|
1735
|
+
},
|
|
1736
|
+
},
|
|
1737
|
+
},
|
|
1738
|
+
{
|
|
1739
|
+
displayName: 'PDF URL',
|
|
1740
|
+
name: 'pdf2docx_url',
|
|
1741
|
+
type: 'string',
|
|
1742
|
+
default: '',
|
|
1743
|
+
description: 'Public URL of the source PDF',
|
|
1744
|
+
placeholder: 'https://pdfapihub.com/sample.pdf',
|
|
1745
|
+
displayOptions: {
|
|
1746
|
+
show: {
|
|
1747
|
+
operation: ['pdfToDocx'],
|
|
1748
|
+
pdf2docx_input_type: ['url'],
|
|
1749
|
+
},
|
|
1750
|
+
},
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
displayName: 'Base64 PDF',
|
|
1754
|
+
name: 'pdf2docx_base64_file',
|
|
1755
|
+
type: 'string',
|
|
1756
|
+
default: '',
|
|
1757
|
+
description: 'Base64 encoded PDF',
|
|
1758
|
+
displayOptions: {
|
|
1759
|
+
show: {
|
|
1760
|
+
operation: ['pdfToDocx'],
|
|
1761
|
+
pdf2docx_input_type: ['base64'],
|
|
1762
|
+
},
|
|
1763
|
+
},
|
|
1764
|
+
},
|
|
1765
|
+
{
|
|
1766
|
+
displayName: 'Binary Property Name',
|
|
1767
|
+
name: 'pdf2docx_file_binary_property',
|
|
1768
|
+
type: 'string',
|
|
1769
|
+
default: 'data',
|
|
1770
|
+
description: 'Binary property containing the source PDF file',
|
|
1771
|
+
displayOptions: {
|
|
1772
|
+
show: {
|
|
1773
|
+
operation: ['pdfToDocx'],
|
|
1774
|
+
pdf2docx_input_type: ['file'],
|
|
1775
|
+
},
|
|
1776
|
+
},
|
|
1777
|
+
},
|
|
1778
|
+
{
|
|
1779
|
+
displayName: 'Output Format',
|
|
1780
|
+
name: 'pdf2docx_output',
|
|
1781
|
+
type: 'options',
|
|
1782
|
+
options: [
|
|
1783
|
+
{ name: 'URL', value: 'url' },
|
|
1784
|
+
{ name: 'Base64', value: 'base64' },
|
|
1785
|
+
{ name: 'Both', value: 'both' },
|
|
1786
|
+
{ name: 'File', value: 'file' },
|
|
1787
|
+
],
|
|
1788
|
+
default: 'url',
|
|
1789
|
+
description: 'Format of the output DOCX',
|
|
1790
|
+
displayOptions: {
|
|
1791
|
+
show: {
|
|
1792
|
+
operation: ['pdfToDocx'],
|
|
1793
|
+
},
|
|
1794
|
+
},
|
|
1795
|
+
},
|
|
1796
|
+
{
|
|
1797
|
+
displayName: 'Output Filename',
|
|
1798
|
+
name: 'pdf2docx_output_filename',
|
|
1799
|
+
type: 'string',
|
|
1800
|
+
default: 'converted.docx',
|
|
1801
|
+
description: 'Optional output filename (used for file output)',
|
|
1802
|
+
displayOptions: {
|
|
1803
|
+
show: {
|
|
1804
|
+
operation: ['pdfToDocx'],
|
|
1805
|
+
},
|
|
1806
|
+
},
|
|
1807
|
+
},
|
|
1533
1808
|
{
|
|
1534
1809
|
displayName: 'Input Type',
|
|
1535
1810
|
name: 'pdf2img_input_type',
|
|
@@ -2374,25 +2649,58 @@ class PdfSplitMerge {
|
|
|
2374
2649
|
}
|
|
2375
2650
|
}
|
|
2376
2651
|
else if (operation === 'pdfOcrParse') {
|
|
2377
|
-
const
|
|
2652
|
+
const pdfInputType = this.getNodeParameter('ocr_pdf_input_type', i);
|
|
2653
|
+
const pdfUrl = this.getNodeParameter('ocr_pdf_url', i, '');
|
|
2378
2654
|
const pages = this.getNodeParameter('ocr_pages', i);
|
|
2379
2655
|
const lang = this.getNodeParameter('ocr_lang', i);
|
|
2380
2656
|
const dpi = this.getNodeParameter('ocr_dpi', i);
|
|
2381
2657
|
const psm = this.getNodeParameter('ocr_psm', i);
|
|
2382
2658
|
const oem = this.getNodeParameter('ocr_oem', i);
|
|
2383
|
-
const body = {
|
|
2659
|
+
const body = { pages, lang, dpi, psm, oem };
|
|
2660
|
+
if (pdfInputType === 'url') {
|
|
2661
|
+
body.url = normalizeUrl(pdfUrl);
|
|
2662
|
+
}
|
|
2663
|
+
const requestOptions = pdfInputType === 'file'
|
|
2664
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('ocr_pdf_binary_property', i), body)
|
|
2665
|
+
: { body, json: true };
|
|
2384
2666
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2385
2667
|
method: 'POST',
|
|
2386
2668
|
url: 'https://pdfapihub.com/api/v1/pdf/ocr/parse',
|
|
2387
|
-
|
|
2388
|
-
|
|
2669
|
+
...requestOptions,
|
|
2670
|
+
returnFullResponse: pdfInputType === 'file',
|
|
2389
2671
|
});
|
|
2390
|
-
|
|
2672
|
+
if (pdfInputType === 'file') {
|
|
2673
|
+
const responseBody = responseData.body;
|
|
2674
|
+
if (typeof responseBody === 'string') {
|
|
2675
|
+
try {
|
|
2676
|
+
returnData.push({ json: JSON.parse(responseBody), pairedItem: { item: i } });
|
|
2677
|
+
}
|
|
2678
|
+
catch {
|
|
2679
|
+
returnData.push({ json: { raw: responseBody }, pairedItem: { item: i } });
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
else if (Buffer.isBuffer(responseBody)) {
|
|
2683
|
+
const text = responseBody.toString('utf8');
|
|
2684
|
+
try {
|
|
2685
|
+
returnData.push({ json: JSON.parse(text), pairedItem: { item: i } });
|
|
2686
|
+
}
|
|
2687
|
+
catch {
|
|
2688
|
+
returnData.push({ json: { raw: text }, pairedItem: { item: i } });
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
else {
|
|
2692
|
+
returnData.push({ json: (responseBody !== null && responseBody !== void 0 ? responseBody : {}), pairedItem: { item: i } });
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
else {
|
|
2696
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2697
|
+
}
|
|
2391
2698
|
}
|
|
2392
2699
|
else if (operation === 'imageOcrParse') {
|
|
2393
2700
|
const imageInputType = this.getNodeParameter('ocr_image_input_type', i);
|
|
2394
2701
|
const imageUrl = this.getNodeParameter('ocr_image_url', i, '');
|
|
2395
2702
|
const base64Image = this.getNodeParameter('ocr_base64_image', i, '');
|
|
2703
|
+
const imageBinaryProperty = this.getNodeParameter('ocr_image_binary_property', i, 'data');
|
|
2396
2704
|
const lang = this.getNodeParameter('ocr_lang', i);
|
|
2397
2705
|
const psm = this.getNodeParameter('ocr_psm', i);
|
|
2398
2706
|
const oem = this.getNodeParameter('ocr_oem', i);
|
|
@@ -2401,13 +2709,41 @@ class PdfSplitMerge {
|
|
|
2401
2709
|
body.image_url = normalizeUrl(imageUrl);
|
|
2402
2710
|
if (imageInputType === 'base64' && base64Image)
|
|
2403
2711
|
body.base64_image = base64Image;
|
|
2712
|
+
const requestOptions = imageInputType === 'file'
|
|
2713
|
+
? await createSingleFileMultipart(i, imageBinaryProperty, body)
|
|
2714
|
+
: { body, json: true };
|
|
2404
2715
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2405
2716
|
method: 'POST',
|
|
2406
2717
|
url: 'https://pdfapihub.com/api/v1/image/ocr/parse',
|
|
2407
|
-
|
|
2408
|
-
|
|
2718
|
+
...requestOptions,
|
|
2719
|
+
returnFullResponse: imageInputType === 'file',
|
|
2409
2720
|
});
|
|
2410
|
-
|
|
2721
|
+
if (imageInputType === 'file') {
|
|
2722
|
+
const responseBody = responseData.body;
|
|
2723
|
+
if (typeof responseBody === 'string') {
|
|
2724
|
+
try {
|
|
2725
|
+
returnData.push({ json: JSON.parse(responseBody), pairedItem: { item: i } });
|
|
2726
|
+
}
|
|
2727
|
+
catch {
|
|
2728
|
+
returnData.push({ json: { raw: responseBody }, pairedItem: { item: i } });
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
else if (Buffer.isBuffer(responseBody)) {
|
|
2732
|
+
const text = responseBody.toString('utf8');
|
|
2733
|
+
try {
|
|
2734
|
+
returnData.push({ json: JSON.parse(text), pairedItem: { item: i } });
|
|
2735
|
+
}
|
|
2736
|
+
catch {
|
|
2737
|
+
returnData.push({ json: { raw: text }, pairedItem: { item: i } });
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
else {
|
|
2741
|
+
returnData.push({ json: (responseBody !== null && responseBody !== void 0 ? responseBody : {}), pairedItem: { item: i } });
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
else {
|
|
2745
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2746
|
+
}
|
|
2411
2747
|
}
|
|
2412
2748
|
else if (operation === 'pngToPdf' || operation === 'webpToPdf' || operation === 'jpgToPdf') {
|
|
2413
2749
|
const inputType = this.getNodeParameter('img2pdf_input_type', i);
|
|
@@ -2493,6 +2829,140 @@ class PdfSplitMerge {
|
|
|
2493
2829
|
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2494
2830
|
}
|
|
2495
2831
|
}
|
|
2832
|
+
else if (operation === 'docxToPdf') {
|
|
2833
|
+
const inputType = this.getNodeParameter('doc2pdf_input_type', i);
|
|
2834
|
+
const outputFormat = this.getNodeParameter('doc2pdf_output', i);
|
|
2835
|
+
const outputFilename = this.getNodeParameter('doc2pdf_output_filename', i);
|
|
2836
|
+
const inputFormat = this.getNodeParameter('doc2pdf_input_format', i, '');
|
|
2837
|
+
let requestOptions;
|
|
2838
|
+
if (inputType === 'file') {
|
|
2839
|
+
const fields = {
|
|
2840
|
+
output: outputFormat,
|
|
2841
|
+
output_filename: outputFilename,
|
|
2842
|
+
};
|
|
2843
|
+
if (inputFormat) {
|
|
2844
|
+
fields.input_format = inputFormat;
|
|
2845
|
+
}
|
|
2846
|
+
requestOptions = await createSingleFileMultipart(i, this.getNodeParameter('doc2pdf_file_binary_property', i), fields);
|
|
2847
|
+
}
|
|
2848
|
+
else {
|
|
2849
|
+
const body = {
|
|
2850
|
+
output: outputFormat,
|
|
2851
|
+
output_filename: outputFilename,
|
|
2852
|
+
};
|
|
2853
|
+
if (inputType === 'url') {
|
|
2854
|
+
body.url = normalizeUrl(this.getNodeParameter('doc2pdf_url', i));
|
|
2855
|
+
}
|
|
2856
|
+
else {
|
|
2857
|
+
body.file = this.getNodeParameter('doc2pdf_base64_file', i);
|
|
2858
|
+
}
|
|
2859
|
+
if (inputFormat) {
|
|
2860
|
+
body.input_format = inputFormat;
|
|
2861
|
+
}
|
|
2862
|
+
requestOptions = { body, json: true };
|
|
2863
|
+
}
|
|
2864
|
+
if (outputFormat === 'file') {
|
|
2865
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2866
|
+
method: 'POST',
|
|
2867
|
+
url: 'https://pdfapihub.com/api/v1/convert/document/pdf',
|
|
2868
|
+
...requestOptions,
|
|
2869
|
+
encoding: 'arraybuffer',
|
|
2870
|
+
returnFullResponse: true,
|
|
2871
|
+
});
|
|
2872
|
+
await prepareBinaryResponse(i, responseData, outputFilename || 'converted.pdf', 'application/pdf');
|
|
2873
|
+
}
|
|
2874
|
+
else {
|
|
2875
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2876
|
+
method: 'POST',
|
|
2877
|
+
url: 'https://pdfapihub.com/api/v1/convert/document/pdf',
|
|
2878
|
+
...requestOptions,
|
|
2879
|
+
returnFullResponse: inputType === 'file',
|
|
2880
|
+
});
|
|
2881
|
+
if (inputType === 'file') {
|
|
2882
|
+
const responseBody = responseData.body;
|
|
2883
|
+
if (typeof responseBody === 'string') {
|
|
2884
|
+
try {
|
|
2885
|
+
returnData.push({ json: JSON.parse(responseBody), pairedItem: { item: i } });
|
|
2886
|
+
}
|
|
2887
|
+
catch {
|
|
2888
|
+
returnData.push({ json: { raw: responseBody }, pairedItem: { item: i } });
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
else {
|
|
2892
|
+
returnData.push({
|
|
2893
|
+
json: (responseBody !== null && responseBody !== void 0 ? responseBody : {}),
|
|
2894
|
+
pairedItem: { item: i },
|
|
2895
|
+
});
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
else {
|
|
2899
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
else if (operation === 'pdfToDocx') {
|
|
2904
|
+
const inputType = this.getNodeParameter('pdf2docx_input_type', i);
|
|
2905
|
+
const outputFormat = this.getNodeParameter('pdf2docx_output', i);
|
|
2906
|
+
const outputFilename = this.getNodeParameter('pdf2docx_output_filename', i);
|
|
2907
|
+
let requestOptions;
|
|
2908
|
+
if (inputType === 'file') {
|
|
2909
|
+
requestOptions = await createSingleFileMultipart(i, this.getNodeParameter('pdf2docx_file_binary_property', i), {
|
|
2910
|
+
output: outputFormat,
|
|
2911
|
+
output_filename: outputFilename,
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2914
|
+
else {
|
|
2915
|
+
const body = {
|
|
2916
|
+
output: outputFormat,
|
|
2917
|
+
output_filename: outputFilename,
|
|
2918
|
+
};
|
|
2919
|
+
if (inputType === 'url') {
|
|
2920
|
+
body.url = normalizeUrl(this.getNodeParameter('pdf2docx_url', i));
|
|
2921
|
+
}
|
|
2922
|
+
else {
|
|
2923
|
+
body.file = this.getNodeParameter('pdf2docx_base64_file', i);
|
|
2924
|
+
}
|
|
2925
|
+
requestOptions = { body, json: true };
|
|
2926
|
+
}
|
|
2927
|
+
if (outputFormat === 'file') {
|
|
2928
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2929
|
+
method: 'POST',
|
|
2930
|
+
url: 'https://pdfapihub.com/api/v1/convert/pdf/docx',
|
|
2931
|
+
...requestOptions,
|
|
2932
|
+
encoding: 'arraybuffer',
|
|
2933
|
+
returnFullResponse: true,
|
|
2934
|
+
});
|
|
2935
|
+
await prepareBinaryResponse(i, responseData, outputFilename || 'converted.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
|
|
2936
|
+
}
|
|
2937
|
+
else {
|
|
2938
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2939
|
+
method: 'POST',
|
|
2940
|
+
url: 'https://pdfapihub.com/api/v1/convert/pdf/docx',
|
|
2941
|
+
...requestOptions,
|
|
2942
|
+
returnFullResponse: inputType === 'file',
|
|
2943
|
+
});
|
|
2944
|
+
if (inputType === 'file') {
|
|
2945
|
+
const responseBody = responseData.body;
|
|
2946
|
+
if (typeof responseBody === 'string') {
|
|
2947
|
+
try {
|
|
2948
|
+
returnData.push({ json: JSON.parse(responseBody), pairedItem: { item: i } });
|
|
2949
|
+
}
|
|
2950
|
+
catch {
|
|
2951
|
+
returnData.push({ json: { raw: responseBody }, pairedItem: { item: i } });
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
else {
|
|
2955
|
+
returnData.push({
|
|
2956
|
+
json: (responseBody !== null && responseBody !== void 0 ? responseBody : {}),
|
|
2957
|
+
pairedItem: { item: i },
|
|
2958
|
+
});
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
else {
|
|
2962
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2496
2966
|
else if (operation === 'pdfToPng' || operation === 'pdfToWebp' || operation === 'pdfToJpg') {
|
|
2497
2967
|
const pdf2imgInputType = this.getNodeParameter('pdf2img_input_type', i);
|
|
2498
2968
|
const pdfUrl = this.getNodeParameter('pdf2img_url', i, '');
|