Using Power Automate (Flow) to Convert SharePoint Online Wiki Pages to PDF

At work, we’re regularly asked by customers of The Muhimbi PDF Converter Services Online, if our PDF Converter can be used to convert SharePoint Online wiki pages to PDF in conjunction with Microsoft Flow, Logic Apps, and PowerApps?  The short answer is yes, and the post below details how you can do it

For those not familiar with the product, The Muhimbi PDF Converter Online is one of a line of subscription services that converts, merges, watermarks, secures, and OCRs files from Microsoft Flow, Logic Apps, and PowerApps- not to mention your own code using C#, Java, Python, JavaScript, PHP, Ruby and most other modern platforms.

Before we get into the How-TO, let’s review what SharePoint Online wiki Pages are in the first place.

A SharePoint Online wiki is a SharePoint site that is designed for groups of people to quickly access and share ideas by creating simple pages and linking them together. Your organization may use a wiki for a variety of reasons. On a large scale, you can share large volumes of information in an Enterprise wiki that acts as a central database, while also being easy to use for non-technical staff. On a smaller scale, you can use a team site as a wiki to gather and share ideas quickly about a single project.

In his post we’ll show you how to create a Power Automate (Flow) solution to convert a SharePoint Online wiki page to PDF whenever a new wiki page is created or an existing wiki page is modified.

 

Prerequisites

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

 

Now, on to the details of how to create a Power Automate (Flow) solution to convert SharePoint Online wiki pages to PDF whenever a new wiki page is created or an existing wiki Page is modified.

First let’s review how the basic structure of our Power Automate (Flow) looks :

Pic2

 

Step 1 – Trigger

  • We use the SharePoint trigger ‘When a file is created or modified in a folder’.
  • Whenever a new wiki page is created, or an existing wiki page is modified, the Power Automate (Flow) will get triggered automatically.
  • For the ‘Site Address’ in the image below, choose the correct site address from the drop down menu.
  • For the ‘Folder Id’ in the image below, select the source folder.

Trigger

 

Step 2 – Convert HTML to PDF

  • The <FileName> highlighted in the URL above is simply the FileName that we obtained from the dynamic content of the trigger action ‘When a file is created or modified’.
  • In the ‘Page Orientation’ field, select the appropriate option. Depending on the content and layout of the page ‘Landscape’ may work out better.
  • In the ‘Media Type’ field, select the ‘Print’ option from the drop down menu. (This automatically strips out most of the SharePoint User interface).
  • Select ‘SharePoint Online’ as the ‘Authentication type’ from the drop down menu.
  • That being said, you will need to enter the correct ‘User name’ and ‘Password’ to get authenticated with the SharePoint Online authentication that you selected in the authentication field above.
  • In the ‘Conversion Delay’ field, enter a delay of 10000 (in milliseconds, so 10 seconds).  This delay will give the page time to load before it is converted.

pic3

 

Step 3 – Create File

  • For the ‘Site Address’ in the image below, choose the correct site address from the drop down menu.
  • Select the correct ‘Folder Path’ where the converted PDF should be created.
  • Give a meaningful ‘File Name’ to the created PDF, but make sure you remember to add the extension ‘.pdf’ after the ‘File Name’ and to make the file name unique, or multiple runs of the flow will overwrite the same file.  I recommend basing it on the source file name, but with some kind of suffix.
  • Select the ‘Processed file content’ option, shown in the image below, to populate the ‘File Content’ field.

imp

 

That is it, create or update a wiki page, wait a few seconds, and then open the generated PDF.

To see the fruits of our labor, please see below what the Wiki page looks like when viewed in a browser and how it looks as a PDF.

 

Source Wiki Page –

Capture2

 

Converted PDF –

Capture

 

Note – You will notice that the PDF includes some navigation elements. Ideally SharePoint would suppress this information in ‘Print’ mode, but it it doesn’t. We have no control over this unless you want to take the extra step of adding the following CSS to each wiki page:

<style>.ms-core-navigation { DISPLAY: none }#contentBox { margin-left: 0px }</style>

 

Keep checking this blog for exciting new articles about Power Automate, SharePoint Online, Power Apps, as well as document conversion and manipulation using The Muhimbi PDF Converter.

3 thoughts on “Using Power Automate (Flow) to Convert SharePoint Online Wiki Pages to PDF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s