cancel
Showing results for 
Search instead for 
Did you mean: 

Merge SharePoint documents using Microsoft Flow or Azure Logic Apps

In one of my previous blog post, I created a Flow to Merge Multiple documents into Single PDF. So the question may arise in your mind as to why am I writing another blog post on Merge? 

 

This post shows how to use the Muhimbi REST API and the Microsoft Flow HTTP action which will help you Merge all documents within a SharePoint Online document library to a single PDF. If the document is not already in PDF Format it will convert the file as part of the merging process.

 

The main reason for using the above approach is better performance, as we are going to send all the Merge files – by their URL – in a single HTTP request, rather than looping through the documents one at a time. An additional benefit is that this request only takes up a single Muhimbi Operation, so is a lot more economical, and it gets around the file size limitations in Flow.

 

A prerequisite is that both the source files and destination file will need to be located in SharePoint Online. Also, Muhimbi’s SharePoint Online App must be installed in the SharePoint Online Site Collection, AND be linked to the same subscription as the Muhimbi (Flow) subscription.

 

Prerequisites:

Before you begin, please make sure the following prerequisites are in place:

From a High level our Flow will look like:

Let’s have some fun and build a Flow!

 

Step 1:

 

  • For this demo, we will use “Recurrence” Flow Trigger and configure it to run once a day. Note: For testing purposes, I have used this trigger, but in real-world situations, any other SharePoint Online trigger can be used.

 

Step 2:

 

  • Add the SharePoint Online Get files (properties only) action and select 
    the path to the SharePoint Online folder.
  • This action will retrieve the list of files to merge

Using “Get files (properties only)” you can also filter down to the items that match a condition. For e.g. You can use ODATA orderBy query for specifying the order of entries or specify the total number of entries to retrieve. For more details see.

 

Step 3:

 

  • Initialize the variables with reference to the screenshot below:

Note: I have used this convoluted approach with 3 variables as – at the time of writing – Flow does not allow ‘self-referencing’ when setting the value of a variable. Please vote for this Flow Idea

 

 

Step 4:

 

  • Add the Apply to each loop and set it to the “value” field, output of the SharePoint Online Get files (properties only) action.

 

Note: Steps 5, 6 and 7 all need to be inserted inside the ‘Apply to each’ loop.

 

Step 5:

 

  • Set variable(Server relative URL).

We will build the path to the file to merge or URL of web page to convert. (e.g. /sites/Finance/Shared Documents/Some Folder/Some file.docx). 

 

  • To keep it simple let’s hardcode the first half of the file URL. /sites/<Site-collection-name>/
  • Use the “Folder path” variable output of the SharePoint Online Get files (properties only) action.
  • “File name with extension” output of the SharePoint Online Get files (properties only) action.

The Next variables ;true:”Name” are optional. They are used to create the Bookmark.

 

For more details see below:

 

  • Include bookmarks (‘true’ in the example above): The source file may already include PDF Bookmarks, or may be able to generate such bookmarks as part of the conversion process, e.g. an MS-Word file. Specify true to copy these bookmarks to the merged PDF file, or false to strip out any bookmarks. This value is optional
  • Bookmark name: The name of the PDF bookmark to use for the specified file. This is typically used to specify the file name, as we do in this demo, but you can specify any text such as the Title field of the SharePoint file.

Step 6:

 

  • In this Step, we will create the Merge String. i.e. on each loop it will concatenate the Temporary String with Server relative URL.
  • Set variables Merge String variable with reference to the screenshot below.

 

Step 7:

 

  • Set the variable Tempory Sting to Merge String with reference to the screenshot below.

 

Step 8:

 

  • Add the HTTP action outside the apply each loop.

 

Method: POST

 

URI: https://api.muhimbi.com/api/v1/operations/merge_to_pdf (Muhimbi Merge Endpoint)

 

Headers:

  • API_key: Your Muhimbi API Key.
  • Content-Type: application/json.

Body:

{
  "fail_on_error": true,
  "use_async_pattern": true,
  "sharepoint_file": {
    "site_url": "https://tenantname.sharepoint.com/sites/site-collection-name",  
    "source_file_url": "@{variables('Merge String')}",
    "destination_file_url": "/sites/site-collection-name/Librarname/filename.pdf"
  },
  "document_start_page": "Starts on the default page"
}

To better understand the JSON Body see Muhimbi Github Merge sample code.

 

Your Merge Flow is now ready. Thanks for reading…

Comments

