Flow Action - Convert Word Document to PDF

Brass Contributor

I'm trying to use the Convert Word Document to PDF action in a Flow. There are three parameters that have to be entered:

  • Location - the SharePoint Site
  • Document Library - Library where the document is located.
  • File - The document to convert

The parameter that I'm having an issue with is the File. The flow works if I choose the specific document from the library but I want it to be dynamic so that when the user starts a Flow on the document it will convert that one, so I don't want to hardcode the document name.

 

For the File property I'm using the property from a previous step with the file name called File name with extension.

 

When I run the flow I get an error, "There was an error accessing the file. Please try again or select a different file."

 

Can I not use dynamic content for the File property?

 

Thanks 

32 Replies

@Ben Girard 

 

Thanks for sharing, I am stuck on this exact issue too and am unable to convert a Word Doc to PDF within Sharepoint. Has there been any developments in the mean time? 

If not, is it possible you paste the flow you've developed as a workaround which you have discussed? would be good to mimick it myself in the interim till an MS solution is developed.

 

 

@Roghan  This can be used to get a pdf version of a document: https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/js-command-convert-to-pdf.

 

This can be used to generate Word Docuements or PDFs from data stored in your sharepoint lists using a word template:  https://github.com/russgove/sp-dev-fx-extensions/tree/dev/samples/react-command-generate-documents

 

 

 

 

@Russell Gove thanks for sharing, I am keen to try point 1: "This can be used to get a pdf version of a document" but am unable to deduce from the link you shared how to go about this? Any easy to follow guide you have seen around?

After some substantial trial and error I believe this usually happens when a file has been created, but isn't "ready yet".  Its as if its returning the file properties that can work with Sharepoint's REST API, without actually determining if the information can be discovered by Microsoft's graph API (which I am now convinced is what that action is using).

 

A workaround I have found is to wrap the action in a while loop with a success and failure branch.  On failure, wait 10 seconds and then restart the loop.  It isn't perfect of course,  but 99% of the time it fails once or twice, then goes through

Hi Roghan, You would need to build the app and deploy it to sharepoint. This would require knowledge of the sharepoint development model.
Want to change PDF format files to Word

@ThreeTen22 sounds like a good workaround to me, thanks for sharing.

 

Can you please describe how to use the success/failure branch? I don't know how to do this.

 

Thanks a lot!

@Rich Koneval 

I found a solution in my case.

 

The 'FullPath' for my word document started with "Shared Documents", given I was using a SharePoint file. This was being merged with the 'Library Name' input, which was creating the wrong location.

 

My solution was to remove the text "Shared Documents" from the 'FullPath' dynamic content. I used a replace function as follows;

 

=replace(text, oldText, newText)

=replace(outputs('Get_file_properties')?['body/{FullPath}'], 'Shared Documents''')
i used Name and it worked perfectly well for me

I tried the suggestions by @sips1  (Option 1) and @evancoulson (Option 2), and both worked for me.

Adding screenshots to help anyone who stumbles upon this issue in the future.

 

Option 1 [using 'Name' dynamic content]:

 

bhumika_0-1606407377885.png

 

"Location": The SharePoint site

"File": Provide the path from the "Documents" folder (or your Document Library location), until the file.

For example, if the full path is "/Shared Documents/Documents/<FolderA>/<filename.docx>", then put it as:

/FolderA/<"Name" dynamic content>

 

Option 2 [using 'Path' dynamic content]:

 

Web capture_26-11-2020_224031_india.flow.microsoft.com.jpeg

 

"Location": The SharePoint site

"File": replace(outputs('Save_the_file_in_SharePoint')?['body/Path'], '/Shared Documents', '')

 

Option 2 is less error-prone so I'd prefer that!

 

Hope this helps :)

@sips1 

Unfortunatelly your solution is not working for me, though I think I use same case - filed template, created docx file and trying to convert

Hi @katarzynaMoraczewska ,

 

Do not keep trying to convert a SharePoint file to PDF - It won't work, I remember it used to be an error with the SharePoint connector (that thing is always buggy... Microsoft)

 

You'll need to convert the file from OneDrive to PDF, then move it to SharePoint. Finally delete it from the OneDrive. That's the "work around" sadly, but if there's no issue with having the file in your OneDrive first, that should do it.

 

-Here's the way I did it: https://www.youtube.com/watch?v=vUoRAxFNxlA (tutorial I found back then)

 

Hope that works for you.

See full blog post: https://sharepointlibrarian.com/2017/10/03/convert-sharepoint-documents-to-pdf-automatically-using-microsoft-flow/ Subscribe to this channel: https://bit.ly/3fWYhZQ Donate to help support: https://bit.ly/3AE3M99 LinkedIn: https://linkedin.com/in/nchambe Twitter: ...

I just managed!!! @RodoMCP 

I'm so surprised, but I did it!

The funny thing is it's so simply and so dummy...

 

After creating sharepoint file I  had added "get file properties"

In the "convert...." for file name I've chosen the folder where my form answers should be landing and some past file - just to see what's entered to file name, than deleted file name itself and replaced it with property "file name with extension".