CodePlex project for Word Automation Services

19 comments

I’ve just published the first release for a CodePlex project I started to provide sample projects / solutions for using the Word Automation Services in SharePoint 2010.

Word Automation Services allow you to convert document to and from different formats.

File formats the service can read:

  • Office Open XML (DOCX, DOCM, DOTX, DOTM)
  • Word 97-2003 Document (DOC) and Word 97-2003 Template (DOT)
  • Rich Text Format (RTF)
  • Single File Web Page (MHTML)
  • HTML
  • Word 2003 XML
  • Word 2007/2010 XML

File formats the service can write:

  • PDF
  • XPS
  • Office Open XML (DOCX, DOCM)
  • Word 97-2003 Document (DOC)
  • Rich Text Format (RTF)
  • Single File Web Page (MHTML)
  • Word 2007/2010 XML

(source)

As far as I’ve found out, there are no UI features available out-of-the-box to use these services, so I’ve decided to create some. The first one is a custom workflow action you can use in SharePoint Designer to convert a document to many of the supported
formats.

In the workflow designer you can add the “Convert Document” action:

Workflow Actions

The action is inserted into the workflow step where you can specify the url of the output file, select the output format and save options and select a variable for storing the conversion job id (which you can use later to retrieve the status, as the job runs asynchronous):

Convert document action

Save Behaviour

The job id is also logged into the Workflo w History Log (the second entry is from a second workflow action that logs the returned conversion job id variable):

image

After the job has run, which can take up to a few minutes (depending on the word automation services settings), the converted document appears in the library:

image

The custom workflow action is one of the first features for Word Automation in SharePoint 2010 I’ve planned to release. Other features will be a Ribbon and Item context menu extension and more Workflow actions.

Let me know if you have any suggestions for improvement or other functionality you would like to see.

Related posts:

  1. New sample project for SP2010 Word Automation: UI
  2. 2 new worflow activities added to SP2010 Word Automation
Tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

