Convert Word to PDF using SharePoint Designer Workflow

Information

Want to see it in action? Contact us to schedule a demo!

In this guide, you’ll get step-by-step instructions on how to convert a Microsoft Word document into a PDF at the click of a button using Muhimbi Document Converter. We’ll also cover how you can convert a folder of Word documents or an entire document library to PDF in SharePoint. This guide can be used in SharePoint Online or on-premises deployments.

Converting a Single MS Word Document in SharePoint

To convert a single MS Word document to PDF, perform the following steps:

  1. Navigate to the Document Library and folder where the MS Word document is located.

  2. Select the MS Word document that you want to convert.

  3. Open the context menu and select Convert to PDF.

convert to pdf

  1. Conversion Settings Page is displayed. You can review the settings and click Convert.

settings page

  1. Conversion results Page is displayed. You can review the results on this page to check if the conversion of the MS Word document has been successful and without any errors.

conversion results

  1. Click Destination Library to navigate to the directory that contains the converted PDF file. Note: When using the Document Converter with MS SharePoint 2010 (or later), you can convert the file by selecting it and choosing Convert to PDF in the Ribbon.

Downloading a Single MS Word Document

If Muhimbi.PDFConverter.ConvertAndDownload.Site Feature is enabled in a site collection, then the Download as PDF option is also added to both the SharePoint Ribbon as well as the file Context Menu.

Download as PDF works very similarly to the Convert to PDF option, except that it opens/downloads the PDF file on a local machine rather than saving it to a location in MS SharePoint.

Converting an Entire Folder Containing MS Word Documents

You can convert an entire folder containing MS Word documents to PDF by performing the following steps:

  1. Navigate to the Document Library that contains the folder with MS Word documents to convert.

  2. Open the context menu and select Convert to PDF.

    convert to pdf

  3. Conversion Settings Page is displayed. You can review the settings and click Convert.

conversion settings page

  1. Conversion results Page is displayed. You can review the results on this page to check if the conversion has been successful and without any errors.

results page

  1. Click Destination Library to navigate the directory containing the converted PDF file(s). Note: When using the Document Converter with MS SharePoint 2010 (or later), you can convert the file by selecting it and selecting Convert to PDF in the Ribbon. The Download as PDF feature does not work for folders.

Converting an Entire Document Library Containing MS Word Documents

Note:** This section is only valid for MS SharePoint 2007.

Although it is possible to convert an entire document library (only in MS SharePoint 2007) containing multiple MS Word documents in one go, it may take a long time to complete, or it may even time out if the library contains many documents. You will automatically receive a warning if many documents are in the library.

You can convert an entire Document Library containing MS Word documents to PDF by performing the following steps:

  1. Navigate to the root folder of the document library containing MS Word documents to convert.

  2. Select Convert to PDF from the Actions menu.

    Note: This option is only available in MS SharePoint 2007.

    convert to pdf

  3. Specify if you want to convert subfolders as well.

  4. Review all the other settings and click the Convert button to start the conversion process.

  5. Verify the files have been converted without errors.

  6. Click Destination Library to navigate the directory containing the converted PDF files. Note: If you are using MS SharePoint 2010 or above, select all files and use the Convert to PDF option in the Ribbon instead, as this option is only available in MS SharePoint 2007.

Saving the Converted MS Word Document to a Different Location

By default, PDF files are saved to the same folder in which the source MS Word documents are located. However, as discussed above, it is possible to specify a different folder, document library, site, or even a different site collection to save the converted PDF files.

To specify a different folder, open the PDF Conversion screen and select the destination folder. When the site is hosted on a MS SharePoint server rather than the free Foundation server, the Browse button is available, allowing folders or sites to be selected within the current site collection.

destination folder
Browse for a destination folder (Commercial versions of SharePoint only)

If the Browse button is not available or the destination folder is located in a different site collection, then you will need to enter the destination path manually. The format to enter the path is as follows:

  1. A folder in the current site collection: Document Library Name/Folder path.
    E.g. – Shared Documents/PDF Files

  2. A folder in the different site collection: Absolute path to Site Collection/Document Library Name/Folder path.
    E.g. – /sites/Press Office/Shared Documents/PDF Files

Note: An absolute path always starts with ‘/’ and will not contain ‘http://’.

If the MS Word documents are always written to the same directory, then it may be a good idea to select Remember this path to automatically default to whatever custom path was last entered.

Note: These settings are remembered per user and stored at the Site collection level.

