locked
Word Automation Service in Sharepoint 2010 RRS feed

  • Question

  • I have two document libraries, in one i attached Event Handler on ItemUpdated. Event Handler Convert that .doc file to .pdf and add it in to other document library.

    I done that part successfully, but my problem is that the metadata(column's data) of the source document library(on which i attached event handler) is lost for the destination document library(.pdf file).

    It perfectly works when i convert .doc to .docx, i mean when i convert .doc to .docx instead of .pdf my metadata will remain same.

    How can i solve my problem? Any body can help me out. Thanks in Advance !!! 


    Thursday, April 7, 2011 6:45 AM

Answers

  • I Found one Solution that .pdf is not SharePoint Document Library file type. So when we convert .doc or .docx file to .pdf it can't set metadata field value with it.

    In the case of .doc or .docx file(both are SharePoint Document Library file type) so it convert with metadata.

    So in .pdf case we have to update metadata manually. I attached the code to update metadata of destination(converted file) below.

     

    foreach (SPField field in fileSource.Item.Fields)

                {

                    if (field.CanBeDisplayedInEditForm)

                        spfilePDF.Item[field.InternalName] = fileSource.Item[field.InternalName];

                }

                spfilePDF.Item.Update();

    Friday, April 8, 2011 5:38 AM

All replies

  • Keyur

    Please see following urls, hope this helps you

    http://archive.msdn.microsoft.com/odcwd14h2/Release/ProjectReleases.aspx?ReleaseId=3798

    also see sharepoint 2010 SDK sample code http://archive.msdn.microsoft.com/sp2010sdk

     


    Ashish Kanoongo, MCP, MCSD, MCTS
    Thursday, April 7, 2011 11:11 AM
  • I Found one Solution that .pdf is not SharePoint Document Library file type. So when we convert .doc or .docx file to .pdf it can't set metadata field value with it.

    In the case of .doc or .docx file(both are SharePoint Document Library file type) so it convert with metadata.

    So in .pdf case we have to update metadata manually. I attached the code to update metadata of destination(converted file) below.

     

    foreach (SPField field in fileSource.Item.Fields)

                {

                    if (field.CanBeDisplayedInEditForm)

                        spfilePDF.Item[field.InternalName] = fileSource.Item[field.InternalName];

                }

                spfilePDF.Item.Update();

    Friday, April 8, 2011 5:38 AM
  • Thanks for posting your solution, Keyur.  I assume you used Word Automation Services to perform the conversion from .DOC to .PDF. 

    However, if the code doesn't recognize when the converted document is added by Word Automation Services, where did you place this code to get the metadata from the source document to the destination document?

    Thanks for your insight.

    Tuesday, February 26, 2013 7:52 PM