Click or drag to resize

OfficeSession Class

Creates a disposable Office session for use with the OfficeAdapterDecoder for decoding a batch of images.
Inheritance Hierarchy
SystemObject
  Atalasoft.Imaging.Codec.OfficeOfficeSession

Namespace:  Atalasoft.Imaging.Codec.Office
Assembly:  Atalasoft.dotImage.Office (in Atalasoft.dotImage.Office.dll) Version: 11.0.0.0.0.297 (.NET 4.5.2, x86)
Syntax
public sealed class OfficeSession : IDisposable

The OfficeSession type exposes the following members.

Constructors
  NameDescription
Public methodOfficeSession
Initializes a new instance of the OfficeSession class
Top
Methods
  NameDescription
Public methodClose
Closes the OfficeSession, releasing any open Office applications.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Releases unmanaged resources and performs other cleanup operations before the OfficeSession is reclaimed by garbage collection.
(Overrides ObjectFinalize.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberOpen
Opens a new OfficeSession. This session must be Disposed or Closed when it is no longer needed.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
Using the OfficeSession with the OfficeAdapterDecoder to decode a batch of various documents:
// By default, the office decoder will create a new session for each document decoded.
// This leads to performance degradation if the same decoder is used to decode several files.
// To remedy this, the OfficeSession class was created, which encapulates a set of running Office
// applications, leaving them open for as long as they are needed.
// The session implements IDisposable, and must be disposed or have the Close method called when it is no longer needed.
using(OfficeSession officeSession = OfficeSession.Open())
{
    OfficeDecoder officeDecoder = new OfficeDecoder(officeSession);

    // With the OfficeDecoder created using the session, we now decode images as usual.
    // The decoder will now use the Office applications provided by the OfficeSession.

    using(Stream wordDocumentStream = File.OpenRead("wordDocument.doc"))
    {
        AtalaImage wordDocumentImage = officeDecoder.Read(wordDocumentStream, null);
    }
    using(Stream wordXmlDocumentStream = File.OpenRead("wordXmlDocument.docx"))
    {
        AtalaImage wordXmlDocumentImage = officeDecoder.Read(wordXmlDocumentStream, null);
    }
    using(Stream excelDocumentStream = File.OpenRead("excelDocument.ppt"))
    {
        AtalaImage excelDocumentImage = officeDecoder.Read(excelDocumentStream, null);
    }
    using(Stream excelXmlDocumentStream = File.OpenRead("excelXmlDocument.pptx"))
    {
        AtalaImage excelXmlDocumentImage = officeDecoder.Read(excelXmlDocumentStream, null);
    }
}
Thread Safety
Static members of this type are not safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.
See Also