MarkdownSaveOptions

MarkdownSaveOptions class

Class to specify additional options when saving a document into the Markdown format.

To learn more, visit the Specify Save Options documentation article.

public class MarkdownSaveOptions : TxtSaveOptionsBase

Constructors

NameDescription
MarkdownSaveOptions()Initializes a new instance of this class that can be used to save a document in the Markdown format.

Properties

NameDescription
AllowEmbeddingPostScriptFonts { get; set; }Gets or sets a boolean value indicating whether to allow embedding fonts with PostScript outlines when embedding TrueType fonts in a document upon it is saved. The default value is false.
CustomTimeZoneInfo { get; set; }Gets or sets custom local time zone used for date/time fields.
DefaultTemplate { get; set; }Gets or sets path to default template (including filename). Default value for this property is empty string (Empty).
Dml3DEffectsRenderingMode { get; set; }Gets or sets a value determining how 3D effects are rendered.
virtual DmlEffectsRenderingMode { get; set; }Gets or sets a value determining how DrawingML effects are rendered.
DmlRenderingMode { get; set; }Gets or sets a value determining how DrawingML shapes are rendered.
Encoding { get; set; }Specifies the encoding to use when exporting in text formats. Default value is Encoding.UTF8.
ExportAsHtml { get; set; }Allows to specify the elements to be exported to Markdown as raw HTML. Default value is None.
ExportGeneratorName { get; set; }When true, causes the name and version of Aspose.Words to be embedded into produced files. Default value is true.
ExportHeadersFootersMode { get; set; }Specifies the way headers and footers are exported to the text formats. Default value is PrimaryOnly.
ExportImagesAsBase64 { get; set; }Specifies whether images are saved in Base64 format to the output file. Default value is false.
ExportUnderlineFormatting { get; set; }Gets or sets a boolean value indicating either to export underline text formatting as sequence of two plus characters “++”. The default value is false.
ForcePageBreaks { get; set; }Allows to specify whether the page breaks should be preserved during export.
ImageSavingCallback { get; set; }Allows to control how images are saved when a document is saved to Markdown format.
ImagesFolder { get; set; }Specifies the physical folder where images are saved when exporting a document to the Markdown format. Default is an empty string.
ImagesFolderAlias { get; set; }Specifies the name of the folder used to construct image URIs written into a document. Default is an empty string.
ImlRenderingMode { get; set; }Gets or sets a value determining how ink (InkML) objects are rendered.
LinkExportMode { get; set; }Specifies how links will be written to the output file. Default value is Auto.
ListExportMode { get; set; }Specifies how list items will be written to the output file. Default value is MarkdownSyntax.
MemoryOptimization { get; set; }Gets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is false.
ParagraphBreak { get; set; }Specifies the string to use as a paragraph break when exporting in text formats.
PrettyFormat { get; set; }When true, pretty formats output where applicable. Default value is false.
ProgressCallback { get; set; }Called during saving a document and accepts data about saving progress.
override SaveFormat { get; set; }Specifies the format in which the document will be saved if this save options object is used. Can only be Markdown.
TableContentAlignment { get; set; }Gets or sets a value that specifies how to align contents in tables when exporting into the Markdown format. The default value is Auto.
TempFolder { get; set; }Specifies the folder for temporary files used when saving to a DOC or DOCX file. By default this property is null and no temporary files are used.
UpdateCreatedTimeProperty { get; set; }Gets or sets a value determining whether the CreatedTime property is updated before saving. Default value is false;
UpdateFields { get; set; }Gets or sets a value determining if fields of certain types should be updated before saving the document to a fixed page format. Default value for this property is true.
UpdateLastPrintedProperty { get; set; }Gets or sets a value determining whether the LastPrinted property is updated before saving.
UpdateLastSavedTimeProperty { get; set; }Gets or sets a value determining whether the LastSavedTime property is updated before saving.
UseAntiAliasing { get; set; }Gets or sets a value determining whether or not to use anti-aliasing for rendering.
UseHighQualityRendering { get; set; }Gets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms.

Examples

Shows how to rename the image name during saving into Markdown document.

public void RenameImages()
{
    Document doc = new Document(MyDir + "Rendering.docx");

    MarkdownSaveOptions saveOptions = new MarkdownSaveOptions();
    // If we convert a document that contains images into Markdown, we will end up with one Markdown file which links to several images.
    // Each image will be in the form of a file in the local file system.
    // There is also a callback that can customize the name and file system location of each image.
    saveOptions.ImageSavingCallback = new SavedImageRename("MarkdownSaveOptions.HandleDocument.md");
    saveOptions.SaveFormat = SaveFormat.Markdown;

    // The ImageSaving() method of our callback will be run at this time.
    doc.Save(ArtifactsDir + "MarkdownSaveOptions.HandleDocument.md", saveOptions);

    Assert.AreEqual(1,
        Directory.GetFiles(ArtifactsDir)
            .Where(s => s.StartsWith(ArtifactsDir + "MarkdownSaveOptions.HandleDocument.md shape"))
            .Count(f => f.EndsWith(".jpeg")));
    Assert.AreEqual(8,
        Directory.GetFiles(ArtifactsDir)
            .Where(s => s.StartsWith(ArtifactsDir + "MarkdownSaveOptions.HandleDocument.md shape"))
            .Count(f => f.EndsWith(".png")));
}

/// <summary>
/// Renames saved images that are produced when an Markdown document is saved.
/// </summary>
public class SavedImageRename : IImageSavingCallback
{
    public SavedImageRename(string outFileName)
    {
        mOutFileName = outFileName;
    }

    void IImageSavingCallback.ImageSaving(ImageSavingArgs args)
    {
        string imageFileName = $"{mOutFileName} shape {++mCount}, of type {args.CurrentShape.ShapeType}{Path.GetExtension(args.ImageFileName)}";

        args.ImageFileName = imageFileName;
        args.ImageStream = new FileStream(ArtifactsDir + imageFileName, FileMode.Create);

        Assert.True(args.ImageStream.CanWrite);
        Assert.True(args.IsImageAvailable);
        Assert.False(args.KeepImageStreamOpen);
    }

    private int mCount;
    private readonly string mOutFileName;
}

See Also