Subscribe to News feed

PDF Converter Services 5.0 - New AutoCAD, TIFF and PDF Merging support

Posted at: 13:33 on 27 May 2011 by Muhimbi

PDFConverterServicesBoxEarlier this week we released version 5.0 of the PDF Converter for SharePoint, which ships 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 all new functionality such as AutoCAD and TIFF conversions as well as the ability to convert and merge multiple files.

The main new features are as follows:


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.

ClassDiagram-Merging
New PDF Merging related classes of the Web Services Interface.

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 and .NET based solutions. It supports a large number of file types including MS-Office and ODF file formats as well as HTML, 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 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 in the new version are as follows:

1325 Fix - Improve watermark random positioning.
891 New - Add support for merging of documents to the Web Services Interface.
1014 New - Add support for converting TIFF files to PDF.
1051 New - Add support for converting AutoCAD files to PDF.
1230 New - AutoCAD Conversion - Add Greyscale and automatic recolouring options.
1262 New - AutoCAD Conversion - Add Configurable page margins.
1243 New - AutoCAD Conversion - Add support for Converter Specific Settings.
1244 New - AutoCAD Conversion - Add support for 3D based CAD drawings.
1212 Fix - Occasional RPC_E_SERVERCALL_RETRYLATER when converting InfoPath 2010 form.
1303 New - Add support for custom page sizes, margins and page orientation to the HTML converter.

 

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 (8MB). .

.

Labels: , , , , , , ,

PDF Converter for SharePoint 5 - AutoCAD, TIFF, Merging, Automatic Watermarking

Posted at: 12:14 on 25 May 2011 by Muhimbi

PDFBox5

It is that beautiful time of the year again where the sun is shining, the birds are singing and new versions of the popular Muhimbi PDF Converter for SharePoint are released left right and center. I say ‘versions’, but it really is only one version, a major milestone, version 5.0!

The list of new features is considerable but the main ones are as follows:

 
Some of this new functionality can be seen in action in a webcast we recorded recently.

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 - including InfoPath, AutoCAD, MS-Office, HTML and images - 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. 

As they say, a picture is worth a thousand words so here you go. Links to more detailed information as well as a download of the latest version is available at the end of this post.
 

 Result of a user specific watermark when opening documents 
 

SP2010-MergeScreenConverting and merging multiple files using the SharePoint User Interface

In addition to the changes listed above, some of the main changes in the new version are as follows:

988 New - Add support for user specific watermarks when a file is opened / converted.
1222 New - Allow watermarks to be applied when items are created / updated without needing workflows.
1257 New - Enhance watermarking merge code / field code syntax.
1325 Fix  - Improve watermark random positioning.
891 New - Add support for merging of documents to the Web Service and SharePoint User Interface.
1014 New - Add support for converting TIFF files to PDF.
1051 New - Add support for converting AutoCAD files to PDF.
1230 New - AutoCAD Conversion - Add Greyscale and automatic recolouring options.
1262 New - AutoCAD Conversion - Add Configurable page margins.
1243 New - AutoCAD Conversion - Add support for Converter Specific Settings.
1244 New - AutoCAD Conversion - Add support for 3D based CAD drawings.
1212 Fix  - Occasional RPC_E_SERVERCALL_RETRYLATER when converting InfoPath 2010 form.
1231 Fix  - Add back Utility.GetSPFolder for use in custom scripts.
1303 New - Add support for custom page sizes, margins and page orientation to the HTML converter.
1307 Fix  - Add support for selecting sub sites to SharePoint 2010 TreePickerDialog.

 

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 (11MB). .

.





Labels: , , , , , , ,

Converting and merging multiple files using the PDF Converter Services and .NET / C#

Posted at: 17:40 on 16 May 2011 by Muhimbi

merge

To facilitate the new PDF Merging facility in our PDF Converter for SharePoint we have added the ability to convert and merge multiple files to our core PDF Conversion engine, which our SharePoint product shares with our generic Java / .NET oriented PDF Converter Services.

