As electronic invoicing becomes standardized across Europe, many businesses are adopting ZUGFeRD to ensure compliance and streamline automation.
ZUGFeRD (Central User Guide of the Forum for Electronic Invoices Germany) is a hybrid e-invoice format that embeds a machine-readable XML file within a human-readable PDF. This dual structure makes it perfect for automated invoice processing while still being accessible for manual review.
In this tutorial, we’ll show you how to:
For a detailed overview of ZUGFeRD standards and Germany’s invoicing regulations, see Stripe’s guide to ZUGFeRD invoices.
Download a sample ZUGFeRD invoice for testing: ZUGFeRD-Example.pdf
For this post we’ll manually trigger the flow, within your own automations you can use any Power Automate trigger action.
1. Create a new ‘Instant cloud flow‘.
1.a. Flow name: Provide a name for your flow.
1.b. Trigger: Select the ‘Manually trigger a flow‘ trigger action.
1.c. Click ‘Create‘.
2. Configure the ‘Manually trigger a flow‘ trigger action
For testing purposes we will upload an invoice file directly to the Flow. To do this we’ll add a File input on the ‘Manually trigger a flow‘ trigger action.
2.a. Click ‘Add an input‘ > Select ‘File‘ > Enter the name ‘Invoice’.
3. Add the Encodian ‘PDF – Extract Attachments‘ action
3.a. File Content: Select the ‘Invoice contentBytes’ property provided by the ‘Manually trigger a flow’ trigger action.
3. At this point let’s test the Flow so we can examine the outputs and look at the embedded XML file in its raw format.
3.a. Select ‘Test’ > Select ‘Manually’ > Click ‘Test’ > Import the test invoice file > Click ‘Run flow’.
3.b. Following successful execution of the Flow. Select the ‘PDF – Extract Attachments’ action > click ‘Show raw outputs’
3.c View the outputs of the action. The embedded XML file can be seen in the documents section of the returned JSON.
4. Iterate the Embedded XML Documents – The output of the ‘PDF – Extract Attachments’ action is a collection of documents which will need to be processed via an ‘Apply to each’ action.
4.a. Add an ‘Apply to each’ action.
4.b. Select the ‘Documents’ property provided by the ‘PDF – Extract Attachments’ action.
5. Check for a ZUGFeRD filename
As per the ZUGFeRD specification the XML embedded in a ZUGFeRD invoice will have one of three filenames depending on the version of the specification it adheres to:
5.a. Add a ‘Condition’ action within the ‘Apply to each’ action.
5.b. Check the ‘Documents Filename’ output from the ‘PDF – Extract Attachments’ action meets one of the three accepted ZUGFeRD filenames.
Once the XML has been extracted there are multiple options on how and where to process depending on your business requirements. This could include sending to a 3rd party via email, adding to some form of persistent storage such as a SharePoint list, Dataverse, API, finance system or ERP.
We’ll cover two scenarios; Sending the extracted XML as a file via email and secondly, processing the XML within Power Automate adding the data to a SharePoint list.
1a. Add a ‘Send an email notification (V3)’ action within the ‘True’ branch of the ‘Condition’ action
1c. To: add a recipient email address
1d. Subject: add an appropriate subject line
1e. Body: add appropriate body text
1f. Attachment: Select the ‘Document File Content’ property provided by the ‘PDF – Extract Attachments’ action.
1g. Attachment File Name: Select the ‘Documents Filename’ property provided by the ‘PDF – Extract Attachments’ action
2. Test the Flow – Test the flow again as described in section 3 and review the email and attached XML.
For option 2, we are going to extract the seller information and invoice line items from the XML and save them as entries in a SharePoint list:
1. Create a SharePoint list
1.a. List Name: ‘ZUGFeRD Invoice Line Items’
1.b. Create the following columns with a data type of Text.
2. Extract the XML as a string – A ‘Compose’ action will be used to extract the XML from the outputs of the ‘PDF – Extract Attachments’ action as a string.
2.a. Add a ‘Compose’ action within the ‘True’ branch of the ‘Condition’ action
2.c. Inputs: Configure the following expression > ‘base64ToString(items(‘Apply_to_each’)?[‘fileContent’])’
3. Convert the XML to JSON with the Encodian action ‘Utility – Convert XML to JSON’
3.a. Add the Encodian action ‘Utility – Convert XML to JSON’
3.b. JSON: Select the ‘Outputs’ variable provided by the ‘Compose’ action
4. Parse the JSON output from the Encodian action ‘Utility – Convert XML to JSON’
4.a. Add the action ‘Parse JSON’
4.b. Content: Select the ‘Result’ property provided by the Encodian action ‘Utility – Convert XML to JSON’
4.c. Schema: Click ‘Use sample payload to generate schema‘ > Copy contents from referenced MS Word document ‘ZUGFeRD-Example-JSON.docx’> Click ‘Done’
(If using a different invoice file than the one provided, a sample schema can be generated by executing the flow and extracting the JSON output from the ‘Utility – Convert XML to JSON‘ action)
5. Add data to the ‘ZUGFeRD Invoice Line Items‘ SharePoint List
5.a. Add an ‘Apply to each’ action to the flow as it will need to be able to iterate multiple line items contained within the JSON dataset.
5.b. Add a ‘Create Item’ SharePoint action
5.c. Site Address: Set the URL of site hosting the ‘ZUGFeRD Invoice Line Items’ list
5.d. List Name: Select the ‘ZUGFeRD Invoice Line Items’ list
5.e. Title: Select the ‘Body ram:ID‘ property provided by the Parse JSON action
5.f. Seller Name: Select the ‘Body ram:Name‘ property provided by the Parse JSON action
5.g. Seller Contact: Select the ‘Body ram:PersonName‘ property provided by the Parse JSON action
5.h. Seller Telephone: Select the ‘Body ram:CompleteNumber‘ property provided by the Parse JSON action
5.i. Seller Email: Select the ‘Body ram:URIID‘ property provided by the Parse JSON action
5.j. Product: Select the ‘Body ram:Name‘ property provided by the Parse JSON action
5.k. No of Units: Select the ‘Body #text‘ property provided by the Parse JSON action
5.l. Unit Amount: Select the ‘Body ram:ChargeAmount‘ property provided by the Parse JSON action
5.m. Total: Select the ‘Body ram:LineTotalAmount‘ property provided by the Parse JSON action
6. Test the Flow – Test the flow again as previously described. Upon successful execution, refresh the SharePoint list ‘ZUGFeRD Invoice Line Items’ to see the two new line items.
We hope this post provides a helpful guide to processing ZUGFeRD invoices using Power Automate and the Encodian Flowr connectors. If you require further assistance, please review the documentation on our support portal or raise a ticket with our support team.
Please share any feedback or comments – all are welcome.
Search 200+ Actions to see how Flowr can save you time
Sign up for your free 30-day trial; no cards, catches, or contracts.
Digital Marketing Director