Clearing the Remember this path checkbox will automatically forget the settings during future conversions.

Working with the ‘Conversion Results’ Screen

The Conversion Results screen contains functionality to simplify managing a large number of converted documents.

The following features are available:

  1. Filter by column: Click the column’s header to filter on and select the value to filter for. For example, select ‘Error’ in the ‘Status’ column to generate an overview of all the MS Word documents that caused an error during the conversion process.

  2. Sort by column: Click the header of a column to sort its contents either in ascending or descending order. For example, click the ‘Source Path’ column to group all documents by folder.

    conversion status

  3. Jump to the destination folder: Click the Destination Library button to navigate to the folder in which the PDF file was written. This is particularly useful when a different destination folder has been specified during the conversion process.

  4. Page through results: A pager is automatically displayed when you convert more than 100 files.

In this guide you’ll learn how to convert Microsoft Word files to PDF using SharePoint Designer Workflows.

Muhimbi’s Document Converter for SharePoint comes with a number of Workflow Actions, including one that you can use to convert Word documents to PDF as part of a workflow using MS SharePoint Designer. To help you get started use the example below to create a simple workflow in MS SharePoint Designer, which converts your Word file to PDF format as soon as it has been approved.

This guide can be used in SharePoint Online and the legacy MS SharePoint 2007 / 2010 workflow engine is fully supported, as is the optional Workflow Manager that comes with MS SharePoint 2013 and later versions. For more details, refer to this post.

Before you start, make sure the Document Converter for SharePoint has been installed, and you have access to a site collection with the appropriate rights to create workflows.

To convert documents via a workflow using MS SharePoint Designer, you will need to configure the Document Library and then also configure the workflow as per the details given below:

Create and Configure the Document Library Containing MS Word Documents

You can create and configure the Document Library containing MS Word documents by performing the following steps:

  1. Create a Document Library named Proposal Documents. You can use any name of your choice.

  2. Ensure you upload all the MS Word documents you like to convert to this location.

  3. Once created, navigate to the library’s Settings
    Document Library SettingsVersioning Settings screen and enable Requires content approval for submitted items.

  4. In the Document Library, create two folders (You can use any name of your choice): Confidential Proposals and
    Approved PDF Files.

Create and Configure MS SharePoint Designer Workflow

You can create and configure the MS SharePoint Designer Workflow by performing the following steps:

  1. Start MS SharePoint Designer and open the site collection that contains the Proposal Documents Document Library. This contains MS Word Documents.

  2. Click Add Item and select List Workflow. Specify the following settings:

    • Name for the workflow: Convert Approved documents to PDF Format.

    • Select the Document Library associated with the Workflow: Proposal Documents.

    • When creating a SharePoint Designer Workflow in SharePoint 2013 or later, select the appropriate Platform Type.

      add item

  3. Click Create button to proceed.

  4. We are now ready to create the workflow. From the ‘Conditions’ menu, select the ‘If value equals value’ condition.

  5. Click the first value followed by the display data binding (fx) button.

  6. Select ‘Current Item’ as the Source and select ‘Approval Status’ in the field.
    Click the OK button to continue.

  7. Click the second value and select ‘Approved’ from the list.

To avoid the same workflow being executed on the converted PDF file after the conversion has taken place, we need to specifically exclude PDF files as follows:

  1. Add another ‘If value equals value’ condition.

  2. Click the first value followed by the display data binding (fx) button.

  3. Select ‘Current Item’ as the Source and select ‘File Type’ in the Field. Click the OK button to continue.

  4. Select ‘equals’ and change it to ‘not equals’.

  5. Click the second ‘value’ and enter ‘PDF’, without a period ‘.’.

