XamlFlowSaveOptions

XamlFlowSaveOptions class

Can be used to specify additional options when saving a document into the XamlFlow or XamlFlowPack format.

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

public class XamlFlowSaveOptions : SaveOptions

Constructors

NameDescription
XamlFlowSaveOptions()Initializes a new instance of this class that can be used to save a document in the XamlFlow format.
XamlFlowSaveOptions(SaveFormat)Initializes a new instance of this class that can be used to save a document in the XamlFlow or XamlFlowPack 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.
ExportGeneratorName { get; set; }When true, causes the name and version of Aspose.Words to be embedded into produced files. Default value is true.
ImageSavingCallback { get; set; }Allows to control how images are saved when a document is saved to XAML.
ImagesFolder { get; set; }Specifies the physical folder where images are saved when exporting a document to XAML format. Default is an empty string.
ImagesFolderAlias { get; set; }Specifies the name of the folder used to construct image URIs written into an XAML document. Default is an empty string.
ImlRenderingMode { get; set; }Gets or sets a value determining how ink (InkML) objects are rendered.
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.
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 XamlFlow.
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 print the filenames of linked images created while converting a document to flow-form .xaml.

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

    ImageUriPrinter callback = new ImageUriPrinter(ArtifactsDir + "XamlFlowImageFolderAlias");

    // Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
    // to modify how we save the document to the XAML save format.
    XamlFlowSaveOptions options = new XamlFlowSaveOptions();

    Assert.AreEqual(SaveFormat.XamlFlow, options.SaveFormat);

    // Use the "ImagesFolder" property to assign a folder in the local file system into which
    // Aspose.Words will save all the document's linked images.
    options.ImagesFolder = ArtifactsDir + "XamlFlowImageFolder";

    // Use the "ImagesFolderAlias" property to use this folder
    // when constructing image URIs instead of the images folder's name.
    options.ImagesFolderAlias = ArtifactsDir + "XamlFlowImageFolderAlias";

    options.ImageSavingCallback = callback;

    // A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
    // We must ensure the folder exists before the callback's streams can put their resources into it.
    Directory.CreateDirectory(options.ImagesFolderAlias);

    doc.Save(ArtifactsDir + "XamlFlowSaveOptions.ImageFolder.xaml", options);

    foreach (string resource in callback.Resources)
        Console.WriteLine($"{callback.ImagesFolderAlias}/{resource}");
}

/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private class ImageUriPrinter : IImageSavingCallback
{
    public ImageUriPrinter(string imagesFolderAlias)
    {
        ImagesFolderAlias = imagesFolderAlias;
        Resources = new List<string>();
    }

    void IImageSavingCallback.ImageSaving(ImageSavingArgs args)
    {
        Resources.Add(args.ImageFileName);

        // If we specified an image folder alias, we would also need
        // to redirect each stream to put its image in the alias folder.
        args.ImageStream = new FileStream($"{ImagesFolderAlias}/{args.ImageFileName}", FileMode.Create);
        args.KeepImageStreamOpen = false;
    }

    public string ImagesFolderAlias { get; }
    public List<string> Resources { get; }
}

See Also