In this example, we will create a Flow which can be manually started on a document in a SharePoint Online document Library or List.
Please make sure the following prerequisites are in place:
- An Office 365 subscription with, SharePoint Online license.
- Muhimbi PDF Converter Services Online full, free or trial subscription(Sign up).
- Appropriate privileges to create Flow.
- Working knowledge of Microsoft Flow.
From a high level, the Flow works as follows:
Our Flow will get the file content from a SharePoint document library, Convert it to PDF, Add a Text Watermark to the PDF and write the generated PDF back to the SharePoint document library.
Step 1: For this demo, we will use “For a selected item” SharePoint Trigger action. We use this trigger to start the Flow from SharePoint Online User Interface.
Step 2: Add the “Get file properties” action to retrieve the path and file name of the document the Flow was started on. This is then used to retrieve the file’s content in the next step. Please specify the SharePoint site URL, path to the document Library and the “ID” (output of the “For a selected item“ trigger)
Step 3: Add the “Get file content using Path” action to retrieve the file content of the document the Flow was started on. This will then be used in the next step. Please specify the SharePoint site URL, path to the document Library using the “Folder Path” and the “File name with Extension” (output of the “Get file properties” action).
Step 4: In the next Step, we will configure the “Convert document” action from Muhimbi Flow connector.
In the ‘Source file name’ field enter the ‘File name with Extension’ value returned by the ‘get file properties’ action. In the ‘Source file content’ field, enter the ‘File Content’ value returned by that same action. For details see the screenshot below.
Step 5: In this Step, we will Watermark the PDF using the “Add text Watermark Muhimbi” action. Configure the action with reference to screenshot and details below.
- “Source file content“: Use the “Processed File Content” the output of the Muhimbi “Convert to PDF” action.
- “Watermark Content“: Add text Confidential (Watermark Text).
- “Font family“: Arial (Name of font e.g. Arial, Time Roman, Calibri etc.)
- “Font color”: #000000 ( Color in RRGGBB notation).
- “Text alignment“: Middle Center.
- “Word Wrap“: Word.
- “Position“: Middle Center.
- “Width“: 200.
- “Height“: 200.
Step 6: In the step, we will write the PDF file back to SharePoint Online document library using the “Create file” action from SharePoint connector. For the “File Name” use the “Base file name“.pdf and the “File Content” as “Processed file content” output of the “Add Text to watermark” Muhimbi action.
Save the Flow.
Step 7: Configure RUN-ONLY User.
In this blog post we show how to use the ‘For a selected item’ trigger to manually start a Flow on a document. This works similarly to Flows that are automatically triggered when a file is created or changed, with one major exception, which is that by default the person starting this Flow will need to authenticate to all services used by it. Although sometimes this is desirable, in general it is not particularly user friendly, especially for non-technical users.
To keep things easy for the end-users, we use Flow’s ‘run-only users’ facility to preconfigure the account used to authenticate with Muhimbi’s conversion service. Configure this setting using the ‘manage run-only users’ card, just below the ‘Owners’ card, see the screenshot below.
Step 8: To test the Flow navigate back to the original library and select an item. Click on the Flow dropdown and click on the name of the Flow you created. Click on Run Flow.
Want to Start the above Flow with a single click? For details see the article “Trigger a Flow to Covert a document to PDF in SharePoint using Button.
Happy converting 🙂.