Share via


Custom Processing of Converted Documents in SharePoint Server 2010 (ECM)

Applies to: SharePoint Server 2010

In this article
Custom Pre-Processing of Converted Documents
Custom Post-Processing of Converted Documents
Additional Post-Processing of Converted Documents

By default, Microsoft SharePoint Server 2010 performs several post-processing functions on the converted copy it receives from the document converter, such as adding the original file's metadata to the copy, and placing the copy back in the same document library as the original. However, you can replace these post-processing actions with your own, or append additional actions. You can also perform custom processing before the document converter is called.

For more information about the post-processing SharePoint Server 2010 performs by default, see Converted Documents in SharePoint Server 2010 (ECM).

Custom Pre-Processing of Converted Documents

To perform custom pre-processing actions before SharePoint Server 2010 passes the original file to the document converter, create an assembly that implements the ISPConversionProcessor interface. The PreProcess method of this interface takes two arguments:

  • A byte array that represents the byte stream of the original file.

  • An SPExecutingConversionRequest object, which contains read-only properties that represent the arguments passed to the Convert method, such as custom configuration information to pass to the document converter, the file name of the converted copy, the conversion priority, the e-mail addresses of people to alert, and whether or not to include the converted copy as an attachment to the alert.

To invoke your custom pre-processing assembly, set two parameters of the Convert method:

  • Set the handlerAssembly parameter to a string that represents the location of your custom assembly.

  • Set the handlerClass parameter to a string the represents the name of the class in your assembly to call for pre-processing.

When you call the Convert method with these parameters set this way, SharePoint Server 2010 in turn calls your custom assembly by using the PreProcess method. The assembly can then perform its actions, and return a byte array that represents the file to be converted to SharePoint Server 2010. SharePoint Server 2010, in turn, passes this byte array to the document converter.

Custom Post-Processing of Converted Documents

To replace the post-processing actions SharePoint Server 2010 performs with your own, create an assembly that implements the ISPConversionProcessor interface. The PostProcess method of this interface takes two arguments:

  • An SPExecutingConversionRequest object, which contains read-only properties that represent the arguments passed to the Convert method, such as custom configuration information to pass to the document converter, the file name of the converted copy, the conversion priority, the e-mail addresses of people to alert, and whether or not to include the converted copy as an attachment to the alert. In addition, the object includes a byte array that represents the converted file.

  • An unknown-type that represents the result.

To invoke your custom post-processing assembly, set two parameters of the Convert method:

  • Set the handlerAssembly parameter to a string that represents the location of your custom assembly.

  • Set the handlerClass parameter to a string the represents the name of the class in your assembly to call for post-processing.

When you call the Transform method with these parameters set this way after the document converter has generated a converted copy of the original file, SharePoint Server 2010 calls your custom assembly by using the PostProcess method. The custom assembly can perform its post-processing actions. In this case, SharePoint Server 2010 performs no post-processing, and does not move the converted copy to the same document library as the original.

Additional Post-Processing of Converted Documents

To perform additional post-processing actions after SharePoint Server 2010 is finished with its post-processing of the converted copy, write a code handler that listens for the Convert list event. SharePoint Server 2010 raises this event when a document is successfully converted, processed, and placed back in the same document library as the original file from which it was generated.

Note

The Before properties of the event refer to the original file, and the After properties refer to the converted copy.

See Also

Concepts

SharePoint Server 2010 Document Converter Development Overview (ECM)

Document Converters in SharePoint Server 2010 (ECM)

Converted Documents in SharePoint Server 2010 (ECM)