Subscribe to News feed

Combining multiple Muhimbi PDF SharePoint Workflow Activities into a sequence

Posted at: 5:19 PM on 17 May 2013 by Muhimbi

workflow

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).

Over the years we have written extensively about the various workflow activities that ship with the PDF Converter for SharePoint, and although we have touched on the ability to target documents other than the one that started the workflow, this topic deserves its own blog post.

 

Introduction

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:

  1. 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.
  2. Item ID (SharePoint 2007):  On this platform use the type named ‘List Item ID’ for the workflow variable.
  3. 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:

  1. Create a blank Nintex Workflow.
  2. Open the Workflow Settings / Variables screen using the Ribbon.
  3. Create a workflow variable named Generated PDF Item ID of type Integer.
  4. Create a workflow variable named Generated PDF List ID of type Single Line of Text.

    Workflow-Variables
     
  5. 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.
  6. 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.

    Convert-to-PDF-Variables
     
  7. 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
    Watermark-PDF-Variables
     
  8. Save and close the workflow activity.
  9. 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

A copy of this workflow is available for download here.

 

Example - Item ID type is string / text

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:

  1. Create a blank Nintex Workflow.
  2. Open the Workflow Settings / Variables screen using the Ribbon.
  3. Create a workflow variable named Generated PDF Item ID (Integer) of type Integer.
  4. Create a workflow variable named Generated PDF Item ID of type Single Line of Text.
  5. Create a workflow variable named Generated PDF List ID of type Single Line of Text

    Workflow-Variables-2
     
  6. Close the Workflow Variables window and add the Muhimbi Convert Document activity to the workflow and double click it to open the configuration window.
  7. 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. 

    Convert-Document-Variables
     
  8. 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.

    Convert-Value
     
  9. 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)
    Watermark-PDF-Variables
     
  10. Save and close the workflow activity.
  11. 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

A copy of this workflow is available for download here.

 

A more complex Nintex Workflow example that uses the ability to target different source files for PDF Conversion is available in this example.

 

Are you working on a complex workflow and struggling to make it work? If so then please leave a comment below or contact our support desk.

Labels: , , ,

Using Third Party CAD Converters in combination with the Muhimbi PDF Converter

Posted at: 11:42 AM on 26 April 2013 by Muhimbi

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.

  1. Download and install the Muhimbi PDF Converter Services or Muhimbi PDF Converter for SharePoint. During installation please pay close attention to Chapter 2 of the included Installation and Administrating Guide.
  2. Download and install Any DWG to PDF Converter Pro. In this example we assume it is installed in the default location.
  3. 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.
  4. Search for “CAD based formats” and remove or comment out the entire XML element.
  5. Search for “CommandLineConverter” and replace it with the following, don’t forget to remove the XML comments (<!--…. –>)
     
    <add key="CAD Converter (CL)"
      description="3rd Party CAD Converter"
      fidelity="Full"
      supportedExtensions="dxf,dwg"
      supportedOutputFormats="pdf"
      type="Muhimbi.DocumentConverter.WebService.CommandLineConverter,
            Muhimbi.DocumentConverter.WebService, Version=1.0.1.1, Culture=neutral,
            PublicKeyToken=c9db4759c9eaad12"
      parameter="C:\Program Files (x86)\Any DWG to PDF Converter Pro\dp.exe |
            /InFile {0} /OutFile {1} /PDFColor GrayScale /PDFQuality High /OutMode AlltoOne /Hide"/>
         
  6. Save the configuration file.
  7. 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.
  8. 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"
  9. 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.

.

Labels: , , , ,

PDF Converter for SharePoint 7.0 - SP2013, Nintex 2013, Fast Web View, PDFA/2b

Posted at: 11:39 AM on 02 April 2013 by Muhimbi

