cancel
Showing results for 
Search instead for 
Did you mean: 

How to merge PDF files in Microsoft Flow, Azure Logic Apps and PowerApps

This article demonstrates how to merge PDF files with the help of Microsoft Flow and Plumsail Documents connector.

 

Before starting, ensure that you added Plumsail Documents connector to Microsoft Flow.

 

In this example, we will read three DOCX files from a specific folder, convert these files to PDF, merge them and send the result PDF file by email.

 

For instance, it may be useful in a situation when a few employees prepare different sections of a contract at the same time. They load the parts of the contract to a folder, then all files from this folder are merged to form the final document.

 

We will use Merge PDF action to combine documents.

 

Our source DOCX files have to be stored somewhere. Microsoft Flow has a lot of connectors for different systems. Here are just a few of them:

  • SharePoint
  • Salesforce
  • Box
  • OneDrive
  • Google Drive
  • Dropbox
  • SFTP
  • File System

In this example, we will store our source DOCX files in SharePoint in a library that we named Source Files Library, but you can get data from other sources. You may use these links to download 3 sample DOCX files: 1, 2, 3.

 

Merging PDF files

 

Here, we will guide you step by step through creating the flow. You also will find a screenshot of the complete flow at the end of the article.

 

Flow trigger

 

You can actually pick any trigger. For example, you can start Flow on file creation in a SharePoint document library. We use Manually trigger a flow trigger here to simplify the Flow.

 

Flow trigger

 

Get files (properties only)

 

We start with getting properties of all our DOCX files stored in a specific folder - Source Files Library. In the next step, we will iterate through the output from this action to get those files contents.

 

Get files (properties only) action

 

You can use any other connector to get files from your system.

 

Initialize variable

 

We need to prepare an array of files, that we will put in Plumsail Documents - Merge PDF action when composing the final document.

 

Add a new action and search for Variables - Initialize variable action. Enter a name for the variable and choose the Array type for it.

 

Initialize variable

 

Get file content using path

 

Now, you need to add Get file content using path action to get source DOCX files contents.

 

Click File Path field and add there Folder Path and File name with an extension from a menu on the right. This will automatically transform this action into repeating one which will be performed for each file from the source folder.

 

Get file content using path

 

Convert DOCX to PDF

 

This is an action from Plumsail Documents connector.

Put here File content from the output of the previous action.

Convert DOCX to PDF

 

You can find more detailed information about Convert DOCX to PDF action here.

 

Append to an array variable

 

Now, add Variables - Append to array variable action, enter an element of the array into the Value field as shown in the screenshot below. Result file here is the output from the previous operation:

Append to array variable

 

The array of PDF files is ready, now we can move to the main step - merging PDFs into the final document.

 

Merge PDF

 

This is an action from Plumsail Documents connector.

 

Click a small array icon on the right to switch to the view where you can input an entire array. Add the Array of the PDF files you received in the loop to the Content of PDF documents field:

 

Merge PDF
 
You can find more detailed information about Merge PDF action here.

 

Send an Email

 

Once the result file is generated, we send an email using Office 365 Outlook - Send email action. In the Attachments section, we add a name and the extension for the merged PDF file and choose Result file output from the previous Merge PDF action.

 

Send an Email

 

So, here is the complete flow:

 

Complete flow

 

Conclusion

 

That is all, the flow is configured. Hope, these steps will help to ease the work with documents.

 

This article was originally published here.

Comments

 Plumsail is a no-go, it's too expensive for all but the most trivial PDF generation. 

 

It uses a credits system and charges more credits for each 0.5MB generated, quickly becoming too expensive to manage PDFs heavy on images.

Which is a very common scenario. Be it expense reports or scanned documents, it is still very common to have PDFs loaded with images.

 

Microsoft needs to have a built-in solution of its own on Microsoft Flow. 

Hi @TiagoFreire,

 

Thank you for the feedback.

 

You are right, if you have large files, your credits will be spent faster. This is a good point for those who handle large files.

 

According to our stats, 95% of files are smaller than 0.5 Mb. Thus, for most users, this is not hurting. Of course, when you processing large files, you may need to upgrade to a higher plan with more credits.

 

In addition, there is also a possibility of custom pricing. You can find contact information to request this on the pricing page (Or contact us for custom pricing).

 

Could you drop a message to support@plumsail.com and describe average file size, number of files monthly and your budget. Please mention me (Anton Khritonenkov) so that this message can be redirected to me.

You may be interested to know that we removed restriction on file size from Plumsail Documents.

Hi @anton-khrit,

 

thanks a lot for the post!

Do you know if there is any possibility to merge PDFs without using a custom connector (e.g. for Office 365 users)?

 

All the best,

 

Basti

Hi Basti,

 

Unfortunately, I'm not aware of services like this.

When I try this, The Merge PDF app doesn't allow me to put in the Files_Array variable. It doesn't show up in the dynamic content and I can't even mannually use the variable() expression to put it in. Am I missing something?

Hi @GregA,

 

The input for PDF files has two modes.

 

The first is default, when you put files one by one like this:

2019-04-18_11-42-36.png

 

You can switch to array mode by clicking the icon on the right side. Then put your variable in the action:

2019-04-18_11-28-21.png

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor