ToFile
ToFile(string, string)
Converts a document to Markdown and saves the result directly to a file. This is the simplest way to produce a Markdown file from a supported document format.
public static void ToFile(string sourcePath, string outputPath)
| Parameter |
Type |
Description |
| sourcePath |
String |
The path to the source document (e.g. "report.pdf"). |
| outputPath |
String |
The path where the Markdown file will be created or overwritten. |
Exceptions
| exception |
condition |
| GroupDocsMarkdownException |
Thrown when the conversion fails. |
| ArgumentNullException |
Thrown when sourcePath is null or empty. |
| NotSupportedException |
Thrown when the file format is not supported. |
Examples
MarkdownConverter.ToFile("document.docx", "output.md");
See Also
ToFile(string, string, ConvertOptions)
Converts a document to Markdown with the specified conversion options and saves the result to a file.
public static void ToFile(string sourcePath, string outputPath, ConvertOptions convertOptions)
| Parameter |
Type |
Description |
| sourcePath |
String |
The path to the source document. |
| outputPath |
String |
The path where the Markdown file will be created or overwritten. |
| convertOptions |
ConvertOptions |
Options that customize the conversion (image strategy, heading offset, page numbers). May be null. |
Exceptions
| exception |
condition |
| GroupDocsMarkdownException |
Thrown when the conversion fails. |
| NotSupportedException |
Thrown when the file format is not supported. |
Examples
var options = new ConvertOptions
{
ImageExportStrategy = new ExportImagesToFileSystemStrategy("images")
};
MarkdownConverter.ToFile("report.docx", "report.md", options);
See Also
ToFile(string, string, LoadOptions, ConvertOptions)
Converts a document to Markdown with the specified load and conversion options, saving the result to a file. This is the most flexible static overload for file-based output.
public static void ToFile(string sourcePath, string outputPath, LoadOptions loadOptions,
ConvertOptions convertOptions)
| Parameter |
Type |
Description |
| sourcePath |
String |
The path to the source document. |
| outputPath |
String |
The path where the Markdown file will be created or overwritten. |
| loadOptions |
LoadOptions |
Options for loading the document (password, format hint). May be null. |
| convertOptions |
ConvertOptions |
Options that customize the conversion. May be null. |
Exceptions
| exception |
condition |
| GroupDocsMarkdownException |
Thrown when the conversion fails. |
| NotSupportedException |
Thrown when the file format is not supported. |
See Also