Do resultado deste fluxo que as Organizações desenvolvem a demanda definida de sua empresa, e possivelmente viabiliza


@CFernandes wrote:

In one of my previous blog post, I created a Flow to Merge Multiple documents into Single PDF. So the question may arise in your mind as to why am I writing another blog post on Merge? 

 

This post shows how to use the Muhimbi REST API and the Microsoft Flow HTTP action which will help you Merge all documents within a SharePoint Online document library to a single PDF. If the document is not already in PDF Format it will convert the file as part of the merging process.

 

The main reason for using the above approach is better performance, as we are going to send all the Merge files – by their URL – in a single HTTP request, rather than looping through the documents one at a time. An additional benefit is that this request only takes up a single Muhimbi Operation, so is a lot more economical, and it gets around the file size limitations in Flow.

 

A prerequisite is that both the source files and destination file will need to be located in SharePoint Online. Also, Muhimbi’s SharePoint Online App must be installed in the SharePoint Online Site Collection, AND be linked to the same subscription as the Muhimbi (Flow) subscription.

 

Prerequisites:

Before you begin, please make sure the following prerequisites are in place:

From a High level our Flow will look like:

Let’s have some fun and build a Flow!

 

Step 1:

 

  • For this demo, we will use “Recurrence” Flow Trigger and configure it to run once a day. Note: For testing purposes, I have used this trigger, but in real-world situations, any other SharePoint Online trigger can be used.

 

Step 2:

 

  • Add the SharePoint Online Get files (properties only) action and select 
    the path to the SharePoint Online folder.
  • This action will retrieve the list of files to merge

Using “Get files (properties only)” you can also filter down to the items that match a condition. For e.g. You can use ODATA orderBy query for specifying the order of entries or specify the total number of entries to retrieve. For more details see.

 

Step 3:

 

  • Initialize the variables with reference to the screenshot below:

Note: I have used this convoluted approach with 3 variables as – at the time of writing – Flow does not allow ‘self-referencing’ when setting the value of a variable. Please vote for this Flow Idea

 

 

Step 4:

 

  • Add the Apply to each loop and set it to the “value” field, output of the SharePoint Online Get files (properties only) action.

 

Note: Steps 5, 6 and 7 all need to be inserted inside the ‘Apply to each’ loop.

 

Step 5:

 

  • Set variable(Server relative URL).

We will build the path to the file to merge or URL of web page to convert. (e.g. /sites/Finance/Shared Documents/Some Folder/Some file.docx). 

 

  • To keep it simple let’s hardcode the first half of the file URL. /sites/<Site-collection-name>/
  • Use the “Folder path” variable output of the SharePoint Online Get files (properties only) action.
  • “File name with extension” output of the SharePoint Online Get files (properties only) action.

The Next variables ;true:”Name” are optional. They are used to create the Bookmark.

 

For more details see below:

 

  • Include bookmarks (‘true’ in the example above): The source file may already include PDF Bookmarks, or may be able to generate such bookmarks as part of the conversion process, e.g. an MS-Word file. Specify true to copy these bookmarks to the merged PDF file, or false to strip out any bookmarks. This value is optional
  • Bookmark name: The name of the PDF bookmark to use for the specified file. This is typically used to specify the file name, as we do in this demo, but you can specify any text such as the Title field of the SharePoint file.

Step 6:

 

  • In this Step, we will create the Merge String. i.e. on each loop it will concatenate the Temporary String with Server relative URL.
  • Set variables Merge String variable with reference to the screenshot below.

 

Step 7:

 

  • Set the variable Tempory Sting to Merge String with reference to the screenshot below.

 

Step 8:

 

  • Add the HTTP action outside the apply each loop.

 

Method: POST

 

URI: https://api.muhimbi.com/api/v1/operations/merge_to_pdf (Muhimbi Merge Endpoint)

 

Headers:

  • API_key: Your Muhimbi API Key.
  • Content-Type: application/json.

Body:

{
  "fail_on_error": true,
  "use_async_pattern": true,
  "sharepoint_file": {
    "site_url": "https://tenantname.sharepoint.com/sites/site-collection-name",  
    "source_file_url": "@{variables('Merge String')}",
    "destination_file_url": "/sites/site-collection-name/Librarname/filename.pdf"
  },
  "document_start_page": "Starts on the default page"
}

To better understand the JSON Body see Muhimbi Github Merge sample code.

 

Your Merge Flow is now ready. Thanks for reading…



