17 Sep 2011

File Conversion Services SharePoint

It is a feature of SharePoint2007

“Document Converter Services Overview,” available on MSDN Online at http://msdn.microsoft.com/en-us/library/aa979484.aspx

Developing a custom document converter of your own, you can read the document, “Document Converter Framework Sample,” available on MSDN Online at
http://msdn.microsoft.com/en-us/library/bb897921.aspx

 

Word Automation Services

Supported input formats:
Open XML File Format documents (.docx, .docm, .dotx, .dotm)
Word 97-2003 documents (.doc, .dot)
Rich Text Format files (.rtf)
Webpages (.htm, .html, .mht, .mhtml)
Word 2003 XML Documents (.xml)

 

supported output formats are:
Open XML File Format documents (.docx, .docm, .dotx, .dotm)
Word 97-2003 documents (.doc, .dot)
Rich Text Format files (.rtf)
Webpages (.htm, .html, .mht, .mhtml)
Word 2003 XML Documents (.xml)
Portable Document Format (.pdf)
Open XML Paper Specification (.xps)

 

image

Converts a document from .DOC to .XPS by using the Server Object Model of the Word Automation Services,

   1:  String siteUrl = "http://dev.sp2010.local/";
   2:  String wordAutomationServiceName = "Word Automation Services";
   3:  using (SPSite site = new SPSite(siteUrl)) {
   4:  using (SPWeb web = site.OpenWeb()) {
   5:  SPFile sourceFile = web.GetFile("Shared%20Documents/Source.doc");
   6:  ConversionJob job = new ConversionJob(wordAutomationServiceName);
   7:  job.UserToken = site.UserToken;
   8:  job.Settings.UpdateFields = true;
   9:  job.Settings.OutputFormat = SaveFormat.XPS;
  10:  String sourceUrl = web.Url + "/" + sourceFile.Url;
  11:  String destinationUrl = web.Url + "/" +
  12:  sourceFile.Url.Replace(".doc", ".xps");
  13:  job.AddFile(sourceUrl, destinationUrl);
  14:  job.Start();
  15:  }
  16:  }




 


How to monitor the status of a conversion job?


   1:  static void MonitorJob(Guid jobId) {
   2:  ConversionJobStatus job = new ConversionJobStatus(
   3:  "Word Automation Services", // Name of the service instance
   4:  jobId, // The JobId to monitor
   5:  null); // Guid of the subscription in case of multiple servers
   6:  Console.WriteLine("Job name: {0}", job.Name);
   7:  Console.WriteLine("Total job activities:\t\t{0}", job.Count);
   8:  Console.WriteLine("Job activities succeeded:\t\t{0}", job.Succeeded);
   9:  Console.WriteLine("Job activities failed:\t\t{0}", job.Failed);
  10:  Console.WriteLine("Job activities in progress:\t\t{0}", job.InProgress);
  11:  Console.WriteLine("Job activities canceled:\t\t{0}", job.Canceled);
  12:  Console.WriteLine("Job activities not started:\t\t{0}", job.NotStarted);
  13:  }



 


Important Classes:


ConversionJob class, provided by the Word Automation Services’ engine and available in assembly Microsoft.Office.Word [named Microsoft Office 2010 Component]


ConversionJobStatus

No comments:

Post a Comment