LoadOptions

LoadOptions class

Specifies additional options for loading a document, such as an explicit file format or a password for encrypted files.

public class LoadOptions

Constructors

Name Description
LoadOptions() Initializes a new instance of the LoadOptions class with automatic format detection.
LoadOptions(FileFormat) Initializes a new instance of the LoadOptions class with an explicit file format.

Properties

Name Description
FileFormat { get; } Gets the file format of the document to load.
Password { get; set; } Gets or sets the password for opening an encrypted document.

Remarks

By default, the library detects the file format automatically from the file extension or content. Use this class when you need to override automatic detection (for example, when loading from a stream without a file name) or when the document is password-protected.

Examples

Specifying the file format explicitly (useful when loading from a stream):

var loadOptions = new LoadOptions(FileFormat.Docx);

using (var stream = File.OpenRead("document"))
using (var converter = new MarkdownConverter(stream, loadOptions))
{
    ConvertResult result = converter.Convert();
    Console.WriteLine(result.Content);
}

Loading a password-protected document:

var loadOptions = new LoadOptions(FileFormat.Docx)
{
    Password = "secret"
};
string markdown = MarkdownConverter.ToMarkdown("protected.docx", loadOptions);

See Also