cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NuttyPistons
Frequent Visitor

Merging Varying Numbers of PDFs from Sharepoint Folder

Hello,

I have a setup where there is a sharepoint folder in which several PDFs get saved throughout the day. At the end of the day, the PDFs are moved from this folder to an archive folder so that the folder is empty again for the next day.

I would like to create a scheduled flow that merges all of the PDFs from the folder into one file before they are moved. I understand how to use Adobe PDF Tools' "Merge PDFs" action when entering in each specific file, like in the first screenshot below. The issue I face is that there won't be the same number of PDFs to merge each day. Some days will be four-or-five and others could be upwards of twenty. 

 

I am looking for a way to instead use actions:

  • List Files in the Sharepoint Folder
  • Initialize Variable (array)
  • Apply to Each - Add each file content to variable in correct format
  • Input entire array variable in the Merge PDFs file content like in second screenshot.

I'm not even sure if this is possible, but would love any advice for this that's out there.

NuttyPistons_0-1613772226224.png

 

NuttyPistons_1-1613772263347.png

 



Thanks in advance.
Matt 

2 REPLIES 2
Gopala_Krishna
Super User
Super User

@NuttyPistons 

You can create an array variable after the trigger and use this to store the file content, once you have the variable initialized you can add the append to array variable action after the "Get file content" step.

 

Format the array in the append to array variable step as below

Gopala_Krishna_1-1613790556881.png

 

pass this variable into the Merge PDF step and it will resolve the issue.

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

if the information shared helps you, please consider giving a thumbs up 👍 and mark solution as resolved

This seems to be very close but I can't quite get it to work. 

Here is my flow, and the error it produces:

NuttyPistons_0-1614015937571.png

NuttyPistons_1-1614015947591.png

 

*Note I removed the quotes around 'File Content' as it seemed to like that more, based on viewing the inputs after the flow has run.

Here is the error that the flow produces: 

NuttyPistons_3-1614016437859.png

 

 

The SP folder has only two files in it, so I re-created this flow using the individual file content option on the PDF Merge step in order to compare the raw inputs:

NuttyPistons_2-1614016252261.png

This flow of course works fine. I've copied and pasted the raw inputs for the Merge PDFs step from each flow and noticed this difference:

Individual PDF Merge (raw input):

NuttyPistons_4-1614016534736.png

 

PDF Merge all as Array (raw input):

NuttyPistons_5-1614016606226.png

 

I've spot checked a ton of the code from these two inputs and everything appears to be identical with the exception of that highlighted part with the field name. I've also removed the "Name" field from the JSON in 'Append to Array Variable' step but end up with the same issue. It seems to be that it doesn't want the "Content:" field name before the actual content, but removing the field name prevents it from being in JSON format. 

Any idea what I might be doing wrong or any tweaks that can get me over the finish line?

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (106,009)