XamlFlowSaveOptions Constructor

Initializes a new instance of this class that can be used to save a document in the XamlFlow format.

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public XamlFlowSaveOptions()
Examples
Shows how to print the filenames of linked images created during conversion of a document to flow-form .xaml.
public void ImageFolder()
{
    // Open a document which contains images
    Document doc = new Document(MyDir + "Rendering.docx");

    XamlFlowSaveOptions options = new XamlFlowSaveOptions
    {
        SaveFormat = SaveFormat.XamlFlow,
        ImagesFolder = ArtifactsDir + "XamlFlowImageFolder",
        ImagesFolderAlias = ArtifactsDir + "XamlFlowImageFolderAlias",
        ImageSavingCallback = new ImageUriPrinter(ArtifactsDir + "XamlFlowImageFolderAlias")
    };

    // A folder specified by ImagesFolderAlias will contain the images instead of ImagesFolder
    // We must ensure the folder exists before the streams can put their images into it
    Directory.CreateDirectory(options.ImagesFolderAlias);

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

/// <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)
    {
        mImagesFolderAlias = imagesFolderAlias;
    }

    void IImageSavingCallback.ImageSaving(ImageSavingArgs args)
    {
        Console.WriteLine($"Image #{++mSavedImageCount} \"{args.ImageFileName}\"");

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

    private int mSavedImageCount;
    private readonly string mImagesFolderAlias;
}
See Also