You are here: dtSearch.Engine > FileConverter Class
FileConverter Class
dtSearch Engine API for .NET Framework 2.x-4.x
FileConverter Class

Converts files to HTML, RTF, or text, optionally marking hits with caller-supplied tags.

Visual Basic
public class FileConverter : DisposableObject;

Use SetInputItem to set up most of the properties of FileConverter from an item in SearchResults. SetInputItem will set the InputFile, InputTypeId, InputDocId, Hits, AlphabetLocation, and IndexRetrievedFrom. If the index was built with caching of documents, SetInputItem will also set up FileConverter to retrieved the cached version of the document from the index. 

The document data to convert can consist of one binary document file, such as a Word document, and any number of field-value pairs in InputFields. InputText can be used to provide additional text to include in the converted output. 

The binary document file to convert can be provided either as a disk file, in which InputFile is the name of the file to convert, or in a memory buffer in InputBytes, or through InputStream. InputText and InputFields are assumed to contain nothing but plain text (not HTML or RTF, which must be provided through InputFile or InputBytes). 

InputFile must be an accessible disk file. UNC paths will work, provided that the network resource can be accessed, but HTTP paths will not. To convert data accessed by HTTP, download the data to a memory buffer and supply it in InputBytes or InputStream

Even when InputBytes or InputStream is used, a filename should be provided in InputFile if possible to tell dtSearch the original filename extension, which can provide useful information about the document format. 

If the original data was indexed using the DataSource indexing API, then to highlight hits set InputBytes, InputFields, and InputText to the same values that were returned from the data source as DocBytes, DocFields, and DocText when the document was indexed. 

The BeforeHit and AfterHit markers are inserted before and after each hit word. The BeforeHit and AfterHit markers can contain hypertext links. To facilitate creation of hit navigation markers, the strings "%%ThisHit%%", "%%NextHit%%", and "%%PrevHit%%" will be replaced with ordinals representing the current hit, the next hit, and the previous hit in the document.


When using the dtSearch Engine API, it is essential to use the IDisposable pattern with all API objects except JobErrorInfo. Otherwise, the .NET garbage collector may take a long time to free memory used by potentially large objects such as SearchResults, resulting in memory depletion in long-running applications. In C# code, use a "using" clause with dtSearch Engine API objects, and in other code call Dispose() when you are done with an object.

See also

Highlighting hits - overview 

Caching documents

Copyright (c) 1998-2019 dtSearch Corp. All rights reserved.