Convert InfoPath to PDF using Nintex Workflow

We recently released the Muhimbi PDF Converter Xtension for Nintex Automation Cloud. You can download it here or learn more about available Muhimbi deployments for Nintex on our product page.

In this guide you’ll learn how to convert InfoPath Forms to PDFs using Nintex Workflows. We provide details on how you can control which view or views to convert to PDF and how you can specify which views to convert depending on the form’s current status.

We also provide details on how to specify the views to convert during design time or at run time using a little bit of custom code or Nintex forms rules. You can also control which views to convert using Nintex workflow or Nintex for O365 in MS SharePoint Online. The example provided below uses the Nintex workflow. But this works equally well in the MS SharePoint Designer workflow as well.

In this example, we create a workflow to retrieve all files modified during the current day and convert them to PDF. Ideally, you would schedule this workflow to run off-peak to batch process all new and modified files

sharepoint designer workflow

Nintex Dialog for the new PDF Conversion Action

The Nintex Convert File to PDF Action can use Nintex Lookups and Workflow Variables and can be used to convert items other than the ones that triggered the workflow, which makes it ideal for converting entire sets of documents.

Prerequisites

Before we build the workflow, please ensure all prerequisites are in place. It is also assumed that the reader has some knowledge of building Workflows using Nintex Workflow.

  1. Make sure the PDF Converter for SharePoint version 4.1 (or newer) is installed in line with chapter 2 of the included Administration Guide.

  2. Naturally, Nintex Workflow will need to be installed as well. Nintex Workflow versions 2007, 2010, 2013, and 2019 are supported.

  3. Make sure the Muhimbi.PDFConverter.Nintex.WebApp SharePoint Feature is activated on the relevant Web Application using SharePoint Central Administration.

  4. You will need to have the appropriate privileges to create workflows.

Creating the Infopath Form

  1. Navigate to the MS SharePoint List where you want to design the Infopath form.

  2. Go to Site Settings → Form Options and click Customize the current form using Microsoft Infopath and click OK button.

    site settings form options

  3. InfoPath Designer for the list opens

  4. On Page Design tab, select New View.

  5. Name the new view ‘PDFView’ or any name of your convenience.

  6. Change the Title at the top to 'PDF View' so you know the exact view that has been exported.

  7. Select the fields you like to see in this view and design the Form View accordingly.

  8. Click FilePublish.

Initial Test

To test that all steps have been carried out correctly and that the PDF Converter is working as expected carry out the following steps:

  1. Open the new Form Library in SharePoint and fill out a new form. Don’t enter any data, just save it.

  2. Convert the file that was just generated from the context menu. When the PDF is opened you'll see Edit Item View, which is the default view.

  3. Fill out another form, but this time enter PDFView. Save it under a new name.

  4. Convert the file we just generated from the context menu. When the PDF is opened you'll see PDF View.

Creating the Nintex Workflow

To get started, create a new workflow and choose the blank template. You can download the complete workflow in NWF format and reuse it for your environment.

nintex workflow

Make sure the workflow doesn’t start automatically and add the workflow variables listed in the following screenshot.

workflow variables

Please ensure that the appropriate data types are assigned (They are listed between round brackets behind each variable name). The names are largely self-describing, but some additional information is provided below:

  • Source Item ID: By default, the item that triggered the workflow is converted to PDF format. However, as we are iterating over multiple items we need to specify the ID of the item to convert in this variable. In SharePoint 2010 / 2013 select Integer as the Type, not List Item ID.
  • Source List ID: The PDF Converter assumes the item that is being converted is located in the same list the workflow is attached to. However, if this is not the case, then the ID (a GUID) of the list will also need to be specified. In this example, everything is located in the same list, so this variable is not actually used.
  • Source Files: As we are potentially converting multiple files, we need to define a variable of type Collection to hold the list of files we will be iterating over.
  • Generated PDF Item ID: Once a file has been converted to PDF, you may want to carry out additional actions on this new file, for example, checking it in. Once converted, the ID of the PDF is automatically stored in this variable. In SharePoint 2010 / 2013, select Integer as the Type, not List Item ID. This example uses the (Legacy) Convert to PDF Workflow Activity, if you use the newer Convert Document activity then please take into account that the Generated PDF Item ID is of type Text. If you wish to pass this ID into a secondary activity then you may need to convert it to the correct data type using the Convert Value Workflow Activity. An example can be found here.
  • Generated PDF List ID: As the PDF Converter allows files to be written to different document libraries, and even completely different Site Collections, you may want to know the ID of the destination list.

Adding the workflow actions

We are now ready to add the actions to the workflow. Begin by adding a Query List action, which will allow us to retrieve all files modified today and store the results in the Source Files collection.

add workflow actions

You can fill out the settings for this action as in the screenshot listed above. You may want to add an additional filter rule to check that Content Type is not equal to Folder or Document Set.

Continue by adding the For Each action to the workflow. Specify the collection’s name to iterate over and the variable’s name to store the Item’s ID in.

specify collection name

The next set of actions will all need to be added inside the For Each action, to make sure they are executed separately for each file in the list.

We want to ensure that we only invoke the PDF Converter for files that are not in PDF format. So, add a condition and check that the file type equals ‘pdf’ as per the following screenshot:

file type equals pdf

Add the Convert file to PDF action listed under the Muhimbi PDF section to the No branch of the condition (type is not pdf). Fill it out as per the leftmost image in the following screenshot.

convert file to pdf

PDF Converter integrates with Nintex Workflow 2007, 2010 & 2019

You may want to leave the Destination Path empty, which will write the PDF File to the same location as the source file. For more information about the Destination Path or any of the other fields, hover the mouse over the small information icons.

The workflow is now done. You may want to add some tracking information using the Log In the History List action. In our example we use the following:

  • Last action in the No branch:
    List ID: {WorkflowVariable:Generated PDF List ID} - List Item ID: {WorkflowVariable:Generated PDF Item ID}
  • Last action in the Yes branch:
    Already in PDF Format: {WorkflowVariable:Source Item ID}

Running the Workflow

Finalize the workflow by saving and publishing it, after which it is ready to be executed.

You can either run the workflow manually or schedule it to run at a time of your choice. You will observe that the InfoPath document will be converted to PDF in the target document library.

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