Posted at: 2:44 PM on 28 January 2011 by Muhimbi

When we developed the Web Services Interface for our PDF Conversion engine, one of our goals was to make it as compatible as possible with legacy and non Visual Studio 2008 environments, e.g. Java and other Web Services capable systems.
Although we succeeded in making it compatible, we recently found out that when using the standard version of the aging Visual Studio 2005 environment, there are some problems with the XML serialisation of web service data.
This article explains how to invoke the Muhimbi PDF Conversion Services from a Visual Studio 2005 environment. It also provides a VB version of the C# based sample code used in our main Web Services tutorial. If you use Visual Studio 2008 or newer then please use this tutorial, unless you have some interest in the vb.net based sample code at the end of this post.
Ok, so the situation is as follows: your organisation still uses Visual Studio 2005, for whatever valid reason, and you wish to invoke the Muhimbi PDF Converter from a Visual Studio 2005 based application. Unfortunately the facility in Visual Studio 2005 that adds web references is not too happy with the default DataContractSerializer used by our WCF based service. Visual Studio 2005 uses the standard XmlSerializer, which is quite compatible, but not completely. Switching serialisers at runtime is not possible either as they are part of the data contract, which makes sense.
Solution 1 – Visual Studio 2005 extensions for .net 3.0
The easiest solution is to download the latest Visual Studio 2005 extensions for the .net framework 3.0. Don’t be put off by the fact that it is still a CTP, Microsoft never bothered to update it and instead pushed people to Visual Studio 2008.
Once installed you can add a Service Reference using the following URL. Please do not use the Add Web Reference option, as that uses the old way of doing it.
http://localhost:41734/Muhimbi.DocumentConverter.WebService/?wsdl
If not already added automatically, you will need to add a regular .net reference to the following .net 3.0 assemblies as well:
System.ServiceModel.dll
System.Runtime.Serialization.dll
Once the service reference has been added you can either use the sample VB.NET code listed at the end of this post or the C# code in our regular tutorial. Please note that depending on how you have named things, you may need to manually change the names of the sample namespaces.
Solution 2 – Create web service proxy manually using SVCUTIL.EXE
If Solution 1 doesn’t work for you, or you don’t want to install the VS2005 extensions, then you can also take the manual approach that uses svcutil.exe to create the web service proxy classes in the language of your choice. If you wish you can skip steps 1 to 4 and download the pre-generated proxies for VB and C#, as well as some other sample code, here.
The procedure is as follows:
- You will need an updated version of svcutil.exe as the one that ships with VS2005 is not suitable, so download and install the Windows SDK.
- If not already the case, please make sure the .net framework 3.0 is installed on your system as well. An easy way to check if it has already been installed is by checking if the following directory exists:
"%WINDIR%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation"
Download it from here if needed.
- Make sure svcutil.exe is on your path (It is most likely located at C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin), and open the command prompt.
- Create a folder or navigate to the directory where you want to create the proxy classes, e.g. c:\ws_proxy and execute the following command to generate the web service proxy classes:
svcutil.exe http://localhost:41734/Muhimbi.DocumentConverter.WebService/?wsdl /language:vb /serializer:DataContractSerializer /namespace:*,DocumentConverter
This will result in the following output (note the version number of svcutil.exe).
You can read about the various parameters, including targeting different languages, in the svcutil documentation.
- If you haven’t already created a Visual Studio 2005 project, then do so now (this sample uses vb.net for a change) and add the generated proxy file to the project.
- Create a new WinForm, add a TextBox as well as a Button to it. Please accept the default names.
- Double click the button and replace all code with the code displayed below.
- Run the application, enter the name of an MS-Word file including the full path and click the button to convert the file and display the PDF.
Download pre-generated proxies and source code here.
Imports System.IO
Imports System.ServiceModel
Public Class Form1
' ** The URL where the Web Service is located. Amend host name if needed.
Dim SERVICE_URL As String = "http://localhost:41734/Muhimbi.DocumentConverter.WebService/"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim client As DocumentConverterServiceClient = Nothing
Try
' ** Determine the source file and read it into a byte array.
Dim sourceFileName As String = TextBox1.Text
Dim sourceFile As Byte() = File.ReadAllBytes(sourceFileName)
' ** Open the service and configure the bindings
client = OpenService(SERVICE_URL)
'** Set the absolute minimum open options
Dim openOptions As New OpenOptions()
openOptions.OriginalFileName = Path.GetFileName(sourceFileName)
openOptions.FileExtension = Path.GetExtension(sourceFileName)
' ** Set the absolute minimum conversion settings.
Dim conversionSettings As New ConversionSettings()
conversionSettings.Fidelity = ConversionFidelities.Full
conversionSettings.Quality = ConversionQuality.OptimizeForPrint
' ** Carry out the conversion.
Dim convFile As Byte() = client.Convert(sourceFile, openOptions, conversionSettings)
' ** Write the converted file back to the file system with a PDF extension.
Dim destinationFileName As String = Path.GetDirectoryName(sourceFileName) & "\" & _
Path.GetFileNameWithoutExtension(sourceFileName) & "." & _
conversionSettings.Format.ToString
Using fs As FileStream = File.Create(destinationFileName)
fs.Write(convFile, 0, convFile.Length)
fs.Close()
End Using
MessageBox.Show("File converted to " & destinationFileName)
' ** Launch the PDF file in the registered viewer
Process.Start(destinationFileName)
Catch ex As FaultException(Of WebServiceFaultException)
MessageBox.Show("FaultException occurred: ExceptionType: " & _
ex.Detail.ExceptionType.ToString())
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
CloseService(client)
End Try
End Sub
''' <summary>
''' Configure the Bindings, endpoints and open the service using the specified address.
''' </summary>
''' <returns>An instance of the Web Service.</returns>
Public Shared Function OpenService(ByVal address As String) As DocumentConverterServiceClient
Dim client As DocumentConverterServiceClient = Nothing
Try
Dim binding As New BasicHttpBinding()
' ** Use standard Windows Security.
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows
' ** Increase the Timeout to deal with (very) long running requests.
binding.SendTimeout = TimeSpan.FromMinutes(30)
binding.ReceiveTimeout = TimeSpan.FromMinutes(30)
' ** Set the maximum document size to 40MB
binding.MaxReceivedMessageSize = 50 * 1024 * 1024
binding.ReaderQuotas.MaxArrayLength = 50 * 1024 * 1024
binding.ReaderQuotas.MaxStringContentLength = 50 * 1024 * 1024
' ** Specify an identity (any identity) in order to get it past .net3.5 sp1
Dim epi As EndpointIdentity = EndpointIdentity.CreateUpnIdentity("unknown")
Dim epa As New EndpointAddress(New Uri(address), epi)
client = New DocumentConverterServiceClient(binding, epa)
client.Open()
Return client
Catch generatedExceptionName As Exception
CloseService(client)
Throw
End Try
End Function
''' <summary>
''' Check if the client is open and then close it.
''' </summary>
''' <param name="client">The client to close</param>
Public Shared Sub CloseService(ByVal client As DocumentConverterServiceClient)
If client IsNot Nothing AndAlso client.State = CommunicationState.Opened Then
client.Close()
End If
End Sub
End Class
This concludes our rather long and boring story. We’ll promise that the next blog post will contain some colourful pictures.
.
Posted at: 11:27 AM on 27 January 2011 by Muhimbi
Customers, customers, customers, you just can’t please them! Ever since we released support for Nintex Workflow, people have started to ask for K2 support…typical.
A commercial grade K2 Connector is planned for a future release, so for now we’ll provide a summary of how you can make the PDF Converter for SharePoint work together with your custom K2 workflows.
- The easiest option is to create a very simple SharePoint Designer workflow that just carries out the PDF Conversion as described in this example. You can then invoke this workflow from your custom K2 workflow.
- Alternatively, and this requires some development experience as well as the K2 SDK, you can create a K2 compatible workflow Action / Activity that directly invokes our rich Web Services interface to carry out the PDF Conversion / Watermarking / Security.
Please contact us if you have any questions or want to have any specific K2 functionality developed for your organisation.
.
Labels: Articles, K2, PDF Converter, Products, Workflow
Posted at: 6:05 PM on 17 January 2011 by Muhimbi
If we didn’t know any better, and had no windows in our office, we’d think spring has come early this year as our SharePoint products just keep delivering their offspring. We are only halfway into January and have already released a new version of our popular PDF Converter for SharePoint, a new version of the platform independent PDF Converter Services and now a new SharePoint 2010 compatible version of the URL Shortener for SharePoint.
For those not familiar with the product, the Muhimbi URL Shortener for SharePoint, aka MuSH, can be used to shorten URLs for typical web applications and SharePoint in particular. It integrates tightly with WSS, MOSS as well as SharePoint 2010 and allows short URLs to be created directly from a list item’s context menu, workflows and web services. For details see the original announcement.
There are no major new features in this version, the main change is that the product has been made compatible with SharePoint 2010, while continuing to work in SharePoint 2007. We have also fixed a few minor issues and improved logging for some specific scenarios.
For more information check out the:
As always, feel free to contact us using Twitter, our Blog or regular email or subscribe to our newsletter.
Download your free trial here (1.5MB).
.
Labels: MuSH, News, Products, SP2010, Workflow
Posted at: 2:50 PM on 10 January 2011 by Muhimbi
Last week’s release of version 4.1 of the PDF Converter for SharePoint shipped with an improved version of our popular PDF Conversion engine. Today we are releasing an update to the standalone version of the Muhimbi PDF Converter Services that includes the same engine including all new functionality such as HTML to PDF Conversion and the many improvements we have made to the conversion of InfoPath documents.
Let’s have a look at some of the new functionality:
If you can’t wait to give it a go then proceed straight to the download link at the end of this post. Read on for a full list of all changes and improvements.
High level overview of the main Web Services based interface. Full Details can be found in the User / Developer Guide.
A quick introduction for those not familiar with the product: The Muhimbi PDF Converter Services is a 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 and .NET based solutions. It supports a large number of file types including MS-Office and ODF file formats as well as HTML and Images 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 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 in the new version are as follows:
| 642 | New - Support for HTML to PDF Conversion in Web Service. |
| 1011 | New - Support for PDF conversion of common image types such as BMP, GIF, PNG, JPG. |
| 870 | New - Web Service method to allow existing PDF files to be watermarked. |
| 1001 | New - Automatically convert files attached to InfoPath forms to PDF. |
| 993 | New - Allow non-default InfoPath views to be selected for conversion to PDF. |
| 1002 | New - Allow multiple InfoPath views to be converted and merged into a single PDF file. |
| 770 | Fix - File system based XSN references are now decoded properly. |
| 673 | New - Allow range of InfoPath page numbers to convert to be specified. |
| 1110 | Fix - Borders are clipped incorrectly for watermarks. |
| 1118 | Fixed – Setup has more instructions and better account validation. |
| 992 | New - Setup now alerts the user of potential 'loopbackcheck' problems. |
| 836 | Fix - Applying Security on PDF files corrupts certain pages. |
| 885 | Fixed - Increased compatibility with InfoPath 2010. |
| 882 | Fixed - Size of watermarked documents have been improved by an order of magnitude. |
| 882 | Fixed - Performance of watermarking documents has been improved by an order of magnitude.< |
| 1191 | Fixed - Applying owner password on certain PDF files results in an error. |
| 1116 | New - Allow Converter Specific Settings to be specified on the Web Services Interface. |
| 1130 | New - Allow InfoPath Specific Settings to be specified on the Web Services Interface. |
| 1117 | New - Allow PowerPoint Specific Settings to be specified on the Web Services Interface. |
| 757 | New - Allow MS-Word Specific Settings to be specified on the Web Services Interface. |
| 1080 | New - Recovery options are now automatically configured for the Windows Service. |
| 1145 | Fixed - Fractions used in watermarks have been fixed for a number of locales. |
| 1017 | Fixed - Credentials were incorrectly cached for HTML to PDF Conversion. |
| 1142 | Fixed - Watermarking fill color no longer defaults to black. |
| 1143 | Fixed - Watermarking random positioning is now more random. |
| 675 | Fixed - Excel to PDF Conversion now allows range of page numbers to be specified. |
| 1106 | New - Allow custom credentials for the retrieval of InfoPath XSN files to be specified. |
| 1146 | New - Added additional details to Conversion Service trace log. |
| 1152 | Fixed - HTML to PDF URLs now allow spaces in the URL. |
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 (7MB).
.
Labels: News, pdf, PDF Converter Services, Products
Posted at: 5:54 PM on 06 January 2011 by Muhimbi
As my grandfather always used to say, and I quote, “There is no better way to start the new year unless you have a brand new release of the popular Muhimbi PDF Converter for SharePoint in your hands”. Words of Wisdom!
All kidding aside, we initially planned to make this a small interim release that improves upon the existing functionality, but we got carried away and added some big feature as well.
The main new features are as follows:
For those not familiar with the product, the PDF Converter for SharePoint is a lightweight solution that allows end-users to convert common document types to PDF format 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, localisation, security and tracing. It runs on WSS 3, MOSS as well as SharePoint 2010 and is available in English, German, Dutch, French, Traditional Chinese and Japanese. For detailed information check out the product page.
New Nintex Workflow 2007 & 2010 Workflow Actions
In addition to the changes listed above, some of the main changes in the new version are as follows:
| 803 | New - Support for SharePoint 2010 Document Sets. |
| 802 | New - Select and Convert multiple files in SharePoint 2010. |
| 894 | New - SharePoint Designer Workflow Activity to secure PDF files. |
| 895 | New - Native support for Nintex Workflow 2007 and 2010. |
| 1140 | Fixed - HTML to PDF Conversion of SharePoint 2010 pages. |
| 885 | Fixed - Increased compatibility with InfoPath 2010. |
| 882 | Fixed - Size of watermarked documents have been improved by an order of magnitude. |
| 882 | Fixed - Performance of watermarking documents has been improved by an order of magnitude. |
| 1118 | Fixed - Service Installer now has more instructions and better account validation. |
| 238 | Fixed - Added support for Google Chrome, Apple Safari and other WebKit based browsers. |
| 700 | Fixed - Workflows started by files written via WEBDAV may not work correctly. |
| 1154 | Fixed - Converted PDF Files are sometimes saved as the System account. |
| 1192 | Fixed - Files that result in PDF files larger than 50MB are not accepted by the client. |
| 1191 | Fixed - Applying owner password on certain PDF files results in an error. |
| 1186 | Fixed - HTML containing pages inside Object tags can now be converted to PDF. |
| 1197 | Fixed - Negative page numbering causes an Exception in the MS-Word converter. |
| 1116 | New - Allow Converter Specific Settings to be specified on the Web Services Interface. |
| 1130 | New - Allow InfoPath Specific Settings to be specified on the Web Services Interface. |
| 1117 | New - Allow PowerPoint Specific Settings to be specified on the Web Services Interface. |
| 757 | New - Allow MS-Word Specific Settings to be specified on the Web Services Interface. |
| 1080 | New - Recovery options are now automatically configured for the Windows Service. |
| 1145 | Fixed - Fractions used in watermarks have been fixed for a number of locales. |
| 1017 | Fixed - Credentials were incorrectly cached for HTML to PDF Conversion. |
| 1137 | Fixed - Text and RTF Data can now be specified inside the watermark element. |
| 1142 | Fixed - Watermarking fill color no longer defaults to black. |
| 1143 | Fixed - Watermarking random positioning is now more random. |
| 1153 | New - Misspelled attributes in composite watermarks are now reported. |
| 1157 | Fixed - Watermarking related workflow actions have been made more reliable. |
| 675 | Fixed - Excel to PDF Conversion now allows range of page numbers to be specified. |
| 1106 | New - Allow custom credentials for the retrieval of InfoPath XSN files to be specified. |
| 1146 | New - Added additional details to Conversion Service trace log. |
| 1152 | Fixed - HTML to PDF URLs now allow spaces in the URL. |
| 1164 | Fixed - ArgumentNullException in Central Admin for people upgrading from very old versions. |
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 (10MB). .
.
Labels: News, Nintex, pdf, PDF Converter, Products, Workflow