Subscribe to News feed

Using Windows Azure to convert documents to PDF format – Part 1

Posted at: 20:15 on 28 February 2011 by Muhimbi

Windows Azure LogoToday’s article is a guest post by John Dent from BlueHub Solutions, who have been using our popular PDF Conversion Services to convert documents in MS-Office, AutoCAD, HTML, Image and many other formats to PDF from a Windows Azure based solution.

Over the next few weeks we’ll publish a number of posts related to using our software in combination with the Azure platform, so make sure you subscribe to our RSS feed or follow us on Twitter.

The following posts are part of this series:

  1. Using Windows Azure in combination with an internet facing web service. (This post)
  2. Using Windows Azure in combination with a web service hosted inside an organisation’s private network.
  3. Using Windows Azure in combination with a 3rd party web service hosted inside a custom Azure VM. (Coming soon)

If you have any questions then please contact us, we are always happy to talk to our customers. For now I’ll hand you over to John.


This post details how I created a very basic Windows Azure web application which colleagues in my company could use to convert documents to PDF format quickly and easily. This application is built around the Muhimbi PDF Conversion web service.

I work for BlueHub Solutions, a small software development consultancy in England, and I’m noticing that most of our new solutions these days seem to relate to rich Silverlight front-ends talking to hosted web applications via WCF using SQL Server as the back-end, and could thus loosely be considered cloud applications. I’m certainly a big fan of the theory of cloud computing, but had never really taken the time to look into Windows Azure in depth. Now that I have I’m very impressed, and we’ll certainly be aiming to use it in anger for our next client project.

As a starting point I installed the Muhimbi PDF Conversion Services on an Internet facing server, such that our Azure web application will provide a basic user interface onto this service. In subsequent blog posts I will show how these services can be hosted on your internal network rather than the Internet, or hosted within a VPC hosted in Azure.

If you are following along you will need a Windows Azure account, you can create one for free, or if you have an MSDN subscription you can also access associated Azure benefits from the same link.


Component and tools installation

Before we begin we need to install the Windows Azure SDK, the Windows Azure Tools for Microsoft Visual Studio 2010 and the Muhimbi PDF Converter Services.

Download and install the SDK (you just need the SDK and not the other supporting files). After installing the SDK install the Windows Azure Tools for Microsoft Visual Studio 2010. Unfortunately the Azure tools are no longer updated for Visual Studio 2008, but an optional copy of VS2010 is included in the Azure Tools download.

Install the PDF Converter Services on an internet facing server as described in Chapter 2 of the product’s Administration Guide. As you will be requesting the WSDL remotely, edit Muhimbi.DocumentConverter.Service.exe.config, change the baseAddress to the public URL the service will be available from and restart the Muhimbi Service.

Note that I initially didn’t install the copy of SQLExpress that comes with Visual Studio 2010, which resulted in all kind of interesting messages including “failed to initialize windows azure storage emulator”. After installing SQLExpress this message went away. If you really don’t want to install SQLExpress locally then you can skip the local test run and upload the package straight to Azure after the setting up Azure storage step.


Project Creation

Having installed the SDK and tools, open a new instance of Visual Studio 2010 and click the New Project command. You should see a new section called Cloud.


So far so good – not too many options here, so select Windows Azure Project. I called mine WAP1.

On the next screen we’ll select the type of application we are going to create, for this example I am going to create a simple C# ASP.Net web application as shown below (though of course you may prefer a different language).


This interface is a little awkward, you need to click the right-hand arrow to move the ASP.NET Web Role across, and then you need to click the pencil icon to rename the role (in my case I named it TestWebsite).

Once created the base solution should look something like this:



Note that depending on the version of the .Net Framework selected some of these items may not be present in your solution. A number of these files are unnecessary, so let’s clean up a little and delete the following (if present):

  • About.aspx,
  • Default.aspx
  • Site.master
  • Style folder
  • Account folder

The resulting solution should look a little like this



Creating the web application interface

I’m going to write a simple web form that allows a user to upload a document, convert it to PDF and then return the generated PDF file to the browser.

