Word Automation tool and Word Automation Service Application in SharePoint 2010



WordAutoTool1.gif

1. Introduction

The purpose of this document is to provide step by step information about how to use the Word Automation tool and overview of Word Automation Service Application in SharePoint 2010.

2. Overview and Concepts in Word Automation Services

SharePoint 2010 introduces a new service application called Word Automation Services. This service application is used for server side conversion of word documents into other file formats.

Source files types:

  • Open XML File Format documents (.docx, .docm, .dotx, .dotm).
  • Word 97-2003 documents (.doc, .dot).
  • Rich Text Format files (.rtf).
  • Single File Web Pages (.mht, .mhtml).
  • Word 2003 XML Documents (.xml).
  • Word XML Document (.xml).

Destination files types:

  • Portable Document Format (PDF) files.
  • XML Paper Specification (XPS) files.
  • Open XML File Format documents (.docx, .docm, .dotx, .dotm).
  • Word 97-2003 documents (.doc, .dot).
  • Rich Text Format files (.rtf).
  • Single File Web Pages (.mht, .mhtml).
  • Word 2003 XML Documents (.xml).
  • Word XML Document (.xml).

Word Automation Service is a part of SharePoint 2010. Word Automation Service is available in the Standard edition and in the Enterprise edition. It is a feature of SharePoint 2010, so SharePoint 2010 should be purchased and installed to use Word Automation Services.

For Word Automation Services Architecture refer http://msdn.microsoft.com/en-us/library/ee556832.aspx

The following concepts are basic for Word Automation Services:

WordAutoTool2.gif

  • Conversion
  • Conversion Job
  • Document Queue

Conversion:
 
Conversion in Word Automation Services is a process of converting the word document to other formats. For example converting .doc file format to .pdf format. It constitutes of the following steps:

WordAutoTool3.gif

  • Create a conversion job
    ConversionJob job = new ConversionJob("Word Automation Services");
  • Set the desired output file format
    job.Settings.OutputFormat = SaveFormat.PDF;
  • Add files to the conversion job
    AddFile () method:

    Syntax:
    job.AddFile(string inputFile, string outputFile)
    Example:
    job.AddFile("http://serverName:31829/sites/Home/Shared%20Documents/ArticleLinks.docx", "http://serverName:31829/sites/Home/Shared%20Documents/ArticleLinks.pdf")

    AddFolder () method:

Syntax:
job.AddFolder(SPFolder inputFolder, SPFolder outputFolder, bool recursion);
Example:
job.AddFolder("\Shared Documents\Word ocuments", "\Shared Documents\PDF Documents", false);

AddLibrary () method:

Syntax:
job.AddFile(SPList inputList, SPList outputList)
Example:
job.AddFile("Word Library", "Document Library");
Submit the job to the document queue
job.Start();

Conversion Job:

Conversion job describes the files to be converted and the operation to perform on them.

Each file is considered to be a conversion item, and the conversion item will be mapped to Conversion job. Conversion job contains one or more conversion items.

Document Queue:

Document Queue is a "first in, first out", which is used to start the conversion and that schedule can be set in the conversion job.

Using API you can convert the word documents into different formats. There are three main methods that are used for server side document conversions.

  • AddFile()
  • AddFolder()
  • AddLibrary()

For AddFile() method refer http://www.c-sharpcorner.com/UploadFile/anavijai/4816/
For AddFolder() method refer http://www.c-sharpcorner.com/UploadFile/anavijai/4823/
For AddLibrary() method refer http://www.c-sharpcorner.com/UploadFile/anavijai/4822/

Using powershell you can use Word Automation Service application to convert the word document into other formats. Refer http://www.c-sharpcorner.com/UploadFile/anavijai/4820/ and http://www.c-sharpcorner.com/UploadFile/anavijai/4801/Default.aspx.

3. Word Automation Tool

Word Automation Tool is developed for converting the documents into other formats using SharePoint 2010 Word Automation Service Application. Documents are converted into different formats in the Server side that are supported by the Microsoft Word Client Application. The tool looks like the following.

WordAutoTool4.gif

4. Parameters required for Word Automation Tool:

Site Collection URL:

We need to specify the site collection URL where we need to perform the document conversion.

Service Proxy Name:

From the farm all the word service application proxy is retrieved and it is added to the combo box. By default index 0 will be selected.

Save Formats:

The supported documents save formats are added to the combo box and by default index 0 is selected. We can select any of the following save formats.

WordAutoTool5.gif

File Conversion:

There are three main methods for document conversions AddFile(), AddFolder() and AddLibrary(). These three methods are added to the combo box and we can select any of the following methods

WordAutoTool6.gif

Based on the selection of file conversion methods the input and output fields change in the UI.

Convert File:

WordAutoTool7.gif

Convert Folder:

WordAutoTool8.gif

Convert Library:

WordAutoTool9.gif

5. Validations:

The following validations are performed before converting the documents to other formats.

btnValidate_Click Event:

For this event the following validations are performed

The URL entered is not well-formed:

WordAutoTool10.gif

Cannot connect to the SharePoint site:

WordAutoTool11.gif

Successfully connected to SharePoint site:

WordAutoTool12.gif

btnConvert_Click Event:

For this event the following validations are performed

The URL entered is not well-formed:

WordAutoTool13.gif

Cannot connect to the SharePoint site:

WordAutoTool14.gif

Please enter the URL:

WordAutoTool15.gif

Please enter the input:

WordAutoTool16.gif

6. Result:

Once the document is converted status of the conversion will be shown in the result as shown in the following.

WordAutoTool17.gif

The failed document file path will also be displayed in the result window.

The input document is of Document (.doc) type. It can be converted into the following file formats.

WordAutoTool18.gif


Note: If you are trying to convert the entire library all the folders and subfolders which contains the correct document formats will be converted into the desired save formats. If other than source file types that are supported by word automation service application are available in the input library or folder or file will not be converted into the desired save format, and also will no show the status as failed.

WordAutoTool19.gif

7. References:

Up Next
    Ebook Download
    View all
    Learn
    View all