Using the PDF Converter for SharePoint from Your Own Code

Clavin Fernandes

Clavin Fernandes

Related Products

PDF Converter

PDF Converter


When developing a product such as the PDF Converter for SharePoint you start with a fair idea of how customers want to use it and what they may want to use it for. It is not until a product has been selling for a while before you grasp what the market really wants.

One of the first changes we made to the product was making it workflow enabled to allow it to be used from products such as SharePoint Designer and the ever popular Nintex Workflow. This basically cut the number of helpdesk tickets by 75%. Recently, however, we have been getting an increasing number of requests from people who want to use the product from their own source code. Although we never imagined anyone ever wanting to do this, we have decided to document (part of) the public interface to our product.

This post describes the public interface of the PDF Converter and provides a simple code sample illustrating how it can be invoked from your own custom .net code. Please consider reading the following related blog postings as well as they provide an alternative approach for using the PDF Converter from your own code:

The external interface is defined in the following class: Muhimbi.SharePoint.DocumentConverter.PDF.DocumentConverter.

The two main methods for converting documents are:

  • DataTable ConvertToPdf(SPFile sourceFile, SPFolder destinationFolder, string destinationFileName, bool copyMetadata)
  • DataTable ConvertToPdf(SPFolder sourceFolder, SPFolder destinationFolder, bool includeSubFolders, bool copyMetadata)

The interface largely describes itself. The first method can be used for converting a single file whereas the second method is used to convert entire folders.

Each method returns its results in a DataTable with a single row for each converted file. Each row’s fields can be accessed by name as defined in the following public constants on the DocumentConverter class.

  • COLUMN_FILENAME = "Filename";
  • COLUMN_RESULT = "Result";
  • COLUMN_MESSAGE = "Message";

As always, the best way to show how it all works is by example. The code at the end of this article generates the following screen


In order to use the code sample below, follow these steps:

  1. Download and install the Muhimbi PDF Converter for SharePoint.

  2. Copy the code below into a file named sample.aspx or download it here.

  3. Place the file in 12\TEMPLATE\LAYOUTS\Muhimbi.PDFConverter (or anywhere else you want).

  4. Access it at http://YOUR_SERVER/SOME_SITE/_layouts/Muhimbi.PDFConverter/sample.aspx.

  5. Enter valid values in the text boxes and click ‘Convert’.

Labels: Articles, PDF Converter


Clavin Fernandes

Clavin Fernandes

Developer Relations and Support Services @ PSPDFKit

Clavin Fernandes is a Microsoft Business Applications MVP and works in Developer Relations and Support Services for PSPDFKit.

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