Convert SharePoint documents to PDF automatically using Microsoft Flow

convert.PNG

We’ve been waiting a lifetime (dramatic?) for this feature. And now it’s here! Sort of.

Currently, with a new “Preview” action release in Microsoft Flow, we’re able to convert documents to PDF in OneDrive for Business via workflow. While this isn’t ready for SharePoint yet, we can make it look that way for our end users. Basically:

  1. When a file is created or modified in SP
  2. Create document in OneDrive for Business
  3. Convert document
  4. Create document in SP

It’s roundabout but we get exactly the result often requested: convert SharePoint docs to PDF automatically. Here’s how to set this up. A video walkthrough is available at the bottom of this post.

My scenario: I want to “publish” meeting minutes to PDF after they’ve been approved and have them posted in a different site.

  1. In your SharePoint document library, create a sort of trigger field/column. I’ll use a checkbox named “Publish”.
    publish.PNG
  2. In Microsoft Flow, create your Flow as follows:
    1. Trigger: SharePoint – When a file is created or modified (properties only)
    2. Condition: Publish = true
      Note: You’ll need to edit this condition in advanced mode to remove the single quotes from around the word true for it to work correctly. See this post for help.
      condition
    3. If yes:
      SharePoint – get file content
    4. OneDrive for Business (ODB) – create file
      Note: add document extension (such as .docx) after filename
    5. ODB – convert file
      convert2
    6. SharePoint – create file (this can be in a different site or site collection)
      Note: add document extension (.pdf) after filename
    7. Optional:
      • SharePoint – update file properties (to copy any column data from original home to new home such as “meeting date”)
      • SharePoint – update file properties (to uncheck box on source file so that future revisions won’t incidentally publish an additional copy)

Test your flow. As you can see here, it happens so quickly (~7 seconds). Your users are sure to thank you for this time-saver.

Advertisements

Written by SharePoint Librarian

I'm a SharePoint Business Analyst and Jayhawk from the Kansas City Area.

5 comments

  1. Hey Nate – thanks so much for the video! Currently, it looks like the solution we require each user running the flow to have the same temporary “wf” folder in their personal one drive for business folder. This makes it a little hard to deploy across different users.

    Do you have any thoughts on deploying this without the folder as a requirement? Is there any way to use an o365 group to make it so that individual users don’t need the folder?

    I assume not, since the convert to PDF action requires One Drive for business. If that’s the case we may have to wait to see if the Convert Content action gets PDF support instead of just text

    1. One way to get around is to use a service account to run the flow. this way you will only create the interim folder in ODB once.

      Nate, thanks for putting this together mate.

  2. Hi,
    I’m having an issue on the Convert pdf action. I have this BadGateway error. Do you have any idea on what’s causing this error?

    Thank you.

  3. Thanks for the post. However, I’m wondering if the pdf will have the same document-ID than the original doc file? In a regulated environment it is essential not to have the same document (as pdf & doc) with different IDs?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.