How to create QR Code Sheets with Power Automate

December 4th 2023
Back to all blogs

If you are looking to create QR Code Sheets with Power Automate, you’re in the right place! Encodian Flowr’s Populate Word Document action is an incredibly powerful document generation engine that overcomes many of the limitations of the native Microsoft action in Power Automate. For example, generate Word documents with:

  • Rich-text and HTML
  • Nested repeating sections and nested array data
  • Conditional expressions
  • Custom formatting
  • Hyperlinks
  • Image sizing
  • …and more!

Today we are going to create a QR code sheet to show some of the repeating image functionality and how easy it is to use the action. The resulting output will look like this:

Step 1: Create your Word Template

Download the Word template here: DOCX Template

Configure the Microsoft Word document with tokens that Power Automate will replace with the JSON data provided at runtime.

For our current use case, we have the following elements:

  • foreach tokens to signify content is being repeated (repeating content syntax: Repeating Sections or Paragraphs)
  • image token placed within the foreach tokens. When using the image token, you must add the token inside a text box (image token syntax: Images)
  • All formatting in the template will transfer to the output document. Therefore, the text box border is removed to avoid the QR codes having a border
  • The text box size is adjusted so that 3 text boxes populate before moving to a subsequent line.
  • The – keep ratio token is added to the image token to preserve the size of the textbox during document generation and to stretch the QR Code image within the bounds of the textbox whilst preserving the ratio of the QR Code. There are various image formatting tokens available for different use cases.

Step 2: Create your Power Automate Flow

The overview of the flow we are going to create is as follows.

This is a simplified version of a flow you may want to create. Here, we are creating just a single QR code and populating it into the template 12 times, but obviously, you may need to create 12 different QR codes using dynamic data within a loop.

First, retrieve the Word template.

Secondly, create your QR codes. In this example, we have hardcoded the QR code data as the Wikipedia URL and have added a caption below the barcode. There are 28  possible parameters to configure your QR Codes, including borders, resolution, placing logos inside QR codes, colouring and much more.

Thirdly, we will Populate our Word Template by passing through the QR Codes within a JSON array.

Our support article on Populating Word Images syntax explains the basic structure of the JSON that is required:

{
   "Name": "Test",
   "Base64image": "Base64stringwithinquotes"
}

The good news is that our Generate QR Code action outputs a Base64 string. However, in some scenarios, Power Automate will silently re-encode your string when you use it in another action (you can see this in the run history), and onward actions fail because they believe they have received a corrupted base64 string.

To fix this, we put the File Contents within quotation marks and a string() function.

{
   "Name": "Test",
   "Base64image": "string(Generate-QR-Code-File-Content)"
}

In my flow, the expression you can see in the screenshot above looks as follows:

{
   "Name": "Test",
   "Base64image": "string(outputs('Create_QR_Code')?['body/FileContent'])"
}

Lastly, we create the Word Document in SharePoint or convert it to PDF before creating the document!

That’s it! However, remember that the QR Codes can be generated with a huge number of configuration options, and the Word template can also be configured to get the exact result that you are looking for. As always, don’t hesitate to get in touch with us if you need any support.

Create a FREE account to use our Power Automate connector

Author
Alex Rackwitz

Director

Back to all blogs

You might also be interested in...