@CFernandes wrote:

In one of my previous blog post, I created a Flow to Merge Multiple documents into Single PDF. So the question may arise in your mind as to why am I writing another blog post on Merge? 

 

This post shows how to use the Muhimbi REST API and the Microsoft Flow HTTP action which will help you Merge all documents within a SharePoint Online document library to a single PDF. If the document is not already in PDF Format it will convert the file as part of the merging process.

 

The main reason for using the above approach is better performance, as we are going to send all the Merge files – by their URL – in a single HTTP request, rather than looping through the documents one at a time. An additional benefit is that this request only takes up a single Muhimbi Operation, so is a lot more economical, and it gets around the file size limitations in Flow.

 

A prerequisite is that both the source files and destination file will need to be located in SharePoint Online. Also, Muhimbi’s SharePoint Online App must be installed in the SharePoint Online Site Collection, AND be linked to the same subscription as the Muhimbi (Flow) subscription.

 

Prerequisites:

Before you begin, please make sure the following prerequisites are in place:

From a High level our Flow will look like:

Let’s have some fun and build a Flow!

 

Step 1:

 

  • For this demo, we will use “Recurrence” Flow Trigger and configure it to run once a day. Note: For testing purposes, I have used this trigger, but in real-world situations, any other SharePoint Online trigger can be used.

 

Step 2:

 

  • Add the SharePoint Online Get files (properties only) action and select 
    the path to the SharePoint Online folder.
  • This action will retrieve the list of files to merge

Using “Get files (properties only)” you can also filter down to the items that match a condition. For e.g. You can use ODATA orderBy query for specifying the order of entries or specify the total number of entries to retrieve. For more details see.

 

Step 3:

 

  • Initialize the variables with reference to the screenshot below:

Note: I have used this convoluted approach with 3 variables as – at the time of writing – Flow does not allow ‘self-referencing’ when setting the value of a variable. Please vote for this Flow Idea

 

 

Step 4:

 

  • Add the Apply to each loop and set it to the “value” field, output of the SharePoint Online Get files (properties only) action.

 

Note: Steps 5, 6 and 7 all need to be inserted inside the ‘Apply to each’ loop.

 

Step 5:

 

  • Set variable(Server relative URL).

We will build the path to the file to merge or URL of web page to convert. (e.g. /sites/Finance/Shared Documents/Some Folder/Some file.docx). 

 

  • To keep it simple let’s hardcode the first half of the file URL. /sites/<Site-collection-name>/
  • Use the “Folder path” variable output of the SharePoint Online Get files (properties only) action.
  • “File name with extension” output of the SharePoint Online Get files (properties only) action.

The Next variables ;true:”Name” are optional. They are used to create the Bookmark.

 

For more details see below:

 

  • Include bookmarks (‘true’ in the example above): The source file may already include PDF Bookmarks, or may be able to generate such bookmarks as part of the conversion process, e.g. an MS-Word file. Specify true to copy these bookmarks to the merged PDF file, or false to strip out any bookmarks. This value is optional
  • Bookmark name: The name of the PDF bookmark to use for the specified file. This is typically used to specify the file name, as we do in this demo, but you can specify any text such as the Title field of the SharePoint file.

Step 6:

 

  • In this Step, we will create the Merge String. i.e. on each loop it will concatenate the Temporary String with Server relative URL.
  • Set variables Merge String variable with reference to the screenshot below.

 

Step 7:

 

  • Set the variable Tempory Sting to Merge String with reference to the screenshot below.

 

Step 8:

 

  • Add the HTTP action outside the apply each loop.

 

Method: POST

 

URI: https://api.muhimbi.com/api/v1/operations/merge_to_pdf (Muhimbi Merge Endpoint)

 

Headers:

  • API_key: Your Muhimbi API Key.
  • Content-Type: application/json.

Body:

{
  "fail_on_error": true,
  "use_async_pattern": true,
  "sharepoint_file": {
    "site_url": "https://tenantname.sharepoint.com/sites/site-collection-name",  
    "source_file_url": "@{variables('Merge String')}",
    "destination_file_url": "/sites/site-collection-name/Librarname/filename.pdf"
  },
  "document_start_page": "Starts on the default page"
}

To better understand the JSON Body see Muhimbi Github Merge sample code.

 

Your Merge Flow is now ready. Thanks for reading…




na sua Infraestrutura o teor do comércio que atende o padrão de mercado do investimento na dicotomia do empreendimento tributário no Brasil.

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