SOLVED

Sharepoint document conversion

Copper Contributor

So, our client wants to use Sharepoint to organize and store their files in a centralized location. This wouldn't be incredibly difficult but they also want every file to be converted to a .pdf. This means any .doc, .docx, .txt. and even .xlsx files.

We were looking at a tool inside of Sharepoint called PowerAutomate and I was wondering if anyone found success using that app to convert files -- or if anyone has a better suggestion on how to accomplish this.

Thanks so much in advance!

2 Replies
best response confirmed by grivonberg (Copper Contributor)
Solution

@grivonberg Power Automate is one of the Office 365 apps and usually I build flows direct in the web interface at make.powerautomate.com rather than do so from within SharePoint, but the choice is yours and the method is the same. It's not difficult to build a flow to convert a document to PDF and I've shown a flow below that I used for a lunch & learn at my company specifically for this. I used the classic designer but you also build it in the new designer.

 

In this example the flow is triggered from a JSON-formatted button in the document library but you need to build the flow first before doing the button formatting: We're going to convert the Word document Consultation-Site Storage.docx to a PDF and the flow will add it to the PDF folder in the library.

 

0-SP.png

 

1. In your flow the trigger will be the SharePoint for a selected file trigger

 

1-Flow.png

 

2. Next add the SharePoint get file properties action and for the Id field select ID from the dynamic content box:

 

2-Flow.png

 

3. Next add a SharePoint get file content action and for the File Identifier field select Identifier from the dynamic content box.

 

 

3-Flow.png

 

4. Next add a OneDrive create file action. Select where in your OneDrive you want to store the document, I've just put it in the root / and it does this as a half way house between the original file and the PDF. Select file name with extension and file content from the dynamic content box.

 

4-Flow.png

 

5. Next, add the OneDrive convert file using path action. Don't worry that it says Preview, it's said that since 2018!. For the File Path select Path and make sure the target type is set to PDF.

 

5-Flow.png

 

6. Add a SharePoint create file action, select the site and folder path where the PDF will be saved to. For the file name field select Name from the dynamic content box and type .pdf after it. Select file content from the convert file using path section of the dynamic content box.

6-Flow.png

 

Finally give your flow a name and save it. and then copy the ID of the flow as you'll need this for the button:

 

6a-Flow.png

 

 

 

Back in your SharePoint library create a single line of text column and format it in advanced mode with the following JSON adjusting text and colors etc to your preferences, and paste in the ID of your flow:

{
"elmType": "button",
"txtContent": "Convert to PDF",
"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\":\"8125634b-6718-4718-84e4-f9a29567276d\", \"headerText\":\" ' + [$Title] + '\",\"runFlowButtonText\":\"Convert\"}'"
},
"style": {
"background-color": "#fff5dd",
"border-radius": "10px"
}
}

 

7a-Flow.png

 

When you click the button the run flow panel will open on the far right of the screen and the flow will run when you click the Convert button at the bottom.

 

7-RunFlow.png

 

This is the result:

 

8-PDF.png

 

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)

 

 

 

@Rob_Elliott Thank you so much! This is incredibly helpful :) 

1 best response

Accepted Solutions
best response confirmed by grivonberg (Copper Contributor)
Solution

@grivonberg Power Automate is one of the Office 365 apps and usually I build flows direct in the web interface at make.powerautomate.com rather than do so from within SharePoint, but the choice is yours and the method is the same. It's not difficult to build a flow to convert a document to PDF and I've shown a flow below that I used for a lunch & learn at my company specifically for this. I used the classic designer but you also build it in the new designer.

 

In this example the flow is triggered from a JSON-formatted button in the document library but you need to build the flow first before doing the button formatting: We're going to convert the Word document Consultation-Site Storage.docx to a PDF and the flow will add it to the PDF folder in the library.

 

0-SP.png

 

1. In your flow the trigger will be the SharePoint for a selected file trigger

 

1-Flow.png

 

2. Next add the SharePoint get file properties action and for the Id field select ID from the dynamic content box:

 

2-Flow.png

 

3. Next add a SharePoint get file content action and for the File Identifier field select Identifier from the dynamic content box.

 

 

3-Flow.png

 

4. Next add a OneDrive create file action. Select where in your OneDrive you want to store the document, I've just put it in the root / and it does this as a half way house between the original file and the PDF. Select file name with extension and file content from the dynamic content box.

 

4-Flow.png

 

5. Next, add the OneDrive convert file using path action. Don't worry that it says Preview, it's said that since 2018!. For the File Path select Path and make sure the target type is set to PDF.

 

5-Flow.png

 

6. Add a SharePoint create file action, select the site and folder path where the PDF will be saved to. For the file name field select Name from the dynamic content box and type .pdf after it. Select file content from the convert file using path section of the dynamic content box.

6-Flow.png

 

Finally give your flow a name and save it. and then copy the ID of the flow as you'll need this for the button:

 

6a-Flow.png

 

 

 

Back in your SharePoint library create a single line of text column and format it in advanced mode with the following JSON adjusting text and colors etc to your preferences, and paste in the ID of your flow:

{
"elmType": "button",
"txtContent": "Convert to PDF",
"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\":\"8125634b-6718-4718-84e4-f9a29567276d\", \"headerText\":\" ' + [$Title] + '\",\"runFlowButtonText\":\"Convert\"}'"
},
"style": {
"background-color": "#fff5dd",
"border-radius": "10px"
}
}

 

7a-Flow.png

 

When you click the button the run flow panel will open on the far right of the screen and the flow will run when you click the Convert button at the bottom.

 

7-RunFlow.png

 

This is the result:

 

8-PDF.png

 

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)

 

 

 

View solution in original post