![Flow]()
Step 1. Trigger, When Power App Calls a Flow(V2).
![Power App Calls]()
This is the trigger for the power automation flow to start. Whenever you click on the button Generate PDF in the Power Apps, the flow gets triggered, and this data will be passed from the Power App to the Power Automate flow.
Step 2. Compose.
![Compose]()
![Result]()
Compose Action in Power Automate enables the user to analyze the inputs /data that the Power Automate flow is receiving. We are using the compose actions in this flow to analyze the input that is sent from the Power App.
Step 3. Parse JSON.
![Parse Json]()
![Run]()
![JSON]()
The Parse JSON action is used to convert the string inputs that we get from the Power Apps to JSON format. If we look at the image showing the output of the compose action, we can see the data in string format. These data are converted to JSON format using the parse json action for easy processing.
Step 4. Select.
The Select action is used to map the key and value that we get from the output of the Parse JSON action.
As mentioned above, we have the key for mapping the values in the templates, so in this action, we are mapping the values for the corresponding key in the templates.
![Select]()
![Date]()
Step 5. Switch.
The switch action is used to switch between the different sets of actions to use the templates we have, according to the number of rain gauges for a structure.
![Switch]()
![Case]()
Step 6. Populate a Microsoft Word Template.
This action allows us to populate the template we made with values that we get from the Power Apps.
![Populate]()
![Output]()
The marked contents are the dynamic contents from the select action, where we mapped the value to the corresponding key in the template.
Step 7. Update File.
![Update file]()
In this action, we are updating a docx file using the contents from the populate a Microsoft Word template action.
Step 8. Convert Word Document to PDF.
![PDF]()
Using this action, we are converting the updated docx file into a PDF. Now we have the file content in the PDF format.
Step 9. Update File.
![Updated]()
Again, we are using the update file action to update a PDF file with the contents from the convert Word document to PDF action.
Step 10. Create File.
![Create File]()
Using the create file action, we are saving the created PDF file to the sharepoint site with a dynamic file name.
Step 11. Get Metadata.
Using the Get Metadata action, we are retrieving the path of the PDF file.
![Metadata]()
Step 12. Compose.
![Composed]()
Using the compose action, we are actually making the URL for the PDF file we just generated.
Step 13. Respond to the Owner App.
![Respond]()
This is the final action; using this action, we actually send the response to the Power App. The response contains the PDF URL, which we get from the previous compose action.
Conclusion
This flow allows you to generate a PDF directly from Power Apps by leveraging Power Automate and Microsoft Word template functionality.