Merge PDF files

Hello Transloadit community,

is it possible to merge PDF files with Transloadit?

I have the following use case:
My users shall be able to upload documents to our system. This should be possible using one of the following scenarios:

  1. Scan the document as one PDF file and upload just one PDF file to our system. This works fine with Uppy and Transloadit.
  2. Scan the document as one PDF file per page. This means all uploaded PDF files should be merged to only file. I’m not sure how to do this with Transloadit.
  3. Scan the document as one image (e.g. JPG, PNG, etc.) per page. Converting each image to a PDF file works great with Transloadit. But how to merge all pages to one PDF file?
  4. Make a photo of each page using a phone. Same as scenario 3.

The other question I have is: How can I use different templates based on file type? E.g. if it’s only PDF files, then Transloadit should just merge them. Or if it’s image files, Transloadit should convert them first and then merge them.

You support is highly appreciated.
Thanks.

Hi there!

I’m sorry to say that currently merging multiple uploads into a single PDF is not available from Transloadit - however we agree that it’s a good feature request and we’re making our developers aware of that use case.

Concerning the second half of your question, you can use the file filter robot to direct files to different steps based on certain conditions.

For example, this template will only convert images to a PDF.

{
  "steps": {
    ":original": {
      "robot": "/upload/handle"
    },
    "filter_images": {
      "use": ":original",
      "robot": "/file/filter",
      "result": true,
      "accepts": [
        [
        "${file.mime}",
        "regex",
        "image"
        ]
      ],
    "error_on_decline": false
    },
    "convert": {
      "use": {
        "steps": [
          "filter_images"
        ]
      },
      "robot": "/document/convert",
      "format": "pdf",
      "result": true
    }
  }
}