As of version 7.3, the Muhimbi PDF Converter for SharePoint provides native support for the K2 workflow engine using K2’s SmartObjects technology.
K2 blackpearl comes with a number of different workflow editors. The majority of K2 workflow designers will be most familiar with K2 Studio, but Visual Studio as well as web based workflow editors are also available. This post describes how to create a basic workflow to convert documents to PDF (as well as other formats) using a basic K2 Designer workflow. Similar tutorials are available for K2 Studio, Nintex Workflow as well as SharePoint Designer.
A note on licensing the Muhimbi PDF Converter for SharePoint when used in combination with K2 blackpearl. Muhimbi’s licensing model is very simple, if a server runs Muhimbi Software in any way shape or form, then it requires a server license. Even though the PDF Conversion engine may be installed on a non-K2 server, all K2 Servers run our SmartObjects and therefore require a license. For details, in plain English, about how Muhimbi’s software is licensed, see this Knowledge Base Article .
A version of this blog post can also be found in the User Guide, Chapter 5.3.
Before creating the workflow, please make sure Muhimbi’s K2 Integration facilities have been deployed as described in the Administration Guide, Appendix – Deploying K2 Integration facilities. Basic knowledge of creating workflows in K2 Designer, and having the privileges to do so, is assumed.
This tutorial was written for SharePoint 2010. Muhimbi’s PDF Converter for SharePoint integrates equally well with SharePoint 2007 & 2013, but the actual steps for creating K2 workflows differ in each SharePoint version, particularly in SharePoint 2013. Please refer to K2’s tutorials and documentation for your particular environment.
The Muhimbi PDF Converter for SharePoint is exposed in K2 as a series of SmartObjects. By default SmartObjects are not available for use in the K2 Designer, an administrator must add them. The steps to do so are as follows:
- In the relevant Site Collection open K2 Site Settings. If this option is not available then please make sure the relevant K2 Designer SharePoint Features have been enabled at the Site Collections and Site Level.
- Under K2 Designer for SharePoint Management select Configure SmartObject Access.
- If Muhimbi Document Converter for SharePoint is not already present in the list, click Add new item.
- In the Add SmartObject Window open the Muhimbi Folder and tick the box next to Muhimbi Document Converter for SharePoint.
- Under Advanced, select the option to Automatically create all methods and click Finish to complete the operation.
Creating the workflow
In this tutorial we will create a basic workflow to convert files to PDF and associate the workflow with a Document Library. This workflow is similar to the one we built using K2 Studio, but as K2 Designer works slightly differently we have to jump though some additional hoops.
Create a new Document Library named Tutorial2 in a site collection of your choice.
In the Tutorial2 Library, select the Library ribbon tab and click K2 Workflow.
In the Welcome dialog, assuming it is displayed by default, select the Create a new workflow option.
Name the workflow Tutorial2, accept the default settings and, as this tutorial does not need any of the other Wizard screens, click Finish.
In order for a SmartObject to be able to convert a document a number of parameters are needed. In K2 Studio these parameters ( EventDetails.ListItemRelativeURL and EventDetails.SiteURL) are available from the Context Browser, but in K2 Designer we have to manually create them. The steps are as follows:
In K2 Designer select File / Configure Workflow Settings / Data Fields.
Click the Add button and specify SiteURL as the name.
Although we could use a complex regular expression to determine this value at run time, let’s keep it simple and specify the URL to the site collection as the Default Value. In our case http://portal.denallix.com/ (including the trailing slash!).
Click OK and add another Data Field named ListItemRelativeURL.
Accept the default settings, click OK and OK again to close the Data Fields dialog.
Hover the mouse over the Start line in the designer, a button will appear, click it and confirm the question to add a new step.
Select the Workflow Steps tab in the ribbon and drag the Set Data Fields activity onto the newly created step.
We already know the SiteURL, but we need to calculate the value of the ListItemRelativeURL by taking Document Context.Document URL and removing the SiteURL from the beginning. This is not difficult, just a bit fiddly.
- In the Context Browser open Inline Functions / Text and drag the Mid(Text,Start) on top of ListItemRelativeURL.
- In the Editor that is opened drag and drop Document Context / Document URL onto the Text field.
- Drag and drop Inline Functions / Text / Length onto the Start field.
- In the Editor that is opened drag and drop Data Fields / Site URL onto the Text field.
- Click OK in the various Edit windows and verify that the Set Data Fields Wizard looks as follows.
- Click Finish to continue.
6. With the required data fields in place, select the SmartObjects tab and drag the Convert Document smart object onto the empty workflow container and fill out the fields:
- Source URL: The URL of the document to convert. The syntax is as per this post, please make sure that the web application name (http://yourwebapp) IS NOT included in the URL. In this tutorial we use the previously calculated data field by dragging Context Browser / Data Fields / ListItemRelativeURL onto the SourceURL field.
- SharePoint Site URL: Similar to K2’s other SharePoint SmartObjects and Wizards, you will need to specify the URL of the site collection the workflow is acting on. The steps are identical to specifying the Source Url, just select SiteURL from Data Fields.
- Destination URL: The optional path and file name of where the converted file will be written to. When left empty the converted file will be saved in the same folder as the source file using the same file name, just with the extension of the specified file type. This field uses the same format and rules as the Source URL field. In this tutorial we’ll leave this field empty. For details on what locations documents can be converted to and how to specify paths, please see here.
- File Type: Theextension of the file type we are converting to. In this case assign the PDF value.
- Include Meta-Data: In this example we want to copy all meta-data available on the source document to the converted document. Please accept the default Yes value
- Optional Parameters: The Muhimbi PDF Converter is a very powerful product that allows many different settings to be specified. It is not feasible to make all of these settings available via individual field mappings, which is why we have developed a special XML syntax to populate these parameters. For this tutorial leave this field empty, you can find more details in this blog post. Please keep in mind that K2 Designer does not provide support for entering line breaks in SmartObject mappings so we recommend creating this XML in a regular code editor (or Notepad) and copy it from there into the Optional Parameters field.
7. Click Next followed by Finish, this tutorial does not use the return properties. 8. From the File option in the ribbon select the Deploy option. Click Next (twice) followed by Finish.
Testing the Workflow
Verify the workflow is working correctly by uploading an MS-Word file (or Excel, MSG, TIFF, PowerPoint or any of the many other formats we support) into the Tutorial2 Document Library and manually starting the workflow on the file. To manually start a workflow, in SharePoint open the context menu for the relevant file and select the ‘Workflows’ option.
If all has been configured well, and the workflow has been created correctly then - within a few seconds - a PDF copy of the source file should appear in the Tutorial2 library.
If the workflow does not work correctly then either use the Process Overview report in K2 Workspace to drill down into the workflow, or - and this is what we like to do - insert a Send E-mail step between the Set Data Fields and Convert Document steps, and populate the email with the content of the various data fields. By sending the email to Context Browser / Workflow Context / Originator E-mail it is easy to verify that the workflow is actually running and get an overview of what is going on without having to dive into the K2 Workspace Reports.
For more details on how to create SharePoint Workflows using K2 blackpearl see the K2 Website. A fully installed Virtual Machine (Excluding the Muhimbi PDF Converter for SharePoint) is available as well.
Labels: Articles, K2, pdf, PDF Converter, Workflow