IDocumentConversionService
Wisej.AI.Services.IDocumentConversionService
Namespace: Wisej.AI.Services
Assembly: Wisej.AI (3.5.0.0)
Represents a service interface for converting documents from one format to another.
public interface IDocumentConversionService
Implementations of this interface provide functionality to convert documents that are provided as a stream. This allows for flexibility in handling documents from various sources such as files or network streams. Usage of this interface requires specifying the desired output file type and optionally providing metadata for the document being converted.
Methods
Convert(stream, fileType, metadata, iterator)

Converts a document from a provided stream to plain text.
stream
The stream containing the document to be converted. It must be readable and positioned at the start of the document.
fileType
The format of the input stream represented as a string. It should be the file type, i.e.: "pdf", "docx", "html", ...
metadata
An optional output parameter to receive metadata about the document. If not provided, the default is null
.
iterator
An optional function to process each page or paragraph or section of the document being converted.
Returns: String. An string representing the converted document.
This method reads a document of type fileType from the specified stream and convert it to an array strings representing either line, paragraphs or pages, depending on the conversion implementation. If the metadata parameter is provided, this method will output additional information about the document, such as the title, author, subject, pages, etc. If the iterator parameter is provided, this method will call it for each section of the document it is converting and will use the returned string value to compose the converted text. Example usage:
using System.IO;
public class DocumentConverter
{
private readonly IDocumentConversionService _conversionService;
public DocumentConverter(IDocumentConversionService conversionService)
{
_conversionService = conversionService;
}
public void ConvertDocument()
{
using (FileStream fileStream = new FileStream("input.docx", FileMode.Open, FileAccess.Read))
{
string convertedDocument = _conversionService.Convert(fileStream, "pdf");
// Use the converted document
}
}
}
Throws:
ArgumentNullException Thrown when stream or fileType is
null
.
Implemented By
Provides functionality to convert documents from various formats into text representations.
Last updated