In this guide you’ll learn how to automatically print InfoPath Forms to PDF in SharePoint using a Power Automate flow. If you are looking to automatically convert InfoPath Forms to PDF in SharePoint visit our InfoPath to PDF conversion guide.
Using Power Automate to print, convert and archive MS InfoPath forms is a bit more involved process as InfoPath uses two files to create a single form, an XML (data) file, and an XSN (template) file. You can print this converted form using File \Print menu from the PDF.
In this example, you will create a simple Flow that is triggered whenever a form is added to a folder in a SharePoint Online Library. Once this is added, the form is automatically printed to a PDF and stored in the MS SharePoint folder. You can open this form in PDF, and using File \Print, you can print this form.
This example can easily be adjusted to use different file services (e.g. the trigger can be for files uploaded to OneDrive, Box.com, DropBox, Google Drive or can even be used to Migrate your SharePoint On-Premise InfoPath Forms to SharePoint Online, etc).
Before we start building the workflow, ensure all prerequisites are in place.
- Muhimbi PDF Converter for Power Automate full or free trial subscription.
- Appropriate privileges to create Power Automate(Flow).
- Working knowledge of both Infopath Forms and Power Automate.
- Access to a high-speed printer to print large volumes of documents quickly.
Using PowerAutomate to Convert to PDF
From a high-level perspective, the Flow looks as follows:
Note: Converting an InfoPath form is similar to converting any other document type using Muhimbi's Flow Actions, but you will also need to pass in the XSN file (the file content, not the URL to the file) alongside the XML file.
This example takes you through converting an MS Infopath file to PDF. From a high-level perspective, the steps to create are as follows:
Create a new Flow and use the SharePoint Online trigger ‘When a file is created’. Fill out the URL for the Site Address and select the relevant SharePoint folder.
Insert ‘Get File Content’ action and specify the path to the SharePoint Online location where the XSN has been published to. (By default it is stored in the Forms Folder, e.g. *‘https://yourdomain.sharepoint.com/sites/Sitecollectionname/Library/Forms/template.xsn’
Insert Muhimbi’s ‘Convert Infopath document’ action, and fill it out as follows.
Source file name: ‘File name’ the output from the ‘When a file is created in a folder’ trigger.
Source file content: ‘File Content’ the output of the ‘When a file is created in a folder’ trigger.
Output format: PDF
Template file content: ‘File Content’ the output of the ‘Get file content’ action, which contains the InfoPath XSN file.
View names: Enter the comma-separated view names that need to be converted to PDF
Include attachment: If you would like the attachments to also be converted to PDF, select Yes.
Attachment action: You can select how to deal with attachments. The options available are:
Default - If this is selected, the attachments are merged into the output file and unsupported attachments are removed.
Merge - If this is selected, the supported attachments are merged into the output PDF.
Unsupported attachments - If this is selected, the behavior will be according to the settings in InfoPathConverterFullFidelity.UnsupportedAttachmentBehaviour.
AttachAsPDF - If this is selected, supported attachments are converted into PDF and attached to the output document.
Unsupported attachments - If this is selected, the attachments are handled according to the settings in InfoPathConverterFullFidelity.UnsupportedAttachmentBehaviour.
AttachOriginal - If this is selected, all attachments are attached to the output document in their original format.
Unsupported attachment action: You can select what to do when the Converter encounters unsupported attachments. The default value is 'Error'.
Error - When this option is selected, an error is raised when unsupported attachments are found.
Remove - When this option is selected, the unsupported attachments are ignored and not included in the output.
AttachOriginal - When this option is selected, unsupported attachments are attached in their original format
Break merge on error: When you select ‘Yes’, then the merging of the document is stopped and an error message is shown.
Default paper size: Select the paper size to be used if not specified in the view.
Default paper size (custom): Enter the paper size to be used if the Default paper size ‘Custom’ is used.
Force paper size: Force the paper size to be used regardless of whether it is set in the views or not.
Force paper size (custom): Enter the paper size to be used if Force paper size ‘Custom’ is used.
Default page orientation: Select the default page orientation for the PDF.
Force page orientation: Force the page orientation to be used regardless of whether it is set in the views or not.
Start page: Select the first page to include in the PDF.
End page: Select the last page to include in the PDF.
Conversion quality: Select the quality of the output file.
Override settings: You can enter further optional settings using Muhimbi’s XML syntax.
Fail on error: When an error message is encountered, it will stop the process if ‘Yes’ is selected.
Note: Do not just pass the path to the XSN file into the Muhimbi Action as it doesn’t have the privileges to read that file.
Insert a ‘Create File’ action to write the converted file back to the OneDrive folder where the converted PDF files are written to. For the Folder path, specify the path to the OneDrive folder. For the File Name, pass in the 'Base file name' field returned by the ‘Convert Document’ action, along with '.pdf' suffix. In the File content field pass the 'Processed file content' returned by the ‘Convert document’ action.
You can write the converted file back to the OneDrive folder, Dropbox, or Google Drive, or you can send the PDF via email.
Publish the workflow and upload an MS Infopath file in the specified document library. After a few seconds, the Flow will trigger and a PDF file will be generated.
If you have large quantities of PDF to be printed, periodically copy a batch of converted PDF files from the source folder to your local drive.
Select the batch of PDF files on your local system, right-click on one of the files, and select the Print option.
Please note that this is just a basic example. Muhimbi PDF Converter also comes with facilities to convert files attached to InfoPath forms as well as choosing which InfoPath view or views to convert. For more information, please feel free to contact our friendly support teams.