Generate multiple pages PDF in Power Automate

On one of my previous blogposts about generating a PDF in Power Automate without premium subscription, I got a question if it is possible to generate a PDF of more than one page.

The goal is generating a multiple pages PDF without buying premium licenses or paid third party connectors.

I started investigating and started trying out the CSS page-break attribute. Using this page-break attribute in the OneDrive connector to convert HTML to PDF is not possible.

When you have a subscription for Encodian connectors, it is possible. See their blogpost on converting HTML to PDF or Word.

However I didn’t gave up and searched a workaround to do it without buying something extra and using out of the box connectors.

First step is to write some HTML in a “Compose” action:

<html>
<head>
<style>
#approvalHistory {
height: 300px;
}
h2 { 
margin-top: 450px;
}
</style>
</head>
<body>
<h1>Overview</h1>
<div id="approvalHistory">
<p>Approval History: </p>
</div>
<p>Owner: </p>
<h2>Details</h2>
<p>These are the details</p>
</body>
</html>

The div approvalHistory has a height of 300px. This makes it possible to insert content into this div that is dynamic and not always has the same height in the PDF.

For the h2 tag, I calculated a little bit and added a margin-top of 450 pixels. This is not really a proper solution, but it can be useful if you cannot buy extra subscriptions.

Next steps are:

  • Creating the HTML file
  • Convert the HTML file to PDF
  • Creating the PDF file

After running the flow, the h2 tag is on a new page:

We achieved what we want by calculating the height to fit the h2 tag to a new page. You can (temporary) use this workaround if you really need it.

If you need to create a stable and enterprise-wide used solution it might be better to look into a stable way to convert multiple page PDF’s.

Leave a Reply

Your email address will not be published. Required fields are marked *