How to Parse Attachments from Incoming Email and Automatically Split Attached PDF into Separated Pages using PDF.co and Integromat

In this tutorial, you will learn how to set up Integromat and PDF.co to receive and automatically extract the PDF attachments from incoming emails and split these PDF attachments into individual PDF pages. Then you will learn how to add uploading of generated PDF files into online storage like Dropbox or Google Drive.

You will need the following modules to set up and connect:

  • Webhooks (in Mailhook mode that will intercept incoming emails)
  • Flow Control (in Iterator so it will take multiple attachments and we can process each attachment separately)
  • PDF.co PDF Split module (to process every attachment received)
  1. Set Up the Webhooks Module with a Custom Mailhook Trigger
  2. Add the Flow Control Module and its Iterator Function
  3. Add the PDF.co Module and Select “Split a PDF”
  4. Test the Configuration
  5. See the PDF Attachment File Name
  6. See the Array Generated for the Split PDF Pages
  7. Steps for Automatically Uploading Generated PDFs to Online Storage
  8. Targeted Result


Screenshot of All Connected Modules Once Completed

1. Set Up the Webhooks Module with a Custom Mailhook Trigger

Click on the Add button to Add a hook and copy the generated address to set as your email forwarding address.

2. Add the Flow Control Module and its Iterator Function

It will go through the array of attachments and will call the next module for every attachment. Please select Attachments[] in the Array field.

3. Add the PDF.co Module and Select “Split a PDF”

Kindly select the Split a PDF function so we can split the PDF attachments.

  • In the Input File field, select Upload a File. It means we are putting an input file into PDF.co instead of input Url.
  • In the Source file field, choose Flow Control – Iterator. The Flow Control – Iterator is holding a single PDF attachment extracted from email.
  • In the Pages field, enter the page numbers, for example, 1,1,1,1. It means to take the very first page and will create four different pdf files. We can set page ranges here as well, for example 1-2`.
  • In the 2nd Source file field, select Flow Control – Iterator. This instructs PDF.co to take a single attachment from the Iterator module.

4. Test the Configuration

We are now ready to test our configuration. Kindly click on the Run button to see the result.

Great! We have successfully set up our modules. In the Webhooks output, you’ll see the details of the received email.


Screenshot of the Webhooks Output

5. See the PDF Attachment File Name

In the Iterator output, you’ll find the filename of the PDF attachment that came with the email.


Screenshot of the Flow Control – Iterator Output

6. See the Array Generated for the Split PDF Pages

And in the PDF.co output, you’ll see the DataAsArray[] array generated for the PDF attachment’s split pages. This array contains pdf files generated by PDF.co PDF Splitter:


Screenshot of the PDF.co Output

7. Steps for Automatically Uploading Generated PDFs to Online Storage

a. Now if you want to automatically upload these generated PDF files to online storage like Dropbox or Google Drive, just add another
Flow Control – Array Iterator” that will go through DataAsArray[] array and will call the next module one by one for each item in the array.

b. Now add new Flow Control – Array Iterator and set DataAsArray[] from PDF.co as input:

c. Finally, connect Flow Control – Array Iterator to Dropbox (or another online storage)

8. Targeted Result

Here is the final scene you should have:

The final scenario can handle emails with multiple attachments and then can process every single attachment, split attachment into multiple PDF files and upload every single PDF file into online storage. Here is how it works, step by step:

  • “WebHooks – Custom Mailhooks” module accepts emails with attachments;
  • It generates Attachments[] array that contains one or more attachments from incoming email;
  • “Flow Control – Array Iterator” goes through this Attachments[] array and calls PDF.co module for every single attachment in it;
  • “PDF.co – Split a PDF” module splits input pdf attachment into multiple PDF files and returns DataAsArray[] array that contains generated pdf documents;
  • Another “Flow Control – Array Iterator” module goes through DataAsArray[] array and calls Dropbox module for every single PDF file from DataAsArray[]
  • Dropbox module uploads every single PDF file generated by “PDF.co – Split a PDF” module;

In this tutorial, we learned how to set up Webhooks to receive incoming emails. We configured the Iterator to get the PDF attachments from the previous step. And most of all, we learned how to use the Split function in PDF.co to split PDF pages into individual PDF documents and then how to automatically upload pdf files generated by PDF.co to online storage like Dropbox or Google Drive.