Generate Dynamic Invoices using Power Automate and PDF4me
Dynamic document generation automatically creates a batch of documents that are personalized with dynamic data from a source. For example, an Invoice might be personalized to address each recipient by name. Creating documents with dynamic data would require a data source, like a list, spreadsheet, database, JSON, or array. Merge fields are placeholders in predefined templates that are later replaced using data from one of those mentioned above or any other supported data sources.
Creating an invoice with dynamic data requires the application of techniques like mail merge or using merge fields. Custom invoices are based on document templates created using Word or other form creators that have to merge field capabilities. To generate pdf invoices with dynamic data, templates are created with merge fields that are later replaced with original data.
PDF4me Mail Merge Data String(List of Docs) lets you create Dynamic invoices and automate them so that you can focus on your most important tasks. The generation process can be automated if you have the template and the dynamic data ready. The template can be a Word file or HTML, or any other supported format. The data can be a Spreadsheet, CSV, JSON, XML, or data list.
How to Generate Dynamic Invoice with Power Automate?
Generating an Invoice with Dynamic Data using Make requires the template and data to be stored in a cloud storage platform. At least, the template should be in cloud storage like Dropbox, but the data can be passed to an input data field directly.
Here we discuss the use of templates created using the mustache syntax - {{placeholder field}} - which is later replaced with the dynamic data.
Add a trigger to start the Flow
Power Automate has several available triggers for starting a Flow. You can choose the preferred trigger based on where you store your source files. In the example, we are using the Dropbox trigger. Add a When a file is created in Dropbox connector to trigger the Zap.
Add a Dropbox step to get file content
To get the template data, map the file using a Dropbox step - Get file content.
Add PDF4me Mail Merge with Data String action
The action gets the template file content from the previous Dropbox action. The data to be populated can be directly added to the Data String textbox in a JSON format.
The data for the input field should look like the below for the template in the use case:
{
"Documents": [
{
"header": {
"docType": "Original Copy"
},
"body": {
"Column1": "Quantity",
"Column2": "Description",
"Column3": "Unit Price",
"Column4": "Total",
"Invoice": {
"number": 14957,
"date": "25-02-2022",
"instructions": "Instruction Invoice 1",
"subTotal": 200150,
"tax": "18%",
"dueDate": "25-03-2022",
"shipping": "200"
},
"Biller": {
"phone": "989797",
"fax": "998463",
"email": "[email protected]",
"web": "www.doc1.com",
"address": {
"company": "Organization 1",
"street": "Street 1",
"city": "City 1",
"zip": "123456"
}
},
"Recepient": {
"name": "recepeint 1",
"address": {
"street": "testveien 3 ",
"city": "City 1",
"zipcode": "0555",
"country": "Country 1"
}
},
"Product": [
{
"quantity": 1,
"description": "item 1",
"unitPrice": 45,
"totalPrice": 867
},
{
"quantity": 2,
"description": "item 2",
"unitPrice": 123,
"totalPrice": 3464
},
{
"quantity": 3,
"description": "item 3",
"unitPrice": 323,
"totalPrice": 6564
}
]
},
"footer": {
"phone": "phone123",
"fax": "fax123",
"email": "[email protected]",
"web": "www.123.com"
}
}
]
}
Add Apply to Each control
Since the action produces multiple file outputs, add an Apply to Each Power Automate action to handle the files one after the other.
Add Create File Dropbox action
Add and configure Dropbox action to save the output files within the Apply to Each control.
The output generated file would look like the below.
With a PDF4me Developer Subscription, you can create workflows that can automate the mass generation of documents with dynamic data with the least manpower and low cost. The subscription ensures your automation never stops due to any shortage of the number of API calls.