Power Automate: Convert Doc Files to PDF

Introduction

A common requirement is to convert between file types and while developing legacy applications we used to refer third-party libraries to get these conversions done. However, with Power Automate, we have the option natively to perform format conversion.

In this article, we will see how to achieve the conversion of Word Document to PDF format.

Business Use Case

We have a requirement where we are dealing with Word-based Invoices and to ensure that the invoices are not easily edited and maintained in a more standardized format, we will be converting it into PDF once the Word Document is uploaded to the SharePoint repository.

For achieving this, we will be using One Drive’s Convert File action which has the capability of format conversion between file types. The supported conversion using this action is listed in the official documentation here.

Destination Format

Description

Supported Source Format

glb

Converts the item into GLB format

cool, fbx, obj, ply, stl, 3mf

html

Converts the item into HTML format

eml, md, msg

jpg

Converts the item into JPG format

3g2, 3gp, 3gp2, 3gpp, 3mf, ai, arw, asf, avi, bas, bash, bat, bmp, c, cbl, cmd, cool, cpp, cr2, crw, cs, css, csv, cur, dcm, dcm30, dic, dicm, dicom, dng, doc, docx, dwg, eml, epi, eps, epsf, epsi, epub, erf, fbx, fppx, gif, glb, h, hcp, heic, heif, htm, html, ico, icon, java, jfif, jpeg, jpg, js, json, key, log, m2ts, m4a, m4v, markdown, md, mef, mov, movie, mp3, mp4, mp4v, mrw, msg, mts, nef, nrw, numbers, obj, odp, odt, ogg, orf, pages, pano, pdf, pef, php, pict, pl, ply, png, pot, potm, potx, pps, ppsx, ppsxm, ppt, pptm, pptx, ps, ps1, psb, psd, py, raw, rb, rtf, rw1, rw2, sh, sketch, sql, sr2, stl, tif, tiff, ts, txt, vb, webm, wma, wmv, xaml, xbm, xcf, xd, xml, xpm, yaml, yml

pdf

Converts the item into PDF format

doc, docx, epub, eml, htm, html, md, msg, odp, ods, odt, pps, ppsx, ppt, pptx, rtf, tif, tiff, xls, xlsm, xlsx

Implementation

We will be using SharePoint Document Library named Invoices Library for uploading the Word Invoice document and the power automate will have a ‘When a file is created’ trigger to start the flow. We will also use the Get File Content to extract the data from the uploaded file which will be later in the flow.

Graphical user interface, text, application, email

Description automatically generated

Now that we have the file content, we have to create the file in One Drive for any conversion because the Convert File action is natively supported in One Drivel. So, we will use the Create File action to move the file from SharePoint and create a copy in One Drive. Ensure that the File Name field uses the Dynamic field ‘File name with extension’ to create the file with the same format as in SharePoint. We will assign the Body Content Output from the Get file Content action to the File Content Field for creating the file with the same content.

Graphical user interface, text, application, email

Description automatically generated

Once the same file is available in OneDrive, will use the Convert File action which is again associated with One Drive to perform the file conversion where we will pass the ID of the recently created One Drive file as input and PDF as the Destination Format.

Application

Description automatically generated with medium confidence

Finally, we will use the Create File action to Save the converted PDF content back to SharePoint where we will use a separate destination library to store the converted PDF files. We will assign the same of the One Drive File with PDF extension to the File Name field and the File Content field will host the ‘File Content’ output of the Convert file action

Graphical user interface, text, application, email

Description automatically generated

Thus the overall flow will look like this:

Graphical user interface, application

Description automatically generated

Test the flow

We will trigger the flow by uploading an invoice word document in the library.

Graphical user interface, application, Teams

Description automatically generated

The flow has converted the content using the Onedrive’s Convert file action and gives a PDF Output Content.

Graphical user interface, text, application, email

Description automatically generated

The converted file has also been created in the Destination Document Library

Graphical user interface, text, application

Description automatically generated

Summary

Thus, we saw how to convert a Word Document to PDF using the One Drive Action – Convert File which is a very handy option when we need to convert file formats. Please note that at the time of writing this article, Convert File action is still in Preview and there may be changes to the action in due course of time.

Related Articles

Author

Author

Priyaranjan KS is a Modern Workplace Architect primarily focused on developing and architecting solutions around Office 365,Power Platform and Azure.He is also a Microsoft Most Valuable Professional(MVP) and a Microsoft Certified Trainer(MCT)

Latest Articles