Share via


Custom Processing of Converted Documents

By default, Microsoft Office SharePoint Server 2007 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 Office SharePoint Server 2007 performs by default, see Converted Documents.

Custom Pre-Processing of Converted Documents

To perform custom pre-processing actions before Office SharePoint Server 2007 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 **T:Microsoft.SharePoint.**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, Office SharePoint Server 2007 in turn calls your custom assembly using the PreProcess method. The assembly can then perform its actions, and return a byte array that represents the file to be converted to Office SharePoint Server 2007. Office SharePoint Server 2007, in turn, passes this byte array to the document converter.

Custom Post-Processing of Converted Documents

To replace the post-processing actions Office SharePoint Server 2007 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, Office SharePoint Server 2007 calls your custom assembly using the PostProcess method. The custom assembly can perform its post-processing actions. In this case, Office SharePoint Server 2007 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 Office SharePoint Server 2007 is finished with its post-processing of the converted copy, write a code handler that listens for the Convert list event. Office SharePoint Server 2007 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, while the After properties refer to the converted copy.

For more information about creating event handlers in Windows SharePoint Services, see the Microsoft Windows SharePoint Services 3.0 SDK.

See Also

Concepts

Document Converters Overview
Document Converters
Converted Documents