Using the PDF Converter from a SharePoint Workflow

It is always interesting to see how your customers have a completely different look on the fantastic product you have been working on for months. After the initial release of our PDF Converter for SharePoint, the majority of the support calls we received were about how to use the product from a SharePoint workflow. Errrr…… we hadn’t really thought about workflows as it is so un-cool, related to SharePoint designer…and…and…and… actually we had never done much with SharePoint workflows.

As much of our feature set and product development is driven by customer demand, it was time to skill up on workflows and  - dare I say it - SharePoint Designer. And you know what? It is pretty cool!As a result a new, workflow enabled, version of the PDF Converter is now available for download.

What follows is an example of how to create a simple workflow in SharePoint Designer, which converts a file to PDF format as soon as it has been approved. If you prefer to use Nintex Workflow then have a look at this post.

Before you start, make sure the PDF Converter for SharePoint has been installed and you have access to a site collection with the appropriate rights to create workflows. Some basic knowledge about creating and configuring document libraries is assumed.

Create and configure the Document Library

  1. Create a document library named ‘Important Documents’.

  2. Once created, enable ‘Requires content approval’ on the library’s Settings > Document Library Settings > Versioning Settings screen.

  3. In the document library, create two folders: ‘Confidential Proposals’ and ‘Approved PDF Files’.

Create and configure the work flow

  1. Start SharePoint Designer and open the site collection that contains the ‘Important Documents’ library.

  2. From the File menu select New > Workflow.

  3. On the first screen of the Workflow wizard, specify the following settings:

    • Name the workflow ‘Convert Approved documents to PDF Format’.
    • Select the ‘Important Documents’ list.
    • When creating a SharePoint Designer Workflow in SharePoint 2013 then please select Platform Type: SharePoint 2010 Workflow.
    • Select the 2nd and 3rd checkboxes to make sure the workflow is triggered whenever a document is created or (its status) is updated.
    • Click the ‘Next’ button to proceed.

workflow wizard

  1. We are now ready to create the workflow. From the ‘Conditions’ menu select ‘Compare any data source’. This inserts the ‘If valueequalsvalue’ condition.

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

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

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

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

  1. Add another ‘Compare any data source’ condition.

  2. Click on 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. Click ‘equals’ and change it to ‘not equals’.

  5. Click on the second ‘value’ and enter ‘pdf’.

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 ‘More 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 mean:

    • this document:  Specify which document to convert. Select the option and make sure ‘Current Item’ is selected.
    • this url: Specify the location the converted file will be written to. The following options are available:
      • Leave it empty: When no value is specified then the converted document is written to the same folder as where the source file is located.
      • 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 Important Documents/Approved PDF Files.
      • 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’ll leave it empty to make sure we use the same name as the original document.
    • include / exclude meta data: In case of sensitive documents we may want to strip any custom SharePoint columns from the file. Assuming that our document library contains a column ‘Yearly sales forecast’, 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 to PDF Format’.

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

    • From the ‘List’ dropdown select ‘Important Documents’.
    • Click the ‘Add’ button and set the field to ‘Approval Status’ and the value to ‘Approved’. Click OK. Please note that things have changed in SharePoint 2010, it is no longer possible to set the value of the ‘Approved’ field. For details and a workaround see this thread on our forums.
    • In the ‘Find the List Item’ area set the Field to ‘Important Documents:ID’.
    • Click the fx button next to ‘Value’, specify ‘Workflow Data’ as the Source and set the Field to ‘Variable: List Item ID’. Click OK.
    • Click ‘OK’ again to return to the Workflow Designer. It should look like the image below.

workflow2

Click the ‘Finish’ button to activate the workflow.

Testing the work flow

Testing the workflow is simple: create or upload an MS-Word file to the ‘Confidential Proposals’ folder, 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.

workflow3

Once the workflow has completed, you should see the PDF version of the document in the ‘Approved PDF Files’ folder.

workflow4

If an error occurs during the execution of the workflow then have a look at the following:

  1. Check the messages on the workflow status screen.

  2. Look in the Windows Event log.

  3. Look in the SharePoint trace log.

Labels: Articles, PDF Converter, Workflow

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