With the Conditions in place, we can now add the Actions, which is where the magic happens.

  1. From the Actions menu, select Convert to PDF. It may be hidden behind the All Actions option.

  2. The following action is inserted:
    Convert ‘this document to ‘this URL using ‘the same file name’ and ‘include / exclude meta data’. Store the converted item details in List ID: ‘Variable: List ID’, Item ID: ‘Variable: List Item ID’.
    Let’s examine what the various options within the action mean:

    • this document: Specify which document to convert. Select the option
      and make sure Current Item is selected.

    • this url: Specify the location to which the converted file will be written. The following options are available:

      1. Leave it empty: When no value is specified then, the converted MS Word document is written to the same folder as the source file.

      2. Site Relative URL: By specifying a URL relative to the current site, e.g. subsite/shared documents/PDF Files, any folder location in the current site collection can be targeted. This is the option we want to use so enter ‘Proposal Documents/Approved PDF Files’.

      3. Web Application relative URL: Using a URL that is relative to the entire web application, e.g. /sites/Press Office/Public Documents/To Distribute, any folder location in any site collection can be targeted.

    • the same file name: The name of the converted file can be specified here. In our case, we will leave it empty to make sure we use the same name as the original document.

    • include / exclude metadata: In case of sensitive documents, we may want to strip out any custom SharePoint columns information from the file. Assuming that our document library contains a column Yearly sales forecast, and the MS Word document uploaded has information entered in that column, we want to select ‘Exclude’.

    • Variable: List ID: A new workflow variable named List ID is automatically created. After the file has been converted, this variable will contain the ID of the list the converted file was saved to. This can later be fed into another action in order to manipulate this file further.

    • Variable: List Item ID: A new workflow variable named ‘List Item ID’ is automatically created. After the file has been converted, this variable will contain the ID of the item the converted file was saved to. This can later be fed into another action in order to manipulate this file further.

  3. Insert a new action named ‘Log to History List’ and enter ‘File converted’.

  4. Insert a new action named ‘Update List Item’ and select ‘this list’. We are now going to automatically mark the converted PDF file as ‘approved’.

    • From the ‘List’ dropdown select ‘Confidential Proposals’.

    • Click Add button and set the field to ‘Approval Status’ and the value to ‘Approved’, and click OK.
      Note: Starting with MS SharePoint 2010, it is no longer possible to set the value of the ‘Approved’ field.

    • In the ‘Find the List Item’ area set the field to ‘ID’.

    • Click the fx button next to ‘Value’, specify ‘Workflow Variables and Parameters’ as the Source and set the field to ‘Variable: List Item ID’ and click the OK button.

    • Click OK again to return to the MS SharePoint Designer Workflow. It should look like the image below.

      update list item

  5. Click Publish button to deploy and activate the workflow.

Testing the Workflow

You can test the workflow created by performing the following steps:

  1. Create or upload a document in MSWord file format to the ‘Confidential Proposals’ folder.

  2. From the context menu, select Approve / Reject and approve the file.

This will automatically start the workflow, and after a few seconds, the Workflow status should change to Completed, as shown in the screenshot below.

approve or reject

Once the workflow has been completed, you will find the PDF version of the MS Word document in the ‘Approved PDF Files’ folder.

approved pdf files

If an error occurs during the execution of the workflow, you can perform the following to troubleshoot the same:

  1. Check the messages on the workflow status screen.

  2. Check for errors in the Windows Event log.

  3. Check for errors in the SharePoint trace log.

Information

We recently released the Muhimbi Document 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 Microsoft Word documents to PDF using Nintex Workflows.

In the first part of the guide we use the Muhimbi Document Converter for SharePoint On-Premises to convert MS Word documents to PDF using a Nintex workflow. The Muhimbi Document Converter for SharePoint On-Premises comes with comprehensive support for all Nintex Workflow versions, currently NW2007 – NW2019.

In the second part of the guide we convert MS Word documents using Nintex Workflows (O365) with our REST API. This involves integrating the functionality exposed by the Muhimbi Document Converter for SharePoint Online directly into a Nintex Workflow by invoking our comprehensive REST API.

Converting MS Word using Nintex with Document Converter for SharePoint On-Premises

In this example, a Nintex workflow retrieves all the MS Word documents modified during the current day and converts them to PDF. In an ideal setup, you will schedule this workflow to run out of office hours to process this as a batch for all new and modified files.

To create a new workflow, you can follow the instructions below or download the complete workflow in NWF format from the following link:

Nintex Workflow to retrieve and convert files to PDF

nintex workflow The finished workflow

Prerequisites

Before we start building the workflow, 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 Document Converter for SharePoint On-Premises version 4.1 (or newer) is installed in line with chapter two of the Administration Guide.

  2. Naturally Nintex Workflow will need to be installed as well.

  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 a new workflow

To get started, create a new workflow and choose the blank template. Make sure the workflow doesn’t start automatically and add the workflow variables listed in the following screenshot.

workflow variables

Ensure that the appropriate data types are assigned. They are listed under the ‘Type’ column beside each variable name. The names are largely self-explanatory, 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 and later select Integer as the Type, not List Item ID.

  • Source List ID: The Document 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 need to be specified as well. 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, check it in. Once converted, the ID of the PDF is automatically stored in this variable. In SharePoint 2010 and later select Integer as the Type, not List Item ID.

  • Generated PDF List ID: As the Document 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

