Convert Microsoft Forms to PDF Using Power Automate

In this guide, you’ll learn how to convert Microsoft forms to PDF using Power Automate.

Steps to convert your Microsoft form to PDF using Power Automate:

  1. Create a flow
  2. Define your action
  3. Create a file
  4. Publish your workflow

Microsoft Forms provides a quick and easy way to create surveys and questionnaires to collect responses from different people. Even though this is useful, the completed forms aren't easily portable — i.e. you can't send a form to another person and expect to keep the look and feel of the completed form, along with any files that have been uploaded to it, intact.

Using Power Automate and Muhimbi PDF Converter, you can merge form attachments into a single PDF, along with the responses, and then send that PDF as an email. You can also write the generated PDF to SharePoint, OneDrive, or anywhere you can send files using Microsoft Power Automate.

Sample MS Form with Attachment

This example will use the following form.

sample ms form


Before building the workflow, ensure all prerequisites are in place:

  • Knowledge about Microsoft Forms and how to build workflows using Power Automate
  • A full, free, or trial subscription to Muhimbi PDF Converter
  • Permission to use Power Automate
  • Appropriate privileges to create flows

Using Power Automate to Convert Forms with Attachments to PDF

The image below shows a high-level overview of how to convert forms with attachments to PDF.

convert forms with attachments

1: Creating a Flow

Add the When a new response is submitted trigger action specifying the Form Id of the Microsoft Form. It will trigger the flow when a new response is submitted.

when a new response is submitted

2: Getting the Response Details

Add the Get response details action, specifying the Form Id and Response Id of the Microsoft form. This will trigger the flow when a new response is submitted.

get response details

3: Converting to PDF

Convert the form to PDF by adding the Muhimbi Convert HTML to PDF action. You can copy the HTML code fragment provided below into the Source URL or HTML field of the Muhimbi action and then insert the various list fields in the appropriate places, just before each line’s <br /> element. Your completed code will look like what you see in the screenshot.

convert html to pdf

4: Working with Attachments

Add the Compose action to the canvas, and set the Inputs to the field that collects the attachments. In this scenario, it's the Please upload your test results from the clinic field, which is the output of the Get response details action. Press Save to save the workflow.

get response details

Note: You use this action as a temporary one to get the JSON sample payload for the Parse JSON action. This can remove the action after getting the payload.

5: Getting the Sample Payload

Fill in the form, upload a file, and submit the form. This will trigger the flow.

  • You can now open the flow that just ran and expand the Compose action, which will look like the screenshot below.

  • Copy the JSON from the OUTPUTS section of the Compose action to a clipboard, and then delete the Compose action.

    copy json from

6: Parsing the JSON

Next, add the Parse JSON action to the canvas, and fill in the following:

  • Content — Pass the Please upload your test results from the clinic field, which is the output of the Get response details action, and which is where your attachments are stored.
  • Schema — In the Parse JSON action, click the Generate from sample button, which will open a modal dialog box. Paste the content from the JSON you copied from the Compose action into the text box, and press Done.

parse json

Note: From the schema, you'll notice that the output for the uploaded document is an array of objects that contains the file name, link to item, etc. You'll need to parse these JSON objects to keep using the schema in your flow.

7: Initializing the Variable

Add the Initialize Variable action, and set the Name field to Files and the Type field to Array.

variable action

8: Getting the File Content

Add the Get file content action, and in the File field, add the item id, which is the output of the Parse JSON action.

Get file content

Note: Power Automate will automatically add the Apply to each loop around the Get file content action.

Apply to each

9: Appending to the Array Variable

Next, within this loop, add the Append to array variable action. In the Name field, specify Files. In the Value field, add the following:

value and names

10: Merging Documents

Outside the Apply to each loop, add Muhimbi’s Merge documents action. Ensure Switch to input entire array is active, and pass in the Files variable, which is the output of the Append to array variable action.

Merge the Microsoft form text question to the attachments. To do this, add another Merge document action, configuring it with reference to the details below:

  • Source file name – 1InitialQuestion.pdf
  • Source file content-1Processed file content, which is the output of the Convert HTML to PDF action.
  • Source file name – 2Merged.pdf
  • Source file content – 2Processed file content, which is the output of the Merge documents 1 action.

Note: Do not switch to detail inputs for an array item in the Muhimbi Merge action.

source file content

11: Choosing a Send Action

Choose any send action. In this example, you can use the Send an email(V2) action and configure it with reference to details below:

  • To — Email address
  • Subject — Patient Questionnaire <You can input any subject of your choice.>
  • Body — Hi, Patient Questionnaire has been submitted by “Responder’s Email”. Many thanks, Patient Services <You can input any content of your choice here>
  • Attachment Name — sample.PDF
  • Attachments ContentsProcessed file content, which is the output of the Merge documents 2 action.

Now go back to the sample questionnaire and answer it. Attach files and click Submit.

You'll notice that the responses and attachments will be converted to PDF and emailed to the email address chosen in the Send an email(V2) action.

Have a Question?
We’re Always Happy to Help.

© Muhimbi Ltd. 2008 - 2024
This website uses cookies to ensure you get the best experience. Learn more