ExtractorFactory Class
Provides the functionality for creating extractors for documents.
Inheritance Hierarchy
SystemObject
  GroupDocs.ParserExtractorFactory

Namespace: GroupDocs.Parser
Assembly: GroupDocs.Parser (in GroupDocs.Parser.dll) Version: 19.5
Syntax
public class ExtractorFactory : IContainerFactory

The ExtractorFactory type exposes the following members.

Constructors
  NameDescription
Public methodExtractorFactory
Initializes a new instance of the ExtractorFactory class.
Public methodExtractorFactory(DocumentFormatter)
Initializes a new instance of the ExtractorFactory class.
Public methodExtractorFactory(DocumentFormatter, MediaTypeDetector)
Initializes a new instance of the ExtractorFactory class.
Public methodExtractorFactory(DocumentFormatter, MediaTypeDetector, EncodingDetector)
Initializes a new instance of the ExtractorFactory class.
Public methodExtractorFactory(DocumentFormatter, MediaTypeDetector, EncodingDetector, INotificationReceiver)
Initializes a new instance of the ExtractorFactory class.
Properties
  NameDescription
Public propertyDocumentFormatter
Gets a document formatter.
Public propertyEncodingDetector
Gets an encoding detector.
Public propertyMediaTypeDetector
Gets a media type detector.
Methods
  NameDescription
Public methodCreateContainer(Stream)
Creates a container.
Public methodCreateContainer(String)
Creates a container.
Public methodCreateContainer(Stream, LoadOptions)
Creates a container.
Public methodCreateContainer(String, LoadOptions)
Creates a container.
Public methodCreateFormattedTextExtractor(Stream)
Creates a formatted text extractor.
Public methodCreateFormattedTextExtractor(String)
Creates a formatted text extractor.
Public methodCreateFormattedTextExtractor(Stream, LoadOptions)
Creates a formatted text extractor.
Public methodCreateFormattedTextExtractor(String, LoadOptions)
Creates a formatted text extractor.
Public methodCreateMetadataExtractor(Stream)
Creates a metadata extractor.
Public methodCreateMetadataExtractor(String)
Creates a metadata extractor.
Public methodCreateMetadataExtractor(Stream, LoadOptions)
Creates a metadata extractor.
Public methodCreateMetadataExtractor(String, LoadOptions)
Creates a metadata extractor.
Public methodCreateTextExtractor(Stream)
Creates a text extractor.
Public methodCreateTextExtractor(String)
Creates a text extractor.
Public methodCreateTextExtractor(Stream, LoadOptions)
Creates a text extractor.
Public methodCreateTextExtractor(String, LoadOptions)
Creates a text extractor.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetDocumentInfo(Stream)
Returns the information of supported extractors for a document.
Public methodGetDocumentInfo(String)
Returns the information of supported extractors for a document.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodIsContainerSupported
Checks whether container for mediaType is existed.
Protected methodIsFormattedTextSupported
Checks whether formatted text extractor for mediaType is existed.
Protected methodIsMetadataSupported
Checks whether metadata extractor for mediaType is existed.
Protected methodIsTextSupported
Checks whether text extractor for mediaType is existed.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodSendNotificationMessage
Sends notification message to receiver and factory receiver (if presented).
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Remarks

ExtractorFactory provides the functionality to create instances of extractors classes. It contains the following methods:

CreateTextExtractor Creates a text extractor for the file. If the document format is not detected, the method returns null.
CreateFormattedTextExtractor Creates a formatted text extractor for the file. If the document format is not detected, the method returns null.
CreateContainer Creates a container object for the file. If the document format is not detected, the method returns null.
CreateMetadataExtractor Creates a metadata extractor. If the document format is not detected, the method returns null.

For detecting the document format MediaTypeDetector is used. By default all the supported document formats are detected. You can change this behavior by passing a custom MediaTypeDetector instance to the factory constructor.

For formatted text extractors a PlainDocumentFormatter is used. You can change a formatter by passing an instance of a formatter to the factory constructor.

Examples

Creating a text extractor:

C#
// Create a factory
ExtractorFactory factory = new ExtractorFactory();
// Create a text extractor
TextExtractor extractor = factory.CreateTextExtractor(fileName);
// Print a text from the document or message if a file format isn't supported
Console.WriteLine(extractor != null ? extractor.ExtractAll() : "The document format is not supported");

Creating a formatted text extractor:

C#
// Create a factory
ExtractorFactory factory = new ExtractorFactory();
// Create a formatted text extractor
TextExtractor extractor = factory.CreateFormattedTextExtractor(fileName);
// Print a formatted text from the document or message if a file format isn't supported
Console.WriteLine(extractor != null ? extractor.ExtractAll() : "The document format is not supported");

Creating a formatted text extractor with Markdown formatter:

C#
// Create a factory with MarkdownDocumentFormatter as a default formatter
ExtractorFactory factory = new ExtractorFactory(new MarkdownDocumentFormatter());
// Create a formatted text extractor
TextExtractor extractor = factory.CreateFormattedTextExtractor(fileName);
// Print a Markdown-formatted text from the document or message if a file format isn't supported
Console.WriteLine(extractor != null ? extractor.ExtractAll() : "The document format is not supported");

Creating a text extractor only for spreadsheets:

C#
// Create a factory which can detect only spreadsheet's media types
ExtractorFactory factory = new ExtractorFactory(null, new CellsMediaTypeDetector());
// Create a formatted text extractor
TextExtractor extractor = factory.CreateFormattedTextExtractor(fileName);
// Print a formatted text from the document or message if a file format isn't supported
Console.WriteLine(extractor != null ? extractor.ExtractAll() : "The document format is not supported");

Creating a container:

C#
// Create a factory
ExtractorFactory factory = new ExtractorFactory(null, new CellsMediaTypeDetector());
// Create a container
Container container = factory.CreateContainer(fileName);
// If a file format isn't supported
if (container == null)
{
  // Print a message
  Console.WriteLine("The document format is not supported");
}
See Also