Power Apps & Power Automate Convert to PDF

Previously, I wrote a post called Microsoft Flow & Quick Parts, which shows how you can insert fields from SharePoint into your document via Flow and Quick Parts.  Many times in business processes, this document needs to be output as a PDF file, in order to be archived or sent out to a customer.

Currently in Flow, the only free way to convert a file to a PDF, is using a OneDrive for Business action, so the file can’t just be in a SharePoint library, it has to be in OneDrive in order to convert it, then it can be put back in SharePoint.  Here are the steps and associated video.  You’ll notice in these screenshots, some small white text at the bottom.  That’s what you see in Flow when you hover your mouse over the dynamic content, so that you can double check that it’s correct.

1.  You need to have an example (template) file to start with.  If you followed the steps in the post about Flow and Quick Parts, use a blank file that has all of the quick parts already inserted. This file can be anywhere, it can be in a library by itself if you’d like.
(If you’re coming from the SharePoint world where we’ve always done this with a custom content type, that method doesn’t currently work with Flow & modern SharePoint)

2.  I’m not going to start with a Flow trigger here, there are many different ways you can start your Flow, such as when an item is first created, modified, or when someone manually triggers it. So… you already have a trigger, I’m going to start with the first action.  I’ll just say, for example, that I have a SharePoint list of customers, and I’m going to select a customer and use the “for a selected item” trigger.  Then I’ll have metadata about that customer that I can insert into the document, in the quick parts.

3.  Add a SharePoint action Get file content.  This is where you select the specific example file (template) from step 1.

4.  Add a SharePoint action Create file.  This address and folder path is where you have a library that has a bunch of columns with information about the customer.  For the filename, I just gave it the ID of the customer, but you could add multiple fields and even a date here, if you want to make it more unique.  The important part is for the File Content, pick the file content (dynamic content) from the previous action.


5.  Add a SharePoint action Update file properties.  This is the same library as in the previous action, and use the ItemId of the previous action (create file).  I show an example here, of populating the customer name from the customer that I mentioned at step 2.  I’m only showing one field, but you may have a bunch of them, this is where you fill them all in, so that the metadata of this new file in the library will have all of the pertinent metadata about this customer.

Theoretically, this is just a temporary file and ultimately needs to be a PDF anyway, so I’m not bothering with a bunch of dynamic lookup information from the SOW library to the customer list, since that makes quick parts much more complicated.


6.  Add another SharePoint action Get file content.  Rename it to Get file content new file.  Use the ID of the file that you created in the create file action.  You may notice that this is the second time we’re getting the content, this is because it’s a new file.


7.  Add a OneDrive for Business action Create file.  Rename it to Create file in OneDrive.  For the path, it’s up to you.  I just chose the root of my OneDrive.  For the file name, I’m just using the Name from the create file action.  The file content is important.  This is where you use the file content from the previous action.


8.  Add a OneDrive for Business action Convert file.  Rename it to Convert file to PDF.  For the ID, select the one from the previous action.


9.  Okay now you have a PDF file, so where do you want to put it?  Here’s how you can put it in SharePoint.  Add the SharePoint action Create file.  Rename it to Create PDF in library.  Use the file name and content from the previous action.


Here’s an example of what it could look like if you wanted this Flow to also send that attachment in an email, maybe send it to your customer?


10.  Then lastly, you will probably want to delete that temporary PDF over in OneDrive.  Add the OneDrive action to delete a file.


Now try it out!

Next, you may be wondering about the title of this article, and wonder where PowerApps comes in.  PowerApps can be used as a trigger (the very first step) if you’d like to click a button from within an app, to generate a PDF.  So, your trigger would be different, you’d use the PowerApps trigger, send the ID of the customer over to the Flow (in my example, since it’s a list of customers).  Then the Flow needs the get item action (renamed to “get customer”) to go get the additional metadata about that particular customer.


Here’s an hour long video, where I go over all of this:


If you’d like to see a full presentation that I did for Collab 365 virtual summit all about how to do the PowerApps triggering a Flow part, go here, and my session is called Using Microsoft Flow with PowerApps.  And of course, I teach my own 8 hour advanced Flow course.


  • Hi Laura,

    I thought I had this working perfectly until I logged in as another user (the Flow uses a connector under a generic service account) – the Flow fails every time on the “Create File in OneDrive” action (Error below)

    InvalidTemplate. Unable to process template language expressions in action ‘Create_file_-_OneDrive’ inputs at line ‘1’ and column ‘2068’: ‘The template language expression ‘json(decodeBase64(triggerOutputs().headers[‘X-MS-APIM-Tokens’]))[‘$connections’][‘shared_onedriveforbusiness’][‘connectionId’]’ cannot be evaluated because property ‘shared_onedriveforbusiness’ doesn’t exist, available properties are ‘shared_sharepointonline, shared_office365’. Please see https://aka.ms/logicexpressions for usage details.’.

    When I log back in with the account creating it, it works every time. I am logged into OneDrive in the account (mine) when testing it.

    I am sure this is something simple, but I cannot find it.


    Warren Belz
    Ventia Utility Services

    • My best guess would be that your service account O365 license doesn’t have OneDrive enabled.

  • Laura,

    I keep getting an error status 400, Message “The file id ’22” is not valid” on the convert file to PDF step. Can you help me figure out why this is happening? I can see a file 22 in my One Drive. I can’t open it and it says 0KB of data. I’m trying to convert my list metadata to a PDF file. I’m new to using Sharepoint so it’s possible I’m doing something very wrong.

    • Have you made sure to include the file extension as part of the filename in Power Automate?

  • Is there a limit on the number of columns you can use? The “Update file properties” step in flow doesn’t seem to display any columns beyond about 50

    Is there any way to include values from calculated columns? They don’t appear in the list of document properties in Quick Parts in Word.

    I was hoping I could work around limit of columns by only updating the raw data columns from my list to my library and leave the library to calculate the additional columns. That works but it seems I can’t then add them in to the document

    The rest of your explanation is great Laura, so simple to follow and all works – maybe I am just pushing too far

  • Hello,
    thanks for the good description, I still have a problem. I create the Word documents with a set of columns in the SharePoint library, but I don’t manage to transfer these columns to the PDF document,
    When I use Update File properties a loop is created and at the end of the flow all documents have the same metadata.
    Do you have any idea what I am doing wrong here?

    • Yes, that usually happens if you’re trying to insert some field that has multiple values. You’d need to append all of those multiple values into a string variable, and then insert the variable into your doc.

Leave a Reply