In this post I will look at how to create PDF documents from data.
In the example that I’m using in this post I will generate a quotation document that takes data from my Dynamics 365 system. But there are so many more use cases for PDF document that take data from any kind of data source.
Your data may live in SharePoint lists, or maybe SQL or maybe even Dataverse it all doesn’t really matter. The aim will all be the same take some data and put it into a nice looking document that is ready to impress the reader.
In my case I got a design delivered in a word document and needed to generate a PDF from a Model Driven app.
now I could use the document generation within Dynamics but I quite quickly found myself going through hoops to make things work. So I thought, I could create a flow.
So straight from my opportunity in Dynamics 365 I can generate a quote that is emailed to me in PDF format ready to send to my client.
In my case I’m going to use the data in Dynamics 365 and generate the html from that.
First steps first. I created the html for my document. This is where you will start to look at the document and recognize that you have pages with a header and a footer and in the footer there is a page number.
If you considered using a flow like this then you will find quote quickly that the OneDrive PDF conversion isn’t up to the job
A couple of the issues that I ran into were:
So I started to look at other options.
The connector that I looked into to generate the PDFs is called Encodian. In this post I will give a bit more information on how to use this great connector. But it isn’t just the connector that is great. During my trials i tested their support team and their support is second to none.
I’m going to start with the generation of the HTML. I’m not going to go into details here as every document will be different. If you need help with generation the html fell free to contact me and I can help you build the flows to do this.
First of all you will need to generate the main html for the page. This is all of the pages without the headers and the footers.
So I initialized a variable that hold my html.
Then I add the html for each element within my document. it is useful to add some comments in your html so that you can recognize the different parts of your document.
Now that we have the html ready, we can Create PDF documents from the html.
The flow that I created uses a few actions from the Encodian connector to create PDF documents. First we will need to convert the HTML to PDF using the Convert HTML to PDF action.
Now we will need to add the header and the footer. There is only one action available for this. The Add HTML Header or Footer will ask you to select the location. this can be Footer or Header but also both. When you select both your header and footer will be the same. I’m not sure when you would do this, but I’m sure there will be some use case for that.
So just construct the HTML that you want to appear on all pages and your PDF will have the footer and the header that you want, making your document look good.
Now we have a header and a footer but no page numbers yet. This however is the easy part. The Add page numbers lets you add a page number to each page in whatever format you might need. In page case I wanted the page number of total pages format.
Then the result quite quickly looked like this.
Why would you use Dataverse, if SharePoint lists gives you the option to avoid premium…
When you read items from a SharePoint list and you want to filter by calculated…
A few weeks ago I looked at calling flows from model driven apps. And for…
To get all your broken connections in the Power Platform can be a challenge. In…
If you call Customer Voice still Forms Pro or not, have you ever looked into…