Generating PDF Files using Power Automate

PowerTechHub
3 min readMay 30, 2022

--

I had a recent requirement of generating PDF files for a pre-defined structured information with a decent formatting.

There were definitely more than one way.

Option 1 : Convert File

By making use of the Convert File connector available within OneDrive.

The file content needs to be created within the Onedrive and then proceeded with conversion to required format.

For PDF conversion, the file must be of one of below formats :

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

I had a key requirement of processing & converting information more than > 100k rows from a DB and needs to formatted.

The source I turned to was, HTML .

Why not Docx or xlsx you may ask ? — I might have to end up, writing to excel file first , store it — then proceed with the actual conversion.

HTML has a decent formatting option — it supports CSS formatting as well.

With the help of the Inbuilt connector, Create HTML Table.

I read data — Created HTML Table of the data. Stored the file in OneDrive as .HTML File.

I applied necessary CSS for the formatting in the Append to String Variable.

<style>……………………………… </style> [HTML Table]

I converted the file & created in my required destination ( which was Sharepoint in this case)

Key Points to Note :

  • The file size cannot be more than 2 MB. The HTML file /Table you had created cannot be more than 2MB. If it is, then Convert File activity errors out.
  • Not all CSS,HTML formatting is supported when conversion takes place.
  • The file needs to be present in the user’s OneDrive momentarily.

My requirement was not met through this — as I had > 100k rows. I hit the 2 MB limit in my case.

Option 2: Power BI service

By making use of the Power BI Paginated Reports. This option can be used when you have very large amount of structured data to be exported as PDF — which was my case.

What are Paginated Reports ?

Paginated reports are designed to be printed or shared. They’re called paginated because they’re formatted to fit well on a page. They display all the data in a table, even if the table spans multiple pages.

Power BI Paginated Report supports to Export to PDF functionality — which export all pages as a PDF.

The same functionality can be called from the Power Automate.

You will need at least Power BI Premium Per User (PPU) license. You will be to generate one export for every 5 minutes. I had this delay logic to avoid hitting this limitation.

Alternatively, if you have at least one workspace backed by reserved capacity — you may not hit the above limitation.

You have Power BI report builder tool that can aid in rich formatting.

Power BI Report Builder — Power BI | Microsoft Docs

You will have to design the PowerBI report using the report builder and publish to the power bi service.

This published report can be consumed and exported as PDF using the connector “Export to File for Paginated Report” from the Power Automate.

Option 3 : Paid connectors like Adobe,Plumsail,Cloud Immersive.

If you have necessary licenses with these partners, you will be able to make use of them.

--

--