PDFBox5

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.

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
1774 Conversion New Validate converter with Office 2013 / 15
1758 Documentation New Document how to invoke the Web Service from PHP
1846 Documentation New Document ConverterSpecificSettings in Java using Axis2
1864 Documentation New Add Ruby sample code
1839 HTML Fix HTML to PDF Conversion fails on certain pages using 0.5inch page margins
1842 HTML Fix Bitmapped output in IE8
1833 HTML Fix Pixelated HTML to PDF conversion on Win2K3
1739 HTML New Add credential override for HTML Conversion in config file
1818 InfoPath Fix 'ClearFormCache' expects English OS
1802 Merging Fix PDF Bookmark targets bottom of page under certain circumstances
1825 Merging Fix Unexpected token Number before 42079 when merging
1848 Merging Fix Unexpected token DictionaryStart when merging file
1851 Merging Fix Fatal Error at 109 when merging files
1755 Merging Improvement Completely suppress errors when merging
1722 Meta-Data Improvement On the merge screen allow the item to be specified where to copy the meta data from
1797 Meta-Data Improvement Copying named meta data fields fails when any of those fields are globally excluded
1808 MSG Fix MSG to PDF - Regression bug, email renders as plain text
1809 MSG Fix MSG to PDF - Incorrect identification of email type (RTF / HTML)
1817 MSG Fix MSG to PDF - Extra ltrch RTF keywords remain in converted PDF
1601 MSG Improvement MSG to PDF - Improve line spacing in HTML to PDF Conversion
1592 MSG Improvement MSG to PDF - Font sizes sometimes becomes very small
1658 MSG Improvement MSG to PDF - Conversion - Indentation missing
1858 MSG New Add support for SMIME and Clear Text signed MSG files
1867 Other Fix Converting MS-Word to non-PDF files using the web services interface requires empty strings for open and owner password
1731 Other Improvement Verify InfoPath & HTML Conversion in Kerberos environments.
1803 Other Improvement Check parameter names when passing 'override settings'
1828 Other Improvement Improve Diagnostics tool for Performance tests
1870 Other Improvement There doesn't appear to be any logging in convert.aspx when not able to connect to central admin
1852 Other Improvement Clean up Diagnostics tool and add new post processing facilities
1775 Other New Add SharePoint 2013 support
1724 Post Processing New Allow PDF Post processing for 'Fast Views' / Linearization
1793 Post Processing New Add support for PDF/A-2B
1835 Post Processing New Add support for specific PDF Versions
1836 Post Processing New Add support for Font Embedding
1837 Post Processing New Add support for PDF Viewer Preferences
1791 Setup Fix During install loopback check window is displayed in the background
1801 Workflow Fix File names with multiple periods are truncated
1865 Workflow New Add Nintex Workflow 2013 support


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

.

Labels: , , , , , , ,

PDF Converter Services 7.0–Embed Fonts, Viewer Preferences, PDFA/2b, PDF Versions

Posted at: 2:24 PM on 31 March 2013 by Muhimbi

PDFConverterServicesBox4_thumb3

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:

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
1774 Conversion New Validate converter with Office 2013 / 15
1758 Documentation New Document how to invoke the Web Service from PHP
1846 Documentation New Document ConverterSpecificSettings in Java using Axis2
1864 Documentation New Add Ruby sample code
1839 HTML Fix HTML to PDF Conversion fails on certain pages using 0.5inch page margins
1842 HTML Fix Bitmapped output in IE8
1833 HTML Fix Pixelated HTML to PDF conversion on Win2K3
1739 HTML New Add credential override for HTML Conversion in config file
1818 InfoPath Fix 'ClearFormCache' expects English OS
1802 Merging Fix PDF Bookmark targets bottom of page under certain circumstances
1825 Merging Fix Unexpected token Number before 42079 when merging
1848 Merging Fix Unexpected token DictionaryStart when merging file
1851 Merging Fix Fatal Error at 109 when merging files
1755 Merging Improvement Completely suppress errors when merging
1808 MSG Fix MSG to PDF - Regression bug, email renders as plain text
1809 MSG Fix MSG to PDF - Incorrect identification of email type (RTF / HTML)
1817 MSG Fix MSG to PDF - Extra ltrch RTF keywords remain in converted PDF
1601 MSG Improvement MSG to PDF - Improve line spacing in HTML to PDF Conversion
1592 MSG Improvement MSG to PDF - Font sizes sometimes becomes very small
1658 MSG Improvement MSG to PDF - Conversion - Indentation missing
1858 MSG New Add support for SMIME and Clear Text signed MSG files
1867 Other Fix Converting MS-Word to non-PDF files using the web services interface requires empty strings for open and owner password
1731 Other Improvement Verify InfoPath & HTML Conversion in Kerberos environments.
1828 Other Improvement Improve Diagnostics tool for Performance tests
1852 Other Improvement Clean up Diagnostics tool and add new post processing facilities
1724 Post Processing New Allow PDF Post processing for 'Fast Views' / Linearization
1793 Post Processing New Add support for PDF/A-2B
1835 Post Processing New Add support for specific PDF Versions
1836 Post Processing New Add support for Font Embedding
1837 Post Processing New Add support for PDF Viewer Preferences
1791 Setup Fix During install loopback check window is displayed in the background

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

.

Labels: , , , , , , , ,

Use Ruby (on Rails) to Convert, Merge and Watermark HTML & Office files to PDF

Posted at: 5:54 PM on 04 March 2013 by Muhimbi

rubyIn 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.

