Hello everyone! I am Priyanshu Srivastav, a Gold Microsoft Learn Student Ambassador from India. I am very much interested in Microsoft's Power Platform and building no code/ low code solutions that simplify day to day repetitive tasks for citizen developers. In this blog post, I’ll be walking you through the procedure of creating ID card generator using Power Automate- one of the 5 tools of Microsoft Power Platform.
If you are a head of a student club of your university or manage a community, one of the tedious tasks for you is to generate ID card for the new members of the club. Manually creating an ID card and emailing it to the members is very much time consuming and error prone. Now, you want to automate this process but don’t have required coding skills to build such an application.
This is where Microsoft's Power Platform comes in handy. Microsoft Power Platform is a low code/no code platform that allows people with limited coding knowledge to perform a lot of their manual tasks successfully and seamlessly. Enough of beating around the bush? Let us now directly dive into creating a program that builds ID cards for the newly admitted students in a club. Here we say Lumos –
What Do You Need to Get Started?
To follow along, you need the following:
Office 365 subscription. If you don't have, you can create a Microsoft 365 Developer Account here
OneDrive for Business
Curiosity to learn ;)
Overview of Our Solution
We want to be able to automatically generate ID cards for members of our student club or organization.
We would need to create a folder in our OneDrive by the name “Pictures” which stores pictures of members of the club.
The name of each picture should be of the convention “<FirstName> <LastName>”. For example, my picture will be stored as “Priyanshu Srivastav”
Trigger of the flow – when a new file is created. Any other trigger can also be used here but for simplicity purpose, I decided that the flow will run whenever a picture is uploaded in OneDrive Folder named “Pictures”.
An ID card template is also present in my OneDrive. I’ve created the template using Microsoft Word.
As soon as a picture is uploaded in the “Pictures folder”, the flow is triggered and the name of the file and the picture itself are used to generate ID card using the Word template. The generate ID card is converted into pdf format and stored in another One Drive folder called “PDFs of ID cards”.
This is how the flow will look by the end of this.
Didn’t understand a thing? Too confusing? We have got you covered. I’ll be covering each of the above six blocks in detail in the forthcoming section.
STEP 0: First things first
I have created a simple ID card as shown in the figure. To create a template,
Open up Microsoft Word on your desktop and head over to Developer tab in the ribbon (if it is not present in the ribbon, on the file tab, go to Options>Customize Ribbon. Under Customize the Ribbon and under Main Tabs, select the Developer check box.)
Add an image control (which will contain the photograph of the student) and a text control (which will contain the name of the student).
Add other static text like club name and university name and save the template.
Upload the template to OneDrive.
Arranging contents in OneDrive
For this demo purpose, I have a folder called ‘ID Card‘ in my OneDrive and in that folder, there are 2 subfolders – ‘PDFs of ID cards’ (to store the generated ID cards) and ‘Pictures’ (the folder in which the pictures will be uploaded). I’ve uploaded the ID card the template in the ‘ID Card’ folder. This is how my folder looks like –
Step 1: Trigger of the Flow.
The flow should run whenever a file is uploaded in ‘Pictures’ folder of my OneDrive. Right? So, the trigger will be ‘When a new file is created’.
The trigger requires us to provide the path to the folder we are intending to work on. So, select the ‘Pictures folder’.
Step 2: Populating Word Document
In order to populate a word document, we need Word (Online) connector. Search for the connector and select the action “Populate a Word Document”.
The Action requires 3 mandatory questions –
Location – The location where the word template is stored (OneDrive for Business in our case)
Document Library – OneDrive
File – Browse and select the Microsoft Word template we created earlier.
After selecting the file, 2 new fields will be populated – the image and text control we added. For the image, we need to select the image that should be put in there. For this purpose, we can use the dynamic content from the trigger and select “File Content”
For the text control, we need to provide the name of the student. By, convention, the name of the file itself is the name of the student. Therefore, for this field, we will be selecting the “File name” dynamic content.
Step 3: Create the file
Now, after we have provided the values for the image control and the text control, we need to create a new file to store the content of the id card. To do this,
Create a new OneDrive Action “Create File”
Provide the path to the folder where this file will be stored.
Provide name of the file. Since this is just a temporary word document file, we will name it as “temp.docx”. [Note that this file will be deleted later after converting to pdf]
For file content, add the dynamic content from the previous word template we created – “Microsoft Word Document”.
Step 4: Convert File
Add a new action called “Convert File” in order to convert our temporary file generated to pdf.
The action takes values of 2 arguments as input –
File – the unique identifier to the file which is to be converted. We will use dynamic content “id” of previous ‘Create file’ action.
Target type – the target file type (pdf in our case).
Step 5: Store the pdf file
Till now, we have created a word document of the ID card, converted the word document to pdf format. Now, its time to store the pdf in OneDrive. For this we will be using the action of OneDrive Connector called “Create File”.
Similar to step 3, we need to provide the destination folder path, file name and file content.
The file content will be dynamic content called “File Content” of the previous action (Convert file action).
Step 6: Delete the temporarily created the word document.
The word document of ID card created in step 3 will have to be deleted. For this purpose, we will be using “Delete File” action of OneDrive. We just need to provide the unique identifier to the file we created. For this, in the file field, we will be providing the dynamic content – “id”.
With this, we have successfully created the flow for generating ID cards using Power Automate. To test the flow, upload a picture of yours in the OneDrive folder and see the magic 🪄 I’ve uploaded the picture and here is the pdf format of the ID card generated for me.
Here are some additional resources for your benefit: