Generate Dynamic Invoices using Zapier and PDF4me
Dynamic document generation is one of the most sought and is the fastest growing technology in the digital world. As we all know most businesses are becoming paperless and the new changes in the way of handling transactions demand documents be generated digitally. PDF documents are the most preferred mode of digital documents. Businesses, where money is involved, are always required to generate invoices. A lot of data in these invoices are dynamically generated.
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 Generate Document action in Zapier 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 Invoices?
Let us look at here an example where you can create a dynamic invoice in Zapier where the template is in Word format and data is in JSON. The JSON lets you create complex data in a structured format.
Let’s look at the following sample template
Add a trigger to start the Zap
Zapier has several available triggers for starting a Zap. 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 New file in Dropbox trigger for Dropbox to trigger the Zap.
Add Download from Dropbox actions for Template & Data
To pass the Template and Data to the Generate Document action, we need to download the Template and associated data from the source. Since we are using Dropbox here, we use the Download from Dropbox action.
Add the Generate Document Action from PDF4me
Once the files are downloaded, we need to pass it to the Generate Document action. In the action, configure the Template file name and Data file name. Also, select the Data type. PDF4me allows 2 types of Data in the Mustache rendering type - XML and JSON. We are using JSON in the current example.
For the above sample template, the sample data would look like below:
{
"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"
}
}
]
}
Configure the parameters accordingly in the PDF4me Generate Document action.
Note that you will have to specify merge fields in header, body, and footer separately with loops. Always specify content inside the body of the document as “body”.
Add Upload to Dropbox action with a Loop control
When documents are generated dynamically, there will be multiple output files. For each file, the Zap should save the file to the desired location. We use the For Each control action to handle when multiple output files are expected.
Add the following Dropbox action inside the loop.
You can accordingly configure the following fields in the Loop action and make sure the Upload to Dropbox action is inside the looper.
The Dynamic Invoice generated would look like below.
You can also add a QR code or Barcode to make your invoice machine-readable using the Add Barcode action as well.
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.