You are now ready to add the actions to the workflow. You can start with adding a Query List action, which will allow you to retrieve all files modified today and store the results in the Source Files collection.

add query list

You can fill out the settings for this action as per 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.

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

configure action for each

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

You need to ensure that the workflow only invokes the Document Converter for those files that are not already in PDF format. To achieve this, add a condition and check that the file type equals ‘pdf’ as per the following screenshot.
set condition in workflow

After this, you need to add the Convert file to PDF action listed under the Muhimbi PDF section to the No branch of the workflow condition (as we want this workflow to only convert those files that are not of type pdf). You can fill this section as per the image below:

convert file to pdf

The Document Converter integrates with all Nintex Workflow versions.

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 logging information using the Log In the History List action. In our example, we use the following two logging information:

  • 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

You can finalize the workflow by saving and publishing it, after which the workflow is ready to be executed.
You can either run the workflow manually or schedule it to run at a specific time of your choice.

Converting MS Word Documents Using Nintex Workflows (O365) using REST API

Note: Please note that this tutorial is for the SharePoint Online version of Nintex Workflow. For details about using our software in combination with the on-premise (2007-2016) versions of SharePoint, see this Knowledge Base article.

You can also convert MS Word Documents using Nintex Workflows using REST API. This section shows how to integrate the functionality exposed by the Muhimbi Document Converter for SharePoint Online directly into a Nintex Workflow by invoking our comprehensive REST API.

Although Muhimbi’s comprehensive Web Services (SOAP) interface works well with our on-premise products, the brand-new, and much-simplified, REST-based interface works very well with cloud-based products.

This new REST-based service is part of the Muhimbi Document Converter Services product. It comes as a separate product and does not have any dependencies on MS SharePoint and can be used to integrate with services such as Microsoft Flow, Azure Logic Apps, C#, Java, PHP, JavaScript, Python Ruby, and many other services including Nintex Workflow for Office 365. Although available as a stand-alone subscription, this new service is automatically included in each Document Converter for SharePoint Online subscription at no additional charge.

Prerequisites

Before you begin, please make sure the following prerequisites are in place:

Building the Workflow

This section explains in detail how you can create the workflow to convert MS Word documents to PDF.

This workflow is available for download as well. If you are downloading, you can import it to Nintex Workflow for Office 365, then set the API KEY, and then publish it. Once the workflow is published, you are ready to go.

If you are creating the workflow step by step, you can navigate to a site collection and document library of your choice containing the MS Word document and choose the option to create a new Nintex Workflow. In this example, we use the standard Shared Document library that is available on most site collections.

Create the Following Workflow Variables:

The following Workflow Variables need to be created for the workflow to work correctly:

  • JSON (Text): Contains the JSON, JavaScript Object Notation, the command that will be sent to the conversion service.

  • API_KEY (Text): A unique ID that will be used to look up your Muhimbi subscription details.

  • ResponseText (Text): The status message returned by the Conversion Service.

  • ResponseCode (Integer): The status code returned by the Conversion Service.

    workflow variables

As a first step, insert a Set Workflow Status action, edit it and set it to Started. This status will let you know that the workflow has actually been triggered (as there is no other way to track this in MS SharePoint Online). This will also give you the option to click on something to inspect the current status of the workflow.

Add a Build String action and set the Output to the JSON workflow variable. In the String field enter the following:

\[  
"sharepoint_file":  
\[  
"site_url":"‍{Workflow Context:Current site URL}‍",  
"source_file_url":"‍{Current Item:Server Relative URL}‍",  
"destination_file_url":"‍{Current Item:Server Relative URL}‍.pdf"  
\],  
"output_format":"PDF",  
"fail_on_error":true  
\]

build string

When you insert code, pay attention to the following:

  • JSON Notation: You may be familiar with JSON notation, but note that we have replaced the curly braces - { } - with square brackets [ ]. This is due to a bug in Nintex Workflow for Office 365. If you have any concerns about using square brackets (as they are also used for Array types) feel free to replace them with anything else. In a follow-up step we will fix them.

  • Copy & Paste: When pasting this JSON code from the browser window, paste it in Notepad (and copy back) to strip out non-standard characters and formatting.

  • References: The text displayed in red are Nintex Workflow references. After pasting the entire fragment, replace each Nintex reference using the Advanced Lookup facility on the bottom of the text box in the screenshot above.

  • Output file name: In this basic example, we just add ‘.pdf’ to the end of the output path and file name. To keep things simple, we are not including the Nintex Workflow actions to strip off the old extension and add the new one. You can use any valid output path and file name.