In this post we’ll describe in detail how to invoke this new merging facility from your own code. This demo use C# and .NET, but the web services based interface is identical when used from Java (See this generic PDF Conversion sample)
 

This post is part of the following series related to manipulating PDF files using web services.

 
Key Features

The key features of the new merging facilities are as follows:

  1. Convert and merge any supported file format (inc. HTML, AutoCAD, MS-Office, InfoPath, TIFF) or merge existing PDF files.
  2. Apply different watermarks on each individual file as well as on the entire merged file (e.g. page numbering).
  3. Apply PDF Security settings and restrictions on the merged file.
  4. Optionally skip (and report) corrupt / unsupported files.
  5. Add PDF Bookmarks for each converted file.
  6. Apply any ConversionSetting supported by the regular conversion process.

 

Object Model

The object model is relatively straight forward. The classes related to PDF Merging are displayed below. A number of enumerations are used as well by the various classes, these can be found in our original post about Converting files using the Web Services interface.

ClassDiagram-Merging

 
The Web Service method that controls merging of files is called ProcessBatch (highlighted in the screenshot above). It accepts a ProcessingOptions object that holds all information about the source files to convert and the MergeSettings to apply, which may include security and watermarking related settings. A Results object is returned that, when it comes to merging of files, always contains a single file that holds the byte array for the merged PDF file.

 

Simple example code

The following sample  describes the steps needed to convert all files in a directory, merge the results into a single file and apply page numbering to the merged file using the built in watermarking engine. We are using Visual Studio and C#, but any environment that can invoke web services should be able to access this functionality. Note that the WSDL can be found at http://localhost:41734/Muhimbi.DocumentConverter.WebService/?wsdl. A generic PDF Conversion Java based example is installed alongside the product and discussed in the User & Developer Guide.

  1. Start a new Visual Studio project and create the project type of your choice. In this example we are using a standard .net 3.0 project of type Windows Forms Application. Name it ‘Simple PDF Converter Sample’.
  2. Add a TextBox and Button control to the form. Accept the default names of textBox1 and button1.
  3. In the Solution Explorer window, right-click References and select Add Service Reference. (Do not use web references!)
  4. In the Address box enter the WSDL address listed in the introduction of this section. If the Conversion Service is located on a different machine then substitute localhost with the server’s name.
  5. Accept the default Namespace of ServiceReference1 and click the OK button to generate the proxy classes.
  6. Double click Button1 and replace the content of the entire code file with the following:

 

using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceModel;
using System.Windows.Forms;
using Simple_PDF_Converter_Sample.ServiceReference1;
 
namespace Simple_PDF_Converter_Sample
{
    public partial class Form1 : Form
    {
        // ** The URL where the Web Service is located. Amend host name if needed.
        string SERVICE_URL = "http://localhost:41734/Muhimbi.DocumentConverter.WebService/";
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            DocumentConverterServiceClient client = null;
 