To do this, I created a new web form called Default.aspx (without a master page). I chose this name because, like IIS, Azure will automatically load this file in the absence of a more specific URL. Of course there was already a Default.aspx in the project before, which I deleted as I prefer to start from scratch.

This page simply needs a header, a file upload control, and a Convert button. Here’s the resultant ASP.Net mark-up, which you can paste straight into Default.aspx.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestWebsite.Default" %>
<html xmlns="">
<head id="Head1" runat="server">
    <title>HTML to PDF Converter</title>
<body style="background-color:#03899C; font-family:Calibri;">
    <form id="form1" runat="server">
    <h1>File to PDF Converter</h1>
    <td><asp:Label ID="Label1" Text="File : " runat="server" /></td>
    <td><asp:FileUpload ID="FileUploadControl" runat="server" /> </td>    </tr><tr>
    <td><asp:Button ID="Button1" runat="server" Text="Convert" onclick="Convert_Click" /></td>


Coding the web application logic

The next step is to add a web reference to the Muhimbi PDF converter web service. In my case I am adding it as a Web Reference by right clicking on References and then selecting Add Web Reference... As the Muhimbi PDF Conversion service is a WCF based service you should also be able to add it as a Service Reference, but I haven’t tested that particular scenario. (Sample code for using Service References is available here)