As mentioned above, we have used square brackets for JSON above and we need to replace these with curly braces again. You can insert a Replace Substring in String action and configure it as follows:

  • Search String: Enter the opening square bracket [.

  • Replace String: Enter the opening curly brace {.

  • String: Insert a reference to the workflow variable named JSON.

  • Output: Pick the JSON workflow variable to store the results in.

  • Click Save button.

    replace substring in string

Copy the workflow action (using the actions menu), and paste it as the next action. Configure the newly pasted workflow action and replace the opening bracket with the closing bracket ‘]’. Do the same for the curly brace, and replace ‘{’ with ‘}’. Click the Save button, and we now have a valid JSON that we can send to the Conversion Service.

You need to next set the API_KEY. Insert a Set Variable action and configure it to set the API_KEY workflow variable to the API Key you received by email when signing up for the Muhimbi Document Converter Services Online and click the Save button. E.g.:

decafbad-baad-baad-baad-decafbaaaaad

Note: Do not try to use this particular key, as it will not work. Do not put curly braces around the key.

set api key

Next, you need to insert the Web Request action and configure it as follows:

  • URL: https://api.muhimbi.com/api/v1/operations/convert

  • Method: POST

  • Content type: application/json

  • Add header: Click Add header, specify API_KEY as the Header name and insert a reference to the API_KEY workflow variable for the Header value.

  • Body: Select the Content option, add a reference to the JSON workflow variable in the Data field.

  • Store response content in: ResponseText.

  • Store http status code in: ResponseCode.

  • Click Save button.

set workflow status

Finally, insert another Set Workflow Status action and configure it with the text Completed. This will help us when we run the workflow, as we can now easily see when the workflow has been completed.Your completed workflow should look like the following:

text completed

nintex workflow

word to pdf

The workflow is complete and can now be published.

Once published, open the document library the workflow is associated with and ensure that a MS Word document is present. You can manually start the workflow. After a few seconds, the PDF file will show up next to the file the workflow was started on.

Troubleshooting

Although both Nintex Workflow for Office 365 and the Document Converter for SharePoint Online work very well together, there are a lot of moving parts in the workflow like custom generated JSON, customer-specific API keys, paths to the document libraries, etc. So, there are chances that you may encounter some issues when deploying the workflow. Some common issues and troubleshooting tips are provided below for your reference:

  • Check prerequisites: Double-check that the prerequisites listed in the beginning of this section are in place.

  • Log to History List: If it is not clear what is going wrong, log critical parts such as the JSON workflow variable (after the replace operation) as well as the ResponseText workflow variable (after the web request) using the Log To History List workflow action. You can see the contents of this list by clicking on the Workflow Status column for the List Item the workflow is running on.

  • Send email: The amount of text that can be logged to the History List is limited (roughly 250 characters). For larger messages, use the Send an Email action instead to send an email with debug content in the body of the email to yourself.

  • Copy & Paste: When copying the JSON fragment into your workflow, paste it into Notepad first to clean it, and then copy it from Notepad and paste it into your workflow. This is because browsers tend to insert hidden characters that are not filtered out by the Nintex Workflow editor.

  • Nintex References: Make sure that the Nintex Workflow references in the JSON provided are replaced by actual Nintex Workflow references. You can double-check if the references are active by logging the JSON workflow variable to the History List. You should see the actual paths and not {Current Item:Server Relative URL}.

  • Muhimbi Support: After double checking all prerequisites and going over all troubleshooting steps in this section, if you are still stuck, please contact our friendly support desk, who are here to help.

Fine-tuning

The workflow created in the previous section was to give a quick idea of how to use the Converter. However, it would benefit from error handling and a solution for a possible recursion problem where the workflow will be triggered for PDF files that it has created by itself.

We have created a version of the workflow that is more production ready. Full details on the same are beyond the scope of this article. You can download the full workflow here and customize this as per your requirements.

After customization, you can import it into Nintex Workflow for Office 365, and set the API KEY, and then publish it for your use.

47

48

49

Other Operations

This section demonstrated how to invoke the Convert action on Muhimbi’s REST interface to convert MS Word documents to PDF. In addition to PDF Conversion, we also expose additional end-points for Merge, Watermark, Secure, Split, OCR and also for Copy Metadata operations. Full examples are beyond the scope of this article, but you can find examples in the SharePoint section of our GitHub repository.