Convert responses from Microsoft Form to PDF

Microsoft Forms provides us with a quick and easy way to create surveys, quiz’s etc. The response to these Forms can be saved in SharePoint list or can be sent over email using Microsoft Flow but how can we save the responses as a PDF in the SharePoint Online Document Library?

In this Blog, we will use the Muhimbi “Convert HTML to PDF” Microsoft Flow action to Convert the Microsoft Form response to PDF and save it in a document Library.

If you are working with complex controls(checkbox) and want to preserve your Forms layout then see blog post.

Please make sure the following prerequisites are in place:

  • An Office 365 subscription with SharePoint Online license.
  • Muhimbi PDF Converter Services Online full, free or trial subscription(Sign up).
  • Appropriate privileges to create Flow.
  • Working knowledge of SharePoint Online, Microsoft Flow and Microsoft Forms.

For this demo, we will convert the Sample Microsoft Form (below) to PDF.

From a High level our Flow will look like:


Step 1:

Add the “When a new response is Submitted” trigger action. It will trigger the flow when a new response is submitted.

In the trigger action specify the “Form Id” of the Microsoft Form.

Step 2: 

  • Add the “Get response details” action. This action retrieves a form response.
  • Specify the “Form Id” of the Microsoft Form
  • For the “Response Id” add the output “List of response notifications Response Id” of the “When a new response is Submitted” trigger action.

Step 3:

  • This is where the real Magic happens. Add the Muhimbi “Convert HTML to PDF” action.
  • Copy the HTML fragment provided below in the ‘Source URL or HTML’ area in the Muhimbi ‘Convert HTML to PDF’ action and then insert the various list fields in the appropriate places just before each line’s <br/> element.
<html>
<body>
<h2>Help us Improve</h2>
Responders Email:<br />
Submission time :<br />
Feedback:<br />
</body>
</html>

Step 4:

Use the “Create file” SharePoint action to write the PDF document to the SharePoint document library.

  • File name: For this Demo, we will use “Feedback(Responder’s Email).pdf” (output variable of the “Get response details” action).
  • File content: Processed file content the (output variable of the “Convert HTML to PDF”)action.

Step 5:

All done! Now it’s time to test our Flow.

  • Open the link\URL for the Microsoft Form in the browser and submit a Form.
  • The Flow will be triggered automatically and a PDF should be created in the SharePoint Document Library.

Happy Converting.

11 thoughts on “Convert responses from Microsoft Form to PDF

  1. Hi Calvin,
    I’ve followed your described method but I seem to have hit a snag. If a person submits more than one form response then their previous pdf-ed response gets overwritten in the SharePoint library. How do I overcome this? Any help greatly appreciated as I’m quite new at this.

    Thanks.

    Like

  2. A quick solution would be to add the UTC() Expression – Your formula would be

    Feedback(@{utcNow()}-@{body(‘Get_response_details’)?[‘responder’]}).pdf

    Another idea would be to generate a random GUID() – Reference formula –

    Feedback(@{guid()}-@{body(‘Get_response_details’)?[‘responder’]}).pdf

    Like

  3. Thanks for that, the random GUID() worked.

    Sorry but one more question, my form has about 15 questions, with quite a few of them large text boxes. My issue is that the pdf created has none of the white spaces and line breaks in these longs paragraphs kind of making it hard to read and also decipher.
    is there any way to retain the formatting from the original form response when converting it to PDF?

    Like

  4. Thanks for this guide. I followed the directions and the flow ran, but created a .dms file vs .pdf even though I have the .pdf in the “File Name” field of the “Create File” step. Any thoughts?

    Like

  5. Hi I am facing a new issue. In the apply to each trigger I don’t find the dynamic expression List of Respondents ID –Can you help me with the way out

    Like

  6. Wondering if there is a cleaver way to auto-magically create an HTML table for each answered questions with 2 columns the first for the question and the second with the answer. That way we can re-use the same actions for all of our Forms without having to explicitly create the HTML as in your example. I can get the JSON data but as you might be aware it only includes the question ID’s and not the actual question text. Thanks in advance.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s