Generate a PDF from Microsoft Flow

Generate a PDF from Microsoft Flow

Recently I have been asked by a few clients how to create PDF files from SharePoint Online List Items. At first, I was perplexed by this request, it is not something I ever need to do. After a few probing questions, I found that they were using SharePoint in very cool ways and one, in particular, was tracking trouble tickets and then generating an “after action report” for distribution to their customer as a PDF via email.

The Challenge

The challenge is that they did not want to use any of the Premium connectors that can perform document conversion to Word or PDF. After Binging around a bit I ran into Paul Culmsee’s very cool article titled Some seriously powerful (and free) PDF functionality in PowerApps and Flow. This post got me to thinking about alternatives to my initial approach of using a Word document as a template. Instead I found it significantly easier to use HTML as the template.

In the video I demonstrate the approach I took to create the PDF. I stripped away all of the extraneous information and stuck to only creating the PDF. Once you have the file, there are tons of options available to you. Here is the rough outline of the steps, the details are in the video.

The Trouble Ticket List

You need a SharePoint Online List. One other gotcha that I ran into is that Microsoft Flow (and PowerApps) do not fully support all SharePoint column types. In my case the Append Only Multi-line column was a problem. So I converted it to a plain text multi-line column.

The Document Template

My document template is just an HTML file. The structure I chose contains {token} fields that I use in Flow Compose actions to perform text replacements. It is a format that I created.

<!DOCTYPE html>
<html>
  <head>
    <meta name="generator" content="Microsoft Flow">
    <title>Service Record | {title}</title>
  </head>
  <body>
    Service Assignment Summary<br/>
    <b>Title:</b> {title}<br/>
    <b>Date:</b> {createdate}<br/>
    <b>Assigned To:</b> {assignedto}<br/>
    <b>Details:</b>
    <p>{servicedetails}</p>
  </body>
</html>

The PowerApp

To keep this post focused on the process of creating the PDF I chose not to create a Power App. In future posts I will add one.

The Flow

The Microsoft Flow performs a lot of string manipulation to merge the template and the list item data. The actual conversion is performed by a Convert to File action from OneDrive. The rest is in the video.

The entire flow

The Video

|| Power Apps || Microsoft Flow || Automation || SharePoint || Office 365

comments powered by Disqus

Let's Get In Touch!


Ready to start your next project with us? That’s great! Give us a call or send us an email and we will get back to you as soon as possible!

+1.512.539.0322