One of the more popular features of the Muhimbi PDF Converter for SharePoint is the ability to execute PDF conversion and manipulation activities as part of a SharePoint Designer Workflow or Nintex Workflow. Quite often these workflows are as basic as ‘when a document is created in location A, convert it to PDF in location B’. However, as the PDF Converter has been deployed on thousands of servers all over the world, we see more complex workflows as well, especially when part of a larger automated business process. (Have a look at these case studies).
Muhimbi’s workflow activities are designed to be chained together. This means that the output generated by one workflow activity (e.g. a PDF file) can be passed into a second workflow activity for further processing (e.g. watermarking). This allows the common scenario to convert a typical MS-Office file to PDF, Watermark it with meta-data and then Secure it using our PDF security and encryption facilities.
Although there are subtle differences between the various workflow environments (SharePoint Designer, Nintex workflow 2007, 2010 and 2013), the principle is the same between all of them. By default our workflow activities act on the file that triggered the workflow, however each activity accepts optional List ID and Item ID variables to act on a different file. Once a file has been processed it is written to whatever path / file name was specified. The List ID and Item ID of that processed file are optionally stored in workflow variables that can be passed into a secondary workflow activity as the Source List ID and List Item ID.
Even though this mechanism is easy to understand, there are a few differences between Nintex Workflow versions and workflow activities, especially where it comes to workflow variable data types. A summary can be found below:
List ID: This is the same for all Muhimbi workflow activities and SharePoint versions. The data type is always string / text and contains the GUID that identifies the associated list / library.
Item ID (SharePoint 2007): On this platform use the type named ‘List Item ID’ for the workflow variable.
Item ID (SharePoint 2010/13): On this platform use the type named ‘Integer’ for the workflow variable.
As always, there is one exception to the rule, which is the Convert Document Workflow Action. This action allows files to be converted to file formats other than just PDF. The Item ID returned by this workflow action is always of type string / text. The reason for this is that a future version of our software may return multiple, comma separated, values for certain file types. In order to pass the Item ID generated into another workflow action, its type may need to be converted first using the Convert Value workflow action.
Example - Item ID type is Integer / List Item ID
Let’s illustrate the concept of combining multiple workflow actions using a simple Nintex Workflow example. The steps described below show how to convert a document to PDF and then watermark it. In this case we use the Convert to PDF Workflow Action so the Item ID will be stored in a workflow variable of type Integer.
The screenshots show Nintex Workflow 2010 in action, but the steps are identical in Nintex Workflow 2013. The only difference when using Nintex Workflow 2007 is that the data type for the Item ID is List Item ID rather than Integer.
The steps for creating the workflow are as follows:
Create a blank Nintex Workflow.
Open the Workflow Settings / Variables screen using the Ribbon.
Create a workflow variable named Generated PDF Item ID of type Integer.
Create a workflow variable named Generated PDF List ID of type Single Line of Text.
Close the Workflow Variables window and add the Muhimbi Convert file to PDF activity to the workflow and double click it to open the configuration window.
Specify the appropriate workflow variables as per the screenshot below, do not change any of the other settings. As a result the PDF file will be generated in the same folder as the source file.
Save and close the workflow activity and add the Watermark PDF activity just below the Convert file to PDF activity. Double click it to open the configuration window. Accept the default settings except for the following:
Content: This is a Watermark
Font Size: 18
Layer: Foreground
Height: 300
Width: 300
Source List ID: Generated PDF List ID
Source List Item: Generated PDF Item ID
Save and close the workflow activity.
Publish the workflow and execute it on a simple MS-Word file. After a few seconds a watermarked PDF file should be present in the same location as the MS-Word file.
If you wish to carry out further steps, e.g. secure the PDF file, then you can re-use the Generated PDF List ID and Generated PDF Item ID variables providing the same file name and path is used by all activities
The previous example uses the Convert File to PDF workflow activity, which uses the default data types for workflow variables. In the following example we’ll show how to use the Convert Document workflow activity, which returns an Item ID of type string / text, and pass that into the Watermarking Activity.
The steps for creating the workflow are as follows:
Create a blank Nintex Workflow.
Open the Workflow Settings / Variables screen using the Ribbon.
Create a workflow variable named Generated PDF Item ID (Integer) of type Integer.
Create a workflow variable named Generated PDF Item ID of type Single Line of Text.
Create a workflow variable named Generated PDF List ID of type Single Line of Text.
Close the Workflow Variables window and add the Muhimbi Convert Document activity to the workflow and double click it to open the configuration window.
Specify the appropriate workflow variables as per the screenshot below, do not change any of the other settings. As a result the PDF file will be generated in the same folder as the source file.
Save and close the workflow activity and add the Convert Value activity just below the Convert Document activity. Double click it to open the configuration window and configure it as per the following screenshot.
Save and close the workflow activity and add the Watermark PDF activity just below the Convert Value activity. Double click it to open the configuration window. Accept the default settings except for the following:
Content: This is a Watermark
Font Size: 18
Layer: Foreground
Height: 300
Width: 300
Source List ID: Generated PDF List ID
Source List Item: Generated PDF Item ID (Integer)
Save and close the workflow activity.
Publish the workflow and execute it on a simple MS-Word file. After a few seconds a watermarked PDF file should be present in the same location as the MS-Word file.
If you wish to carry out further steps, e.g. secure the PDF file, then you can re-use the Generated PDF List ID and Generated PDF Item ID (Integer) variables providing the same file name and path is used by all activities
Muhimbi’s range of server based PDF Conversion products has had the ability to convert AutoCAD (DXF and DWG) files for quite some time. It works really well, but as it doesn’t rely on AutoCAD being present it uses custom code to carry out the conversion. As the AutoCAD format is constantly evolving, certain features are not supported (e.g. 3D solids, bitmaps or embedded OLE objects).
The AutoCAD converter that comes with our software is improved all the time, however if you need a certain unsupported feature right now, and cannot wait, then you may want to consider adding a third party AutoCAD plug-in to your copy of the Muhimbi PDF Converter as described below. As a result you will be able to achieve perfect conversion fidelity when converting DXF and DWG files from your Java, PHP, Ruby, .NET or SharePoint solution.
The easiest way to add third party plug-ins to the Muhimbi PDF Converter is to make use of our generic Command Line Converter, which allows any third party product that can be controlled via the command line to be fully integrated with the PDF Converter, in a completely transparent manner, without losing any of the PDF Converter’s other features such as watermarking, merging and encryption.
Some of our existing customers already use this approach using either VisConvert (part of Siemens Teamcenter) or an affordable third party utility named Any DWG to PDF Converter (US$ 150 per server, contact us for a discount code). A Google search reveals other command line based DWG to PDF converters, but a quick evaluation reveals that the quality of those is questionable at best.
In the example below we’ll show how to integrate AnyDWG into the Muhimbi PDF Converter.
Download and install Any DWG to PDF Converter Pro. In this example we assume it is installed in the default location.
Open Muhimbi.DocumentConverter.Service.exe.config in your favourite text editor (notepad works as well). A handy shortcut to the configuration / installation folder that holds this config file can be found in the Muhimbi Document Converter Windows Start Menu group.
Search for “CAD based formats” and remove or comment out the entire XML element.
Search for “CommandLineConverter” and replace it with the following, don’t forget to remove the XML comments (<!--…. –>)
If you have any custom SHX fonts then please place these in the Fonts folder under the AnyDWG installation directory. On our test system that folder is located at C:\Program Files (x86)\Any DWG to PDF Converter Pro\Fonts.
Restart the Muhimbi Document Converter Service using the Services Management Console or using the command prompt:
Net stop "Muhimbi Document Converter Service" Net start "Muhimbi Document Converter Service"
Validate the converters as described here and check that CAD Converter (CL) validates.
For more details about configuring 3rd party converters see this blog post.
Although AnyDWG integrates seamlessly with the Muhimbi PDF Converter, any CAD settings in our config file or Web Services based Object Model are ignored. Fear not as in case of AnyDWG most of the options can be added to the command line.
Listed below is an abstract of the AnyDWG help file that deals with command line options:
/Hide
Hide the result window and the message dialog (Always specify this switch)
/PDFWidth
PDF width in millimeters, e.g. /PDFWidth 210
/PDFHeight
PDF height in millimeters, e.g. /PDFHeight 297
/DisableAutoSize
Disable the "Automatically adjust the page size based on the drawing" option
/PDFMargin
Margin in millimeters, e.g. /PDFMargin 5
/PDFColor
Output color, available values: TrueColors, GrayScale, BlackWhite.
TrueColors: True Colors
GrayScale: Gray-scale
BlackWhite: Black/White
For example: /PDFColor TrueColors
/PDFQuality
PDF quality, available values: Normal, Medium, High, Highest. e.g. /PDFQuality Highest
/OutMode
Output mode option, available values: ByLayout, ByDrawing, AlltoOne.
ByLayout: One PDF per layout ByDrawing: One PDF per drawing AlltoOne: All drawings combined into on PDF file
For example: /OutMode ByLayout
/OutLayout
Output layout, available values: All, Model, Paper, Active, ByName:layoutname.
All: All layouts
Model: Model space Paper: All paper spaces Active: Last active layout ByName: Ouput by layout name
For example:
/OutLayout Paper or /OutLayout ByName:Layout1
/OutArea
Output area, available values: ZoomExtents, LastSavedView.
ZoomExtents: Zoom extents LastSavedView: Last saved view of drawing
For example: /OutArea ZoomExtents
/LineWidth
Line width, available values: Default, CADDefault, ByColor.
Default: Default width CADDefault: Use the CAD default line weight ByColor: Custom by color
For example: /LineWidth CADDefault
/LineScale
Set the line width scale, e.g. /LineScale 4
/PDFAuthor
Set the PDF author, e.g. /PDFAuthor author name
/PDFTitle
Set the PDF title, e.g. /PDFTitle title
/PDFSubject
Set the PDF subject, e.g. /PDFSubject subject
/PDFKeyword
Set the PDF keywords, e.g. /PDFKeyword keywords1, keywords2
/DisablePDFBookmark
Disable the "Create PDF bookmark" option
/DisableFillTTF
Disable the "Fill TTF font in the drawing" option
/DisableOutImage
Disable the "Export Image/Excel file in the drawing" option
Any questions? Leave a comment below or contact us.
We are happy to announce a major new release of the popular Muhimbi PDF Converter for SharePoint, version 7.0. The main new features are support for SharePoint 2013 and Nintex Workflow 2013, but a large number of other additions and improvements have been made as well. Rest assured that the product continues to run great on SharePoint 2007 and 2010.
Overhaul of the MSG (email) converter with improved formatting and support for SMIME and Clear Text signed emails.
For those not familiar with the product, the PDF Converter for SharePoint is a lightweight solution that allows end-users to watermark, merge, split, secure and convert common document types - including InfoPath, AutoCAD, MSG (email) MS-Office, HTML and images - to PDF as well as other formats from within SharePoint using a friendly user interface, workflows or a web service call without the need to install any client side software or Adobe Acrobat. It integrates at a deep level with SharePoint and leverages facilities such as the Audit log, Nintex Workflow, localisation, security and tracing. It runs on SharePoint 2007, 2010 & 2013 and is available in English, German, Dutch, French, Traditional Chinese and Japanese. For detailed information check out the product page.
In addition to the changes listed above, some of the main changes and additions in the new version are as follows:
1778
CAD
Improvement
AutoCAD Conversion - Empty layout not properly detected
We are happy to announce a major new release of the popular Muhimbi PDF Converter Services, version 7.0. The main new features are support for Font Embedding, Changing PDF Versions, Support for PDF/A2b and Specifying PDF Viewer Preferences, but we have also added a lot of fixes, improvements, documentation and examples for Java, PHP and Ruby.
The list of new features and improvements is considerable but the main ones are as follows:
Overhaul of the MSG (email) converter with improved formatting and support for SMIME and Clear Text signed emails.
A quick introduction for those not familiar with the product: The Muhimbi PDF Converter Services is an ‘on premises’ server based SDK that allows software developers to convert typical Office files to PDF format using a robust, scalable but friendly Web Services interface from Java, .NET, Ruby & PHP based solutions. It supports a large number of file types including MS-Office and ODF file formats as well as HTML, MSG (email) AutoCAD and Image based files and is used by some of the largest organisations in the world for mission critical document conversions. In addition to converting documents the product ships with a sophisticated watermarking engine, PDF Splitting and Merging facilities and the ability to secure PDF files. A separate SharePoint specific version is available as well.
In addition to the changes listed above, some of the main changes and additions in the new version are as follows:
1778
CAD
Improvement
AutoCAD Conversion - Empty layout not properly detected
In this article we explain how to use Ruby to convert MS-Word, Excel, PowerPoint, HTML and other common file formats to PDF as well as to other formats. Read on to learn more about the Muhimbi PDF Converter and how it can assist with the Conversion, Merging, Watermarking, Splitting and Securing of documents.
For those not familiar with the product, the Muhimbi PDF Converter Services is a server based SDK that allows software developers to convert and manipulate typical Office files, including MS-Word, Excel, PowerPoint, Visio, Publisher, AutoCAD, HTML, emails and InfoPath, to PDF and other formats using a robust, scalable but friendly Web Services interface from Java, PHP, Ruby and .NET based solutions. If you have any questions or need more information then please let us know.
Installing the base ROR environment
If you are reading this then you probably already have a full ROR environment set up. If that is the case then please take into account that this example has been tested with Ruby 1.8.7-p370 and Rails 3.2.12. You may want to use RVM to select the exact same Ruby version as the soap4r gem used in this example may not be compatible with all ruby versions.
If you don’t have a full Rails environment installed then you may want to follow the instructions below to install it. For the sake of this example we used Ubuntu 12.10.
Download and Install Ubuntu 12.10. We set it up to run inside Hyper-V, but that is naturally not a requirement.
Install Ruby and Rails as described here. However, rather than using the ‘rvm install 1.9.3’ command use ‘rvm install ruby-1.8.7-p370’ and set that to the default using ‘rvm use ruby-1.8.7-p370 –default’.
When deploying to a clean Ubuntu 12.10 system the ExecJS dependency is missing. The easiest way to install this is to issue the following command: sudo apt-get install nodejs
That is it as far as the base ROR environment is concerned. You may want to consider installing a decent text editor. For testing purposes we use Sublime-Text.
Creating the Rails application
The Muhimbi PDF Converter exposes a comprehensive API via a standards based Web Services interface (Full Documentation). A number of Web Service frameworks are available for Ruby (Savon, , Handsoap), but in this example we use Soap4R to pre-generate Ruby proxies as it is simple, and it works.
In the example below we will create a basic PDF Conversion Rails application. If you are looking to add PDF Conversion to an existing Rails application then I am sure you’ll know how to modify the various steps.
Use a terminal application of your choice to navigate to the location where you wish to create the Rails application. We use ~Sites.
Execute the following command to create the skeleton for the application:
rails new MuhimbiPDFConverter –O
Navigate to MuhimbiPDFConverter, edit Gemfile using a text editor of your choice and add the following line:
gem 'soap4r'
Install bundler as follows:
gem install bundler
Execute the following command to pull in the applicable gems (Make sure you are still in the MuhimbiPDFConverter directory)
bundle install
Generating proxies
The quickest way (also from a performance perspective) to interact with a Web Service is to generate proxy classes. This can be achieved easily using soap4r, which has already been added to the application as described above.
Before we can generate the proxies we need to make sure that the Muhimbi Conversion Service has been installed and is running (Yes, this requires one or more Windows Based Servers. Sorry Linux/Apple experts, there is just no way to achieve a decent conversion fidelity on other platforms. Rest assured that your Ruby application can continue to run on non-Windows systems).
Open Muhimbi.DocumentConverter.Service.exe.config in your favourite text editor (notepad works as well). A handy shortcut to the configuration / installation folder can be found in the Windows Start Menu Group.
Search for baseAddress and change localhost to the DNS name or IP address of the server running the Conversion Service.
Restart the Conversion Service as follows:
Net stop "Muhimbi Document Converter Service"
Net start "Muhimbi Document Converter Service"
Back on your Ruby system carry out the following steps to generate the proxies:
Navigate to MuhimbiPDFConverter/lib
Execute the following command. Please replace localhost with the name or ip address of the server that runs the Muhimbi PDF Converter Service.
bundle exec wsdl2ruby.rb --wsdl http://localhost:41734/Muhimbi.DocumentConverter.WebService/?wsdl --type client
This generates four new files and places them in the lib folder. Note that the generated property and method names follow Ruby’s naming convention and not the convention used in the Muhimbi Developer guide. This mainly impacts the capitalisation of the first letters.
Implementing the sample
All prerequisites are in place. Let’s add some code to tie it all together. If you prefer you can download the full example, including generated proxies from our website.
Start by generating a controller where the form will be posted to:
rails generate controller home upload_file
Delete the home page that comes with every new Rails application (Execute in the MuhimbiPDFConverter folder)
rm public/index.html
If you are using Sublime-Text then this is the moment to execute ‘subl .’ to open the text editor and display the entire folder structure.
Edit config/routes.rb and after the following line
get "home/upload_file"
Add
post "home/upload_file" root :to => 'home#upload_file'
Edit app/views/home/upload_file.html.erb and add the following HTML
<formmethod="post"enctype="multipart/form-data">
<br/>
<labelfor="file">Document:</label>
<inputtype="file"name="file"id="file"/>
<br/>
<labelfor="outputFormat">Output format:</label>
<selectname="outputFormat"id="outputFormat">
<optionvalue="PDF">PDF</option>
<optionvalue="XPS">XPS</option>
<optionvalue="DOCX">DOCX</option>
<optionvalue="DOC">DOC</option>
<optionvalue="ODT">ODT</option>
<optionvalue="RTF">RTF</option>
<optionvalue="TXT">TXT</option>
<optionvalue="MHT">MHT</option>
<optionvalue="HTML">HTML</option>
<optionvalue="XML">XML</option>
<optionvalue="XLS">XLS</option>
<optionvalue="XLSX">XLSX</option>
<optionvalue="CSV">CSV</option>
<optionvalue="ODS">ODS</option>
<optionvalue="PPT">PPT</option>
<optionvalue="PPTX">PPTX</option>
<optionvalue="ODP">ODP</option>
<optionvalue="PPS">PPS</option>
<optionvalue="PPSX">PPSX</option>
</select>
<br/>
<inputtype="submit"name="submit"value="Convert"/>
</form>
6. Edit app/controllers/home_controller.rb and replace it with the following:
Please update the url variable with the IP address or DNS name of the server that runs the Muhimbi Conversion Service.
This is a minimum code sample to illustrate how simple it is to convert a file. Our full Developer Guide contains the entire object model, including details about how to Convert, Watermark, Split, Merge and Secure files.
That is it. Start the Rails server as follows:
rails s
Open a web browser and point it to http://localhost:3000. If the browser is opened on a system other than the one that runs the Rails application then replace localhost with the DNS name or IP number of that server.
The sample application is very simple. Select a file to convert (See this list of supported file types, please make sure that the file extension matches its format). Then select the Output format, e.g. PDF, and click the Convert button.
SOAP / Web Service Debugging
The Muhimbi Conversion Service is a Windows Service based on the Microsoft Windows Communication Foundation (WCF) framework. This comprehensive framework is used to expose a standards based Web Services interface that can be consumed by many different platforms including .NET, Java, PHP, SAP, Ruby, Documentum and many others.
Even though WCF Web Services are standards based, standards are not interpreted the same by everyone so from time to time you may need to do some troubleshooting when programming against the PDF Converter Web Service, especially from non-Microsoft platforms.
One of our key principles is that no one is left behind when it comes to our customers and their SharePoint versions. No matter how old your version of SharePoint is, we will continue to support it by making sure every new feature, where feasible, is made available on all SharePoint versions.
When the PDF Converter for SharePoint was first released, SharePoint 2007 was state of the art. Over the years SharePoint 2010 adoption has grown as expected, but a surprising number of organisations still use older SharePoint 2007 versions. We will not leave them behind.
Naturally we have to look at the future as well, so ever since SharePoint 2013 was released our developers have been working flat out to make sure we provide a first class experience, adopt the SharePoint 2013 look and feel and naturally integrate with other 3rd party SharePoint 2013 solutions such as the brilliant Nintex Workflow.
After all this effort I am happy to announce that as of version 7.0 SharePoint 2013 is fully supported. It can be download from the generic download page. The download contains the SP2007, 2010 and 2013 versions, the installer will automatically deploy the correct version for your environment.