I then typed the URL of the Internet facing web service (e.g. http://YourName:41734/Muhimbi.DocumentConverter.WebService/) into the top box, and waited for it to download the WSDL information. I entered a web reference name of DCS and clicked the Add Reference button.



Now it’s time to add the code to our project, which will:

  • Set up a link to the Azure file storage
  • Turn the file into binary byte data for transport
  • Open a connection to the Muhimbi web service
  • Set the minimum file options for the conversion process
  • Call the service method
  • Turn the returned data back into a file
  • Redirect the user to the PDF document.

If you wish you can amend the code and skip the step that writes the PDF to Azure storage and instead return the PDF directly to the user.


To achieve this we’ll need to edit Default.aspx.cs :

First we need to add the following references to the top of the file :

using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using System.IO;
using TestWebsite.DCS;  // (Providing you use the same names as we did)

Then add the following method to the class :

protected void Convert_Click(object sender, EventArgs e)
     if (FileUploadControl.HasFile)
         StorageCredentialsAccountAndKey account = new StorageCredentialsAccountAndKey("AccountName", "PrimaryAccessKey");
         CloudStorageAccount storageAccount = new CloudStorageAccount(account, false);
         CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
         CloudBlobContainer files = cloudBlobClient.GetContainerReference("files");
         files.BeginCreateIfNotExist(null, null);
         BlobContainerPermissions perm = new BlobContainerPermissions();
         perm.PublicAccess = BlobContainerPublicAccessType.Container;
         string filename = Path.GetFileName(FileUploadControl.FileName);
         // ** Open the connection to the web service
         DCS.DocumentConverterService service = new DCS.DocumentConverterService();
         // ** Get the file data
         byte[] sourceFile = FileUploadControl.FileBytes;
         //** Set the absolute minimum open options
         DCS.OpenOptions openOptions = new DCS.OpenOptions();
         openOptions.OriginalFileName = Path.GetFileName(filename);
         openOptions.FileExtension = Path.GetExtension(filename);
         // ** Set the absolute minimum conversion settings.
         DCS.ConversionSettings conversionSettings = new DCS.ConversionSettings();
         conversionSettings.Fidelity = DCS.ConversionFidelities.Full;
         conversionSettings.FidelitySpecified = true;
         conversionSettings.Quality = DCS.ConversionQuality.OptimizeForPrint;
         conversionSettings.QualitySpecified = true;
         conversionSettings.Format = DCS.OutputFormat.PDF;
         conversionSettings.FormatSpecified = true;
         conversionSettings.PDFProfile = PDFProfile.PDF_1_5;
         conversionSettings.PDFProfileSpecified = true;
         // ** Carry out the conversion.
         byte[] convFile = null;
         convFile = service.Convert(sourceFile, openOptions, conversionSettings);
         string newFileName = Path.GetFileNameWithoutExtension(filename) + "." + conversionSettings.Format;

         // ** Save the PDF to Azure storage
         CloudBlob saveloc = files.GetBlobReference("/temp/" + newFileName);
         // ** Redirect them to the pdf.


At this stage, if we run the ASP.Net web project then we should get the following output from Default.aspx. (Note that you may need to set Default.aspx as the start-up page).



Azure Storage

Before we can test the project we need to configure a storage account for the Azure platform, so we have a place to store the PDF files - this is where we will hold our files after they have been converted.

To do this login to your Windows Azure account and click on New Storage Account. This shows the following form:


We need to get our Storage Account Name and our Primary Access key, these are shown on the right hand side of the screen after clicking Create. You then enter these in default.aspx in place of the placeholders on the following line of Default.aspx.cs :

 StorageCredentialsAccountAndKey account = new StorageCredentialsAccountAndKey("AccountName", "PrimaryAccessKey");




We can now test the application. To do this, we re-launch the application and browse to a file that we want to convert. On clicking the Convert button we should be redirected to a PDF copy of that file.


Uploading to Azure

To upload to Azure is relatively simple – we first right click on the Azure project (WAP1) in our solution and click Publish. The following form is displayed:



After this we select Create Service Package Only and click OK. This creates a small package which we can upload to Azure. To do this, we log in to our Azure account and select New Hosted Service.

We’re then prompted to fill out a short wizard to upload your service package. Specifically:

  • We need to enter a name for the service for our reference
  • We need to enter a unique URL that you want to the service to be accessed on (only used in production, not staging).
  • We need to select where in the world you want it to be hosted
  • We select stage or production environments (I selected stage)
  • We need to make sure Start after successful deployment is checked
  • We need to enter a name for this deployment

After doing this we just need to select the package and configuration file from the Debug folder of our Azure project (where it has been built) by browsing locally.


Then we click OK to start uploading and deploying the project – this can take some time, so it could be a good time to get a drink, tidy your desktop, clean out your Inbox, de-worm the dog etc. You may get a warning message during deployment about the fact that you are only using a single instance. For this test it is safe to ignore this warning.

Once this has completed you can highlight the deployment object in the grid and on the right hand side of the screen you will be able to get a link to test the application now hosted on the Windows Azure platform and start converting those files!


Next Steps

I hope to follow up this blog with another showing how to configure Azure Connect so that the Muhimbi web service could be hosted on your LAN rather than the Internet. I also want to explore the new VPC functionality in Windows Azure, which in theory allows you to run full virtual server environments in the cloud. Unfortunately, as these are both Beta features, I’m waiting on approval from Microsoft to be able to access them, a curious process where apparently you are effectively guaranteed to be approved but such approval takes weeks or months to be issued… (Update: It only took 2 days when Muhimbi applied for the beta)


About Me

If you have any comments then please post them below, or feel free to email me at Alternatively you can contact Muhimbi’s support team.

John Dent


Labels: , , , , , ,

Converting AutoCAD (DXF, DWG) files to PDF using the Muhimbi PDF Converter Services

Posted at: 14:49 on 24 February 2011 by Muhimbi

AutoCAD IconAs has been the case for the last few years, development on our range of PDF Conversion products is going full steam ahead. Full details about all the great new features will follow in a future post, for now I want to focus on the new and improved AutoCAD converter included in the latest 5.0 release.

If you are an existing user of our software then you are probably aware that we have provided the ability to convert DWG and DXF files for quite some time as it basically came for free with our Visio converter. Unfortunately Visio does not do a particular great job with most AutoCAD files.

As we are receiving more and more requests for high-end AutoCAD support, we decided to completely overhaul our CAD converter, which is now completely self-contained and no longer relies on external dependencies such as Visio.

The key features and improvements are as follows:

  1. Full 2D and 3D support.
  2. Highly configurable (Output paper size, margins, Layouts / Views to convert)
  3. Automatic and intelligent recoloring of drawings, e.g. Switch background to black, white or any other color without losing visibility of elements that were already using that color. Full Black and White support is available as well.
  4. Conversion of individual Layouts or all Layouts while skipping empty and invalid ones.
  5. Automatic detection of paper orientation.


As the converter is part of our highly scalable PDF Conversion platform, it automatically benefits from all its features including reliability, scalability, watermarking engine, cross platform support, web services based API, PDF security, SharePoint integration, Nintex Workflow integration, Java support, InfoPath attachments, Windows Azure etc.

As they say, a picture is worth a thousand words, so listed below are 3 copies of the same drawing after conversion to PDF, but with different recoloring options.

CAD Sample - White Back


CAD Sample - Black Back


CAD Sample - Black and White

If you prefer you can also use third party CAD converters in combination with the Muhimbi PDF Converter, in case you need support for a feature that is currently not supported by us. For details on how to integrate third party components see this post.


Labels: , , , , ,

SharePoint Audit Suite 2.0 - SharePoint 2010 support, Enriched Audit data

Posted at: 18:08 on 21 February 2011 by Muhimbi

SharePointAuditBoxToday is an exciting day for Muhimbi as we are shipping the second major release of our popular SharePoint Audit Suite.

In these days of WikiLeaks and strict regulatory requirements, it is essential to be able to track who have viewed, added, updated or deleted content in your SharePoint sites. The Muhimbi Audit Suite makes this easier than ever by building on top of SharePoint’s existing auditing abilities and filling in the many gaps and shortcomings associated with Microsoft’s platform.

The main new features are as follows, we’ll publish more detailed posts in the next few days so make sure you follow us on Twitter or subscribe to our newsfeed.

  • SharePoint 2010 Support: In addition to WSS3 and MOSS 2007 we now provide support for SharePoint Foundation 2010 as well as SharePoint Server 2010.
  • Enriched Data: Any Audit data logged by the native SharePoint platform is cryptic at best. Our software translates this information into a format that is much more readable and easier to report on.
  • Additional Audit events: Although the SharePoint platform provides such basic audit events as View and Delete, some events such as Insert are sorely missing. The Muhimbi Audit Suite fills in the gaps by adding new event types and tightening up the support for existing event types. For example our product adds support for tracking views of List Items and Document property screens. 
  • Authentication events: Wouldn’t it be great to track when users log-in to or log-off from a site collection? Now you can, and include it in your fancy audit reports as well.
  • Field changes: It is great to track that a document or item has been updated, but what you really want to know is what fields have changed and what the old and new values are. This information is now logged to the audit logs to make it extremely easy to get an overview of what happened to an item over time.
  • Advanced Querying: Our lightning fast log viewer / querying tool makes it very simple to run custom queries. Per user, for a group of users, excluding certain users, between two dates, certain audit events only, you name it.
  • Improved Reporting: The Muhimbi Audit Suite ships with a number of pre-generated reports such as Security Reports and Content Modification Reports, but it is also very simple to generate your own custom ones. Results can be grouped by User, Date, Site or by any combination of these. Export the data to Excel for further filtering / pivoting.

    SharePoint-Audit-ReportGenerated report grouped by Date and User  

  • Increased Scalability: The audit tables that ship with SharePoint have not been designed with scalability in mind. The Muhimbi Audit Suite creates a separate logging database that is highly optimised for the logging and querying of audit data, no matter how many millions of rows it contains.
  • Automatic log truncating: SharePoint’s standard log tables, they just grow and grow…. out of control. We have many customers who used to have more than 100 million rows in their audit tables, which could no longer be queried due to their size and were causing problems during the backup process of site collections. The Muhimbi Audit Suite allows the log files to be truncated automatically after a certain amount of time. There is no need to keep indefinite audit data if all you need is the last 3 months.

For more information check out the following resources:


As always, feel free to contact us using Twitter, our Blog, regular email or subscribe to our newsletter.

Download your free trial here (4.5 MB). .


Labels: , , ,

Need support from experts?

Access our Forum

Download Free Trials