            try
            {
                // ** Options and all settings for batch conversion
                ProcessingOptions processingOptions = new ProcessingOptions();
 
                // ** Specify the minimum level of merge settings
                MergeSettings mergeSettings = new MergeSettings();
                mergeSettings.BreakOnError = false;
                mergeSettings.Watermarks = CreateWatermarks();
                processingOptions.MergeSettings = mergeSettings;
 
                // ** Get all files in the folder
                string sourceFolder = textBox1.Text;
                string[] sourceFileNames = Directory.GetFiles(sourceFolder);
 
                // ** Iterate over all files and create a list of SourceFile Objects
                List<SourceFile> sourceFiles = new List<SourceFile>();
                foreach (string sourceFileName in sourceFileNames)
                {
                    // ** Read the contents of the file
                    byte[] sourceFileContent = File.ReadAllBytes(sourceFileName);
 
                    // ** Set the absolute minimum open options
                    OpenOptions openOptions = new OpenOptions();
                    openOptions.OriginalFileName = Path.GetFileName(sourceFileName);
                    openOptions.FileExtension = Path.GetExtension(sourceFileName);
 
                    // ** Set the absolute minimum conversion settings.
                    ConversionSettings conversionSettings = new ConversionSettings();
                    conversionSettings.Fidelity = ConversionFidelities.Full;
                    conversionSettings.Quality = ConversionQuality.OptimizeForPrint;
 
                    // ** Create merge settings for each file and set the name for the PDF bookmark
                    FileMergeSettings fileMergeSettings = new FileMergeSettings();
                    fileMergeSettings.TopLevelBookmark = openOptions.OriginalFileName;
 
                    // ** Create a source file object and add it to the list
                    SourceFile sourceFile = new SourceFile();
                    sourceFile.OpenOptions = openOptions;
                    sourceFile.ConversionSettings = conversionSettings;
                    sourceFile.MergeSettings = fileMergeSettings;
                    sourceFile.File = sourceFileContent;
                    sourceFiles.Add(sourceFile);
                }
 
                // ** Assign source files
                processingOptions.SourceFiles = sourceFiles.ToArray();
 
                // ** Open the service and configure the bindings
                client = OpenService(SERVICE_URL);
                // ** Carry out the merge process
                BatchResults results = client.ProcessBatch(processingOptions);
                // ** Read the results of the merged file.
                byte[] mergedFile = results.Results[0].File;
 
                // ** Write the converted file back using the name of the folder
                string folderName = new DirectoryInfo(sourceFolder).Name;
                DirectoryInfo parentFolder = Directory.GetParent(sourceFolder);
                string destinationFileName = Path.Combine(parentFolder.FullName, folderName + ".pdf");
                using (FileStream fs = File.Create(destinationFileName))
                {
                    fs.Write(mergedFile, 0, mergedFile.Length);
                    fs.Close();
                }
 
                MessageBox.Show("Contents of directory merged to " + destinationFileName);
            }
            catch (FaultException<WebServiceFaultException> ex)
            {
                MessageBox.Show("FaultException occurred: ExceptionType: " +
                                ex.Detail.ExceptionType.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                CloseService(client);
            }
        }
 
 
        /// <summary>
        /// Configure the Bindings, endpoints and open the service using the specified address.
        /// </summary>
        /// <returns>An instance of the Web Service.</returns>
        public static DocumentConverterServiceClient OpenService(string address)
        {
            DocumentConverterServiceClient client = null;
 
            try
            {
                BasicHttpBinding binding = 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
                EndpointIdentity epi = EndpointIdentity.CreateUpnIdentity("unknown");
                EndpointAddress epa = new EndpointAddress(new Uri(address), epi);
 
                client = new DocumentConverterServiceClient(binding, epa);
 
                client.Open();
 
                return client;
            }
            catch (Exception)
            {
                CloseService(client);
                throw;
            }
        }
 
        /// <summary>
        /// Check if the client is open and then close it.
        /// </summary>
        /// <param name="client">The client to close</param>
        public static void CloseService(DocumentConverterServiceClient client)
        {
            if (client != null && client.State == CommunicationState.Opened)
                client.Close();
        }
 
 
        /// <summary>
        /// This method creates watermarks for applying page numbers
        /// </summary>
        /// <returns>Array of watermarks</returns>
        private Watermark[] CreateWatermarks()
        {
            // ** Create watermark container
            Watermark pageWatermark = new Watermark();
            // ** Set positioning to the lower right of the page
            pageWatermark.HPosition = HPosition.Right;
            pageWatermark.VPosition = VPosition.Bottom;
            // ** Set size
            pageWatermark.Width = "200";
            pageWatermark.Height = "20";
 
            // ** Create text object for the page numbering 
            Text oddPageText = new Text();
            // ** No need to position the element in the watermark container
            oddPageText.Width = "200";
            oddPageText.Height = "20";
            // ** set content including field codes
            oddPageText.Content = "Page {PAGE} of {NUMPAGES}";
            // ** set font properties
            oddPageText.FillColor = "#ffff0000";
            oddPageText.FontFamilyName = "Verdana";
            oddPageText.FontSize = "10";
            oddPageText.FontStyle = FontStyle.Regular;
            //* set text alignment
            oddPageText.HAlign = HAlign.Right;
            oddPageText.VAlign = VAlign.Top;
 
            //** create array of watermark elements
            Element[] pageWatermarkElements = new Element[] { oddPageText };
 
            //** set elements of watermark
            pageWatermark.Elements = pageWatermarkElements;
 
            //* return array of watermarks
            return new Watermark[] { pageWatermark };
        }
 
    }
}

 

