InfoPath Print to PDF

In this guide, you’ll learn how to automatically print InfoPath forms to PDF in SharePoint using a Power Automate flow. If you’re looking to automatically convert InfoPath forms to PDF in SharePoint, refer to our InfoPath-to-PDF conversion guide.

Using Power Automate to print, convert, and archive MS InfoPath forms is an 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’ll create a simple flow that’s 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 as a PDF and print it using File > Print.

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, or Google Drive, or it can even be used to migrate your SharePoint On-Premises InfoPath Forms to SharePoint Online, etc).

Prerequisites

First, ensure all prerequisites are in place:

  • A full or free trial subscription of Muhimbi PDF Converter for Power Automate.
  • Appropriate privileges to create Power Automate flows.
  • Working knowledge of both InfoPath Forms and Power Automate.
  • Access to a high-speed printer to print large volumes of documents quickly.

Using Power Automate to Convert to PDF

From a high-level perspective, the flow looks like what’s shown below.

convert to pdf using power automate

Note: Converting an InfoPath form is similar to converting any other document type using Muhimbi’s flow actions, but you’ll 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:

  1. Create a new flow and use the When a file is created’ SharePoint Online trigger. Fill out the URL for the Site Address and select the relevant SharePoint folder.

    create new flow

  2. Insert the Get file content action and specify the path to the SharePoint Online location where the XSN file has been published. By default, it’s stored in the forms folder, e.g. https://yourdomain.sharepoint.com/sites/Sitecollectionname/Library/Forms/template.xsn/.

    *get file content

  3. Insert Muhimbi’s Convert InfoPath document action, and fill it out as follows:

    1. Source file name — The file name is the output from the When a file is created in a folder trigger.

    2. Source file content —The file content the output of the When a file is created in a folder trigger.

    3. Output format — PDF

    4. Template file content —The file content is the output of the Get file content action, which contains the InfoPath XSN file.

    5. View names — Enter the comma-separated view names that need to be converted to PDF.

    6. Include attachment — If you’d like the attachments to also be converted to PDF, select Yes.

    7. Attachment action — You can select how to deal with attachments. The options available are:

      1. Default — If this is selected, the attachments are merged into the output file and unsupported attachments are removed.

      2. Merge — If this is selected, the supported attachments are merged into the output PDF.

      3. Unsupported attachments — If this is selected, the behavior will be according to the settings in InfoPathConverterFullFidelity.UnsupportedAttachmentBehaviour.

      4. AttachAsPDF — If this is selected, supported attachments are converted into PDF and attached to the output document.

      5. Unsupported attachments — If this is selected, the attachments are handled according to the settings in InfoPathConverterFullFidelity.UnsupportedAttachmentBehaviour.

      6. AttachOriginal — If this is selected, all attachments are attached to the output document in their original format.

    8. Unsupported attachment action — You can select what to do when the converter encounters unsupported attachments. The default value is Error.

      1. Error — When this option is selected, an error is raised when unsupported attachments are found.

      2. Remove — When this option is selected, the unsupported attachments are ignored and not included in the output.

      3. AttachOriginal — When this option is selected, unsupported attachments are attached in their original format

    9. Break merge on error — When you select Yes, then the merging of the document is stopped and an error message is shown.

    10. Default paper size — Select the paper size to be used if not specified in the view.

    11. Default paper size (custom) — Enter the paper size to be used if the default paper size Custom is used.

    12. Force paper size — Force the paper size to be used regardless of whether it’s set in the views or not.

    13. Force paper size (custom) — Enter the paper size to be used if forced paper size Custom is used.

    14. Default page orientation — Select the default page orientation for the PDF.

    15. Force page orientation — Force the page orientation to be used regardless of whether or not it’s set in the views.

    16. Start page — Select the first page to include in the PDF.

    17. End page — Select the last page to include in the PDF.

    18. Conversion quality — Select the quality of the output file.

    19. Override settings — You can enter further optional settings using Muhimbi’s XML syntax.

    20. Fail on error — When an error message is encountered, it will stop the process if Yes is selected.

      fail on error
      Note: Don’t just pass the path to the XSN file into the Muhimbi action, as it doesn’t have the privileges to read that file.

  4. Insert a Create file action to write the converted file back to the OneDrive folder where the converted PDF files are written to. In the Folder Path field, specify the path to the OneDrive folder. In the File Name field, pass in the base file name field returned by the Convert document action, along with the .pdf extension. In the File Content field, pass the processed file content returned by the Convert documentaction.

create file

You can write the converted file back to the OneDrive folder, Dropbox, or Google Drive, or you can send the PDF via email.

  1. 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.

  2. 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.

  3. Select the batch of PDF files on your local system, right-click 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 us.

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