We previously discussed how to use the popular Muhimbi PDF Converter Services in combination with PHP, Java (Axis2 and wsimport) as well as Microsoft .NET based environments. Today we will discuss a similar example using the increasingly popular Ruby on Rails (ROR) platform.

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.

  1. Download and Install Ubuntu 12.10. We set it up to run inside Hyper-V, but that is naturally not a requirement.
  2. 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’.
  3. 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.

  1. Use a terminal application of your choice to navigate to the location where you wish to create the Rails application. We use ~Sites.
  2. Execute the following command to create the skeleton for the application:
       rails new MuhimbiPDFConverter –O
  3. Navigate to MuhimbiPDFConverter, edit Gemfile using a text editor of your choice and add the following line:
       gem 'soap4r'
  4. Install bundler as follows:
       gem install bundler
  5. 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).

  1. Download and Install the Muhimbi PDF Converter Services as described in Chapter 2 of the Administration guide.
  2. 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.
  3. Search for baseAddress and change localhost to the DNS name or IP address of the server running the Conversion Service.
  4. 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:

  1. Navigate to MuhimbiPDFConverter/lib
  2. 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.

  1. Start by generating a controller where the form will be posted to:
      rails generate controller home upload_file
  2. Delete the home page that comes with every new Rails application (Execute in the MuhimbiPDFConverter folder)
      rm public/index.html
  3. 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.
  4. Edit config/routes.rb and after the following line
      get "home/upload_file"
    Add
      post "home/upload_file" 
      root :to => 'home#upload_file'
  5. Edit app/views/home/upload_file.html.erb and add the following HTML
     
<form method="post" enctype="multipart/form-data">
    <br/>
    <label for="file">Document:</label>
    <input type="file" name="file" id="file" />
    <br/>
    <label for="outputFormat">Output format:</label>
    <select name="outputFormat" id="outputFormat">
        <option value="PDF">PDF</option>
        <option value="XPS">XPS</option>
        <option value="DOCX">DOCX</option>
        <option value="DOC">DOC</option>
        <option value="ODT">ODT</option>
        <option value="RTF">RTF</option>
        <option value="TXT">TXT</option>
        <option value="MHT">MHT</option>
        <option value="HTML">HTML</option>
        <option value="XML">XML</option>
        <option value="XLS">XLS</option>
        <option value="XLSX">XLSX</option>
        <option value="CSV">CSV</option>
        <option value="ODS">ODS</option>
        <option value="PPT">PPT</option>
        <option value="PPTX">PPTX</option>
        <option value="ODP">ODP</option>
        <option value="PPS">PPS</option>
        <option value="PPSX">PPSX</option>
    </select>
    <br/>
    <input type="submit" name="submit" value="Convert" />
</form>

 
6.   Edit app/controllers/home_controller.rb and replace it with the following:

require Rails.root.to_s + '/lib/DocumentConverterServiceDriver'
require "base64"
class HomeController < ApplicationController
  def upload_file
    #** Get a reference to the uploaded file and check it was specified
    file = params['file']
    if file
      #** Specify the URL of the server that holds the Conversion Service
      url = "http://localhost:41734/Muhimbi.DocumentConverter.Webservice/?wsdl"
      conversionClient = DocumentConverterService.new(url)
      #** Create OpenOptions and specify the absolute minimum information
      openOptions = OpenOptions.new()
      openOptions.fileExtension = file.original_filename.split(".").last
      openOptions.originalFileName = file.original_filename
      #** Create ConversionSettings and set the minimum fields. See Developer guide for details
      conversionSettings = ConversionSettings.new()
      conversionSettings.format = params['outputFormat']
      conversionSettings.fidelity = "Full"
      conversionSettings.openPassword = ""
      conversionSettings.ownerPassword = ""
      #** Encode the source file into a Base64 encoded byte array
      sourceFile = Base64.encode64(file.read)
      #** Carry out the conversion
      convert = Convert.new(sourceFile, openOptions, conversionSettings)
      result =  conversionClient.convert(convert)
      #** Send the converted file back to the browser. ‘wsdl2ruby’ needs double Base64 decoding for some reason.
      send_data(Base64.decode64(Base64.decode64(result.convertResult)),
         :filename => "convert." + conversionSettings.format,
         :content_type => 'application/octet-stream',
         :disposition => 'attachment')
    end
  end
end

 

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.

For details about how to debug Web Service / SOAP messages, see this Knowledge Base Article.

 

If you have any questions then leave a comment below or contact us.

.

Labels: , , ,

Using the Muhimbi PDF Converter with SharePoint 2013

Posted at: 4:20 PM on 25 February 2013 by Muhimbi

SP2013 LogoOne 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.  
 

SP2013-Collage

 
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.

 

.

Labels: , , , , , ,