18 Comments

  1. kranthi
    Posted July 8, 2010 at 1:32 am | Permalink

    hi peter,

    Nice artcile and great solution.

    I’m using your sharepoint solutions to convert documents to pdf through workflow. I have created the workflow with convert document action and added output document url but its not working. please help how to set the appropirate output document url with examples.

  2. Peter Gerritsen
    Posted July 8, 2010 at 7:26 pm | Permalink

    You will need to use the full url to the outputfile.

    The workflow action will simply call the following method:
    http://msdn.microsoft.com/en-us/library/microsoft.office.word.server.conversions.conversionjob.addfile.aspx

  3. gab
    Posted August 23, 2010 at 10:01 pm | Permalink

    I got the following error when i tried to activate the solution to my sharepoint server
    This solution contains invalid markup or elements that cannot be deployed as part of a sandboxed solution. Solution manifest for solution ’8a318b41-0260-49c9-a627-4fe83ad052d8′ failed validation, file manifest.xml, line 6, character 4: The element ‘Solution’ in namespace ‘http://schemas.microsoft.com/sharepoint/‘ has invalid child element ‘TemplateFiles’ in namespace ‘http://schemas.microsoft.com/sharepoint/'. List of possible elements expected: ‘FeatureManifests, ActivationDependencies’ in namespace ‘http://schemas.microsoft.com/sharepoint/'.

    Troubleshoot issues with Microsoft SharePoint Foundation.

  4. Peter Gerritsen
    Posted August 23, 2010 at 10:19 pm | Permalink

    That’s because this solution is not supported as a sandbox solution. It needs to deploy files to the _layouts folder.

  5. Dave
    Posted November 15, 2010 at 11:00 pm | Permalink

    So helpful – thanks for publishing this! Now that MOSS 2010 is taking off, this will be really, really helpful (we’re going to test and deploy).

    One addition that would be cool is a workflow that, instead of writing to a library, would send by e-mail, or simply activate a download… e.g., “Download as .Doc” or “Download as .DocX” to help the people who don’t have newer versions of MSWord software…

    Anyway — great work, thanks again!
    –DC

  6. Mike C
    Posted January 11, 2011 at 6:06 pm | Permalink

    Thanks so much for all you’ve done to put these this together! I’ve got everything working as it should but I’m having trouble with the output URL. I’ve tried /folder, http://site/folder, folder, etc…and everything returns an error. Am I missing something?

    Thanks in advance!

    Mike

  7. Peter Gerritsen
    Posted January 11, 2011 at 8:03 pm | Permalink

    You will need to specify the full url, including the filename and extension.

  8. Tom
    Posted January 17, 2011 at 4:24 pm | Permalink

    Have everything implemented. For some reason, on the screen where I can choose the format and the destination, this screen will always come back, once I click OK.
    What I`m doing wrong ?

  9. Nirav
    Posted January 25, 2011 at 2:54 pm | Permalink

    Hi Guys,

    I am trying to convert infopath form into pdf format.

    I think I have done everything but still not getting the output file. For you understanding, I will put the steps I have done:
    1) I have used SP2010WordAutomation.Workflow.wsp.
    2) I published infopath form to a forms library in SP 2010 site
    3) I opened up my sharepoint 2010 designer and created a reusable workflow with content type.
    4) I used following action from SP 2010 designer,
    Convert documents in library with url http://servername/formlib, using outputformat PDF, store the documents in library with url http://servername/pdflib and place the job id in variable: conversion job id3; if the document already exists “Always overwrite”
    5) Once this is done I publish the workflow….
    6) Then I go to library http://servername/formlib where my infopath forms can be added using “Add Document”.
    7) When I add one form document – The status of the workflow column changes to “In Progress” then after some time it changes to “Completed”.
    8) On clicking the workflow status to check workflow information to check whats happening, it shows
    Conversion Job with Id= some id started. Under outcome heaer there is nothing
    9) But when I go to library http://servername/pdflib, I dont get the converted file.

    Can somebody please tell me what am I missing.

    Thanks for you valuable time.

    Thanks,
    Nirav.
    niravsakhi@hotmail.com

  10. Peter Gerritsen
    Posted January 25, 2011 at 3:41 pm | Permalink

    InfoPath is not a valid input format for Word Automation services. You can see this in the list in the top of this post.

    Peter

  11. Nirav
    Posted January 25, 2011 at 4:06 pm | Permalink

    Peter,

    Thanks for that. Do you have any option where I can do research for this requirment.

    Thanks,
    Nirav.

  12. Sapukai
    Posted March 10, 2011 at 3:14 pm | Permalink

    Hi, sorry, but, I download de .wsp file, but how I can use it? I don´t known how import it to my Sharepoint Server, or how to use this file, please, help me with some tips. Thanks and great work Peter!

  13. Dave Fleming
    Posted March 30, 2011 at 1:58 am | Permalink

    I cannot get this to activate unless I activate the “Microsoft SharePoint Foundation Sandboxed Code Service”. When I do that, it gives me the same error as above. What services do I need active to activate this solution? FYI – I’m a newbie

  14. Chris Miller
    Posted August 10, 2011 at 5:46 pm | Permalink

    Hi Peter,
    I was wondering if you have a copy list item activity that will use “append to version history…”.
    I have the need for it, my situation is: Document needs to be moved/copied from one list to another, but append to version history. then the document needs to be deleted. the OOTB has a copy, which overwrites everything, I just need it append to the version history.
    If you have it, please let me know.
    Thanks in advance
    Chris.

  15. mike
    Posted September 9, 2011 at 4:40 pm | Permalink

    This is great, thanks. Though, I’m running into a workflow issue. I’m using your activity in a workflow in library A to convert a doc to a pdf which lands in library B. I have another workflow in library B that is set to start for every new item. This workflow generates a “failed on start message” for the inbound pdfs. To be clear:

    1. manually running the workflow in library B: works fine
    2. uploading a doc (which therefore triggers the workflow) in library B: works fine
    3. Using word automation services via your activity to generate a pdf in library B: The workflow in library B throws an error. (failed on start)

    The workflow in library B has one action: log to history list.

    Any thoughts?

  16. Posted January 5, 2012 at 11:09 pm | Permalink

    Hi Peter,
    Overall your solution has worked for me. However, I’ve run into a couple scenarios (2 server environments out of 5) where the solution suddenly stops working and i have to go into the workflow and remove then readd the line to “Convert Current Document…”. Then it works again. Have you experienced this issue and do you have any advice for what might be happening? There were no changes to Word Automation services and no Sharepoint updates applied when it happened.
    thanks!

  17. Peter Gerritsen
    Posted January 6, 2012 at 9:24 am | Permalink

    Hi Steph,

    I haven’t used the solution in a lot of production scenarios for very long, so I’ve got no experiences with this happening.
    My first guess would be that the code is somewhat buggy and might contain some memory leaks, which causes the workflow action to stop working.

    Peter

  18. Kalona
    Posted February 1, 2012 at 6:07 pm | Permalink

    Hi

    I’ve installed from codeplex OK and I can see the workflow actions in the workflow list. But if I pick one nothing happens – doesn’t appear in my workflow – any ideas? (using SP2010 Server Enterprise with one WFE and one APP Server)

    Thanks

One Trackback

  1. [...] Dit blogartikel was vermeld op Twitter door PB Coleman en Gert Lambers, Gert Lambers. Gert Lambers heeft gezegd: #Word #automation services in #sharepoint. Very interesting post of Peter Gerritsen how to implement! http://ow.ly/2y4jH [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>