{
  "name": "DynamicPDF pdf-endpoint merge files",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -32,
        0
      ],
      "id": "e770e111-df29-40dd-9fe7-48214824f06c",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "fileSelector": "/temp/n8n-examples/resources/instructions.json",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        208,
        0
      ],
      "id": "a1e7f593-1a8d-4a4d-94d2-6cefb060e87d",
      "name": "Read/Write Files from Disk"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "item.binary.data_json = item.binary.data;\ndelete item.binary.data;\nitem.json.mergeKey = 1;\nreturn item;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        400,
        0
      ],
      "id": "bbdf8504-f18e-4025-8b4c-7b0a90b76fe7",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "fileSelector": "/temp/n8n-examples/resources/DocumentA.pdf",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        560,
        0
      ],
      "id": "80265d26-54c7-4600-b7cf-bc6e1181f10d",
      "name": "Read/Write Files from Disk1"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "item.binary.data_pdf1 = item.binary.data;\ndelete item.binary.data;\nitem.json.mergeKey = 1;\nreturn item;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        0
      ],
      "id": "abeb92ab-0b60-4ae5-81de-0a2e20170760",
      "name": "Code in JavaScript1"
    },
    {
      "parameters": {
        "fileSelector": "/temp/n8n-examples/resources/DocumentB.pdf",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        896,
        0
      ],
      "id": "f3f1d9d9-73f4-4525-bd92-ea738c883bb2",
      "name": "Read/Write Files from Disk2"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "item.binary.data_pdf2 = item.binary.data;\ndelete item.binary.data;\nitem.json.mergeKey = 1;\nreturn item;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1056,
        0
      ],
      "id": "00ee977b-982d-448c-a355-2b60001b848f",
      "name": "Code in JavaScript2"
    },
    {
      "parameters": {
        "fileSelector": "/temp/n8n-examples/resources/sample.doc",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        1264,
        0
      ],
      "id": "fe4ac09d-adac-4791-b442-c9c578a95fec",
      "name": "Read/Write Files from Disk3"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "item.binary.data_word = item.binary.data;\ndelete item.binary.data;\nitem.json.mergeKey = 1;\nreturn item;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1488,
        0
      ],
      "id": "fa831b48-3e84-454e-9022-e8e9e5586ee9",
      "name": "Code in JavaScript3"
    },
    {
      "parameters": {
        "numberInputs": 6
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        656,
        -576
      ],
      "id": "c7659036-d18c-4b8e-8f17-5867cd92dd9d",
      "name": "Merge"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.dpdf.io/v1.0/pdf",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "Instructions",
              "inputDataFieldName": "data_json"
            },
            {
              "parameterType": "formBinaryData",
              "name": "Resource",
              "inputDataFieldName": "data_pdf1"
            },
            {
              "parameterType": "formBinaryData",
              "name": "Resource",
              "inputDataFieldName": "data_pdf2"
            },
            {
              "parameterType": "formBinaryData",
              "name": "Resource",
              "inputDataFieldName": "data_word"
            },
            {
              "parameterType": "formBinaryData",
              "name": "Resource",
              "inputDataFieldName": "data_img"
            },
            {
              "parameterType": "formBinaryData",
              "name": "Resource",
              "inputDataFieldName": "data_html"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "combined_pdf"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1088,
        -512
      ],
      "id": "9bbf3157-1498-43c5-9240-ca583c43d7f5",
      "name": "HTTP Request",
      "credentials": {
        "httpHeaderAuth": {
          "id": "DJUR2FkHeM3HNv1X",
          "name": "Header Auth account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Collect all incoming items\nconst all = $input.all();\n\n// Create an output item with all binaries combined\nconst out = {\n  json: { message: \"Combined for multipart POST\" },\n  binary: {}\n};\n\n// Copy each binary from its item to a named property\nfor (const i of all) {\n  if (i.binary?.data_json) out.binary.data_json = i.binary.data_json;\n  if (i.binary?.data_pdf1) out.binary.data_pdf1 = i.binary.data_pdf1;\n  if (i.binary?.data_pdf2) out.binary.data_pdf2 = i.binary.data_pdf2;\n  if (i.binary?.data_word) out.binary.data_word = i.binary.data_word;\nif (i.binary?.data_img) out.binary.data_img = i.binary.data_img;\nif (i.binary?.data_html) out.binary.data_html = i.binary.data_html;\n}\n\nreturn [out];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        -512
      ],
      "id": "316fe69d-f6af-46cd-8e86-918e7fedf8aa",
      "name": "Code in JavaScript4"
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "/temp/n8n-examples/output/output-pdf-local.pdf",
        "dataPropertyName": "combined_pdf",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        1296,
        -512
      ],
      "id": "9684be9c-c8d3-449a-a1fa-8340e3aff0b2",
      "name": "Read/Write Files from Disk4"
    },
    {
      "parameters": {
        "fileSelector": "/temp/n8n-examples/resources/temp.png",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        1680,
        0
      ],
      "id": "847b886d-8c4f-42ee-a57c-98f225dbd3c9",
      "name": "Read/Write Files from Disk5"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "item.binary.data_img = item.binary.data;\ndelete item.binary.data;\nitem.json.mergeKey = 1;\nreturn item;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1840,
        0
      ],
      "id": "7a012974-3052-4f14-b6c4-0ba60f5a9bbc",
      "name": "Code in JavaScript5"
    },
    {
      "parameters": {
        "fileSelector": "/temp/n8n-examples/resources/test.html",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        2048,
        0
      ],
      "id": "5eb8cd7d-eb06-4150-a594-a19e5061e36c",
      "name": "Read/Write Files from Disk6"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "item.binary.data_html = item.binary.data;\ndelete item.binary.data;\nitem.json.mergeKey = 1;\nreturn item;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2240,
        0
      ],
      "id": "91d7623d-edeb-42a9-8aca-600fee6d7c87",
      "name": "Code in JavaScript6"
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read/Write Files from Disk": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read/Write Files from Disk1": {
      "main": [
        [
          {
            "node": "Code in JavaScript1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript1": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Read/Write Files from Disk2": {
      "main": [
        [
          {
            "node": "Code in JavaScript2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript2": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk3",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Read/Write Files from Disk3": {
      "main": [
        [
          {
            "node": "Code in JavaScript3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript3": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk5",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Code in JavaScript4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript4": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read/Write Files from Disk5": {
      "main": [
        [
          {
            "node": "Code in JavaScript5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript5": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk6",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 4
          }
        ]
      ]
    },
    "Read/Write Files from Disk6": {
      "main": [
        [
          {
            "node": "Code in JavaScript6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript6": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 5
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2d0df704-1c8d-44b9-abe6-aec536bdafec",
  "meta": {
    "instanceId": "cf3ce71e2d4c42097cb0560c37c3f1540cd97dea40af8f3f4791b1bb42fd7a9c"
  },
  "id": "LZff6v5FhcsHEzBQ",
  "tags": []
}