Providing the project and all controls are named as per the steps above, it should compile without errors. Run it, enter the full path to a folder that holds a couple of text files (PDF, Word, Excel, etc) and click the button to start the convert and merge process. The operation may take a while depending on the number and complexity of files in the folder.

Note that In this example we are programmatically configuring the WCF Bindings and End Points. If you wish you can use a declarative approach using the config file.

A more complex and full featured sample application is installed, with full source code, alongside the Conversion Service.

This new functionality is available as of version 5.0 of our software.

.

Labels: , , , , , ,

Converting and merging multiple files using the PDF Converter for SharePoint

Posted at: 12:22 on by Muhimbi

mergeThe Muhimbi PDF Converter for SharePoint has had the ability to convert multiple files starting with the very first version we released a number of years ago. However, each of these files are converted individually, which is great, but sometimes you want to carry out an extra operation such as merging those files into a single PDF file.

This functionality has been on our roadmap for a while, but we wanted to do it properly, so we have consulted a cross section of our customers to get a feel for how to implement merging in the best possible way. I think we have come up with a great solution that is easy to use while still providing plenty of options for power users.

For real power users and developers, merging can also be carried out via a web service call. A future version of the product will also come with native workflow activities to merge files. Until then you can merge PDF files from a workflow as described here.

OK, so let’s have a look at how PDF Merging works using the SharePoint user interface. Please note that the screenshots in this article have been made using SharePoint 2010, but it works equally well in SharePoint 2007.

The first step is to select which files to convert and merge. You can select individual files or an entire folder including sub folders. Don’t worry if you are not interested in merging all files, you can fine tune your selection during the merging process.
 

SP2010-MergeLib

 
Once selected click the ‘Convert to PDF’ button to open our standard PDF Conversion screen. The default option is to convert all files individually, but clicking the ‘Merge Files’ option enables all merging related functionality as per the screenshot below.

You can specify the following options:

  • Select the field to use for bookmarks: If you wish you can automatically generate a PDF bookmark for each file that is merged. This makes navigating through the PDF file a lot easier. You can select any field defined on the document library or ‘– Empty – ‘ to skip the bookmarking process. The default field is ‘Title’, which usually contains the most descriptive data.
  • Enabled / disable documents: For each file you can specify if they should be included in the merged document or not. This can be very useful when selecting an entire folder to convert and merge.
  • Manually change bookmark text: Selecting a field to populate the bookmarks with will automatically generate the text for each file’s bookmark. However, if you wish you can manually change this value to anything you like. Please take into account that any manually entered values will be overwritten if you select a different bookmark field name.
  • Change sequence of documents: By default all documents are ordered by modification date, with the oldest one on top. You can change the sequence using the up and down arrows.
  • Include document bookmarks: Each source document may already have its own bookmarks, e.g. existing PDF Files or MS-Word headings. By default these are all stripped out, but if you wish you can select to merge the bookmarks as well. For each document they will automatically be moved to sit underneath any custom bookmark name specified for the file.
  • Change file name: As we are dealing with multiple files we cannot use the name of the source file to generate the destination file name. For the merged file we default the file name to the name of the folder the files are located in. If the files are in the root folder then we use the name of the Document Library. You can override the default generated name and select a different folder if needed as well.

SP2010-MergeScreen

 
Further operations such as applying watermarks and PDF security can be carried out as a post processing step using simple workflows.

This new functionality is included in the 5.0 release of our software.

.





Labels: , , , , ,

Need support from experts?

Access our Forum

Download Free Trials