Class XamlFixedSaveOptions

Class XamlFixedSaveOptions

Namespace: Aspose.Words.Saving
Assembly: Aspose.Words.dll (25.12.0)

Can be used to specify additional options when saving a document into the Aspose.Words.SaveFormat.XamlFixed format.

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

public class XamlFixedSaveOptions : FixedPageSaveOptions

Inheritance

object SaveOptions FixedPageSaveOptions XamlFixedSaveOptions

Inherited Members

FixedPageSaveOptions.Equals(object) , FixedPageSaveOptions.AssertValidIdPrefix(string) , FixedPageSaveOptions.IsValidIdPrefix(string) , FixedPageSaveOptions.PageSet , FixedPageSaveOptions.PageSavingCallback , FixedPageSaveOptions.NumeralFormat , FixedPageSaveOptions.MetafileRenderingOptions , FixedPageSaveOptions.JpegQuality , FixedPageSaveOptions.ColorMode , FixedPageSaveOptions.OptimizeOutput , SaveOptions.CreateSaveOptions(SaveFormat) , SaveOptions.CreateSaveOptions(string) , SaveOptions.SaveFormat , SaveOptions.ExportGeneratorName , SaveOptions.TempFolder , SaveOptions.PrettyFormat , SaveOptions.UseAntiAliasing , SaveOptions.UseHighQualityRendering , SaveOptions.DmlRenderingMode , SaveOptions.DmlEffectsRenderingMode , SaveOptions.ImlRenderingMode , SaveOptions.DefaultTemplate , SaveOptions.UpdateFields , SaveOptions.UpdateLastSavedTimeProperty , SaveOptions.UpdateLastPrintedProperty , SaveOptions.UpdateCreatedTimeProperty , SaveOptions.MemoryOptimization , SaveOptions.UpdateAmbiguousTextFont , SaveOptions.Dml3DEffectsRenderingMode , SaveOptions.ProgressCallback , SaveOptions.AllowEmbeddingPostScriptFonts , SaveOptions.CustomTimeZoneInfo , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Shows how to print the URIs of linked resources created while converting a document to fixed-form .xaml.

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

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

                                                                                                                       Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.XamlFixed));

                                                                                                                       // Use the "ResourcesFolder" property to assign a folder in the local file system into which
                                                                                                                       // Aspose.Words will save all the document's linked resources, such as images and fonts.
                                                                                                                       options.ResourcesFolder = ArtifactsDir + "XamlFixedResourceFolder";

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

                                                                                                                       options.ResourceSavingCallback = callback;

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

                                                                                                                       doc.Save(ArtifactsDir + "XamlFixedSaveOptions.ResourceFolder.xaml", options);

                                                                                                                       foreach (string resource in callback.Resources)
                                                                                                                           Console.WriteLine(resource);
                                                                                                                   }

                                                                                                                   /// <summary>
                                                                                                                   /// Counts and prints URIs of resources created during conversion to fixed .xaml.
                                                                                                                   /// </summary>
                                                                                                                   private class ResourceUriPrinter : IResourceSavingCallback
                                                                                                                   {
                                                                                                                       public ResourceUriPrinter()
                                                                                                                       {
                                                                                                                           Resources = new List<string>();
                                                                                                                       }

                                                                                                                       void IResourceSavingCallback.ResourceSaving(ResourceSavingArgs args)
                                                                                                                       {
                                                                                                                           Resources.Add($"Resource \"{args.ResourceFileName}\"\n\t{args.ResourceFileUri}");

                                                                                                                           // If we specified a resource folder alias, we would also need
                                                                                                                           // to redirect each stream to put its resource in the alias folder.
                                                                                                                           args.ResourceStream = new FileStream(args.ResourceFileUri, FileMode.Create);
                                                                                                                           args.KeepResourceStreamOpen = false;
                                                                                                                       }

                                                                                                                       public List<string> Resources { get; }
                                                                                                                   }

Constructors

XamlFixedSaveOptions()

public XamlFixedSaveOptions()

Properties

ResourceSavingCallback

Allows to control how resources (images and fonts) are saved when a document is exported to fixed page Xaml format.

public IResourceSavingCallback ResourceSavingCallback { get; set; }

Property Value

IResourceSavingCallback

Examples

Shows how to print the URIs of linked resources created while converting a document to fixed-form .xaml.

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

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

                                                                                                                       Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.XamlFixed));

                                                                                                                       // Use the "ResourcesFolder" property to assign a folder in the local file system into which
                                                                                                                       // Aspose.Words will save all the document's linked resources, such as images and fonts.
                                                                                                                       options.ResourcesFolder = ArtifactsDir + "XamlFixedResourceFolder";

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

                                                                                                                       options.ResourceSavingCallback = callback;

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

                                                                                                                       doc.Save(ArtifactsDir + "XamlFixedSaveOptions.ResourceFolder.xaml", options);

                                                                                                                       foreach (string resource in callback.Resources)
                                                                                                                           Console.WriteLine(resource);
                                                                                                                   }

                                                                                                                   /// <summary>
                                                                                                                   /// Counts and prints URIs of resources created during conversion to fixed .xaml.
                                                                                                                   /// </summary>
                                                                                                                   private class ResourceUriPrinter : IResourceSavingCallback
                                                                                                                   {
                                                                                                                       public ResourceUriPrinter()
                                                                                                                       {
                                                                                                                           Resources = new List<string>();
                                                                                                                       }

                                                                                                                       void IResourceSavingCallback.ResourceSaving(ResourceSavingArgs args)
                                                                                                                       {
                                                                                                                           Resources.Add($"Resource \"{args.ResourceFileName}\"\n\t{args.ResourceFileUri}");

                                                                                                                           // If we specified a resource folder alias, we would also need
                                                                                                                           // to redirect each stream to put its resource in the alias folder.
                                                                                                                           args.ResourceStream = new FileStream(args.ResourceFileUri, FileMode.Create);
                                                                                                                           args.KeepResourceStreamOpen = false;
                                                                                                                       }

                                                                                                                       public List<string> Resources { get; }
                                                                                                                   }

ResourcesFolder

Specifies the physical folder where resources (images and fonts) are saved when exporting a document to fixed page Xaml format. Default is null.

public string ResourcesFolder { get; set; }

Property Value

string

Examples

Shows how to print the URIs of linked resources created while converting a document to fixed-form .xaml.

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

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

                                                                                                                       Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.XamlFixed));

                                                                                                                       // Use the "ResourcesFolder" property to assign a folder in the local file system into which
                                                                                                                       // Aspose.Words will save all the document's linked resources, such as images and fonts.
                                                                                                                       options.ResourcesFolder = ArtifactsDir + "XamlFixedResourceFolder";

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

                                                                                                                       options.ResourceSavingCallback = callback;

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

                                                                                                                       doc.Save(ArtifactsDir + "XamlFixedSaveOptions.ResourceFolder.xaml", options);

                                                                                                                       foreach (string resource in callback.Resources)
                                                                                                                           Console.WriteLine(resource);
                                                                                                                   }

                                                                                                                   /// <summary>
                                                                                                                   /// Counts and prints URIs of resources created during conversion to fixed .xaml.
                                                                                                                   /// </summary>
                                                                                                                   private class ResourceUriPrinter : IResourceSavingCallback
                                                                                                                   {
                                                                                                                       public ResourceUriPrinter()
                                                                                                                       {
                                                                                                                           Resources = new List<string>();
                                                                                                                       }

                                                                                                                       void IResourceSavingCallback.ResourceSaving(ResourceSavingArgs args)
                                                                                                                       {
                                                                                                                           Resources.Add($"Resource \"{args.ResourceFileName}\"\n\t{args.ResourceFileUri}");

                                                                                                                           // If we specified a resource folder alias, we would also need
                                                                                                                           // to redirect each stream to put its resource in the alias folder.
                                                                                                                           args.ResourceStream = new FileStream(args.ResourceFileUri, FileMode.Create);
                                                                                                                           args.KeepResourceStreamOpen = false;
                                                                                                                       }

                                                                                                                       public List<string> Resources { get; }
                                                                                                                   }

Remarks

When you save a Aspose.Words.Document in fixed page Xaml format, Aspose.Words needs to save all images embedded in the document as standalone files. Aspose.Words.Saving.XamlFixedSaveOptions.ResourcesFolder allows you to specify where the images will be saved and Aspose.Words.Saving.XamlFixedSaveOptions.ResourcesFolderAlias allows to specify how the image URIs will be constructed.

If you save a document into a file and provide a file name, Aspose.Words, by default, saves the images in the same folder where the document file is saved. Use Aspose.Words.Saving.XamlFixedSaveOptions.ResourcesFolder to override this behavior.

If you save a document into a stream, Aspose.Words does not have a folder where to save the images, but still needs to save the images somewhere. In this case, you need to specify an accessible folder by using the Aspose.Words.Saving.XamlFixedSaveOptions.ResourcesFolder property

Aspose.Words.Saving.XamlFixedSaveOptions.ResourcesFolderAlias

ResourcesFolderAlias

Specifies the name of the folder used to construct image URIs written into an fixed page Xaml document. Default is null.

public string ResourcesFolderAlias { get; set; }

Property Value

string

Examples

Shows how to print the URIs of linked resources created while converting a document to fixed-form .xaml.

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

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

                                                                                                                       Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.XamlFixed));

                                                                                                                       // Use the "ResourcesFolder" property to assign a folder in the local file system into which
                                                                                                                       // Aspose.Words will save all the document's linked resources, such as images and fonts.
                                                                                                                       options.ResourcesFolder = ArtifactsDir + "XamlFixedResourceFolder";

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

                                                                                                                       options.ResourceSavingCallback = callback;

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

                                                                                                                       doc.Save(ArtifactsDir + "XamlFixedSaveOptions.ResourceFolder.xaml", options);

                                                                                                                       foreach (string resource in callback.Resources)
                                                                                                                           Console.WriteLine(resource);
                                                                                                                   }

                                                                                                                   /// <summary>
                                                                                                                   /// Counts and prints URIs of resources created during conversion to fixed .xaml.
                                                                                                                   /// </summary>
                                                                                                                   private class ResourceUriPrinter : IResourceSavingCallback
                                                                                                                   {
                                                                                                                       public ResourceUriPrinter()
                                                                                                                       {
                                                                                                                           Resources = new List<string>();
                                                                                                                       }

                                                                                                                       void IResourceSavingCallback.ResourceSaving(ResourceSavingArgs args)
                                                                                                                       {
                                                                                                                           Resources.Add($"Resource \"{args.ResourceFileName}\"\n\t{args.ResourceFileUri}");

                                                                                                                           // If we specified a resource folder alias, we would also need
                                                                                                                           // to redirect each stream to put its resource in the alias folder.
                                                                                                                           args.ResourceStream = new FileStream(args.ResourceFileUri, FileMode.Create);
                                                                                                                           args.KeepResourceStreamOpen = false;
                                                                                                                       }

                                                                                                                       public List<string> Resources { get; }
                                                                                                                   }

Remarks

When you save a Aspose.Words.Document in fixed page Xaml format, Aspose.Words needs to save all images embedded in the document as standalone files. Aspose.Words.Saving.XamlFixedSaveOptions.ResourcesFolder allows you to specify where the images will be saved and Aspose.Words.Saving.XamlFixedSaveOptions.ResourcesFolderAlias allows to specify how the image URIs will be constructed.

Aspose.Words.Saving.XamlFixedSaveOptions.ResourcesFolder

SaveFormat

Specifies the format in which the document will be saved if this save options object is used. Can only be Aspose.Words.SaveFormat.XamlFixed.

public override SaveFormat SaveFormat { get; set; }

Property Value

SaveFormat

Examples

Shows how to print the URIs of linked resources created while converting a document to fixed-form .xaml.

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

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

                                                                                                                       Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.XamlFixed));

                                                                                                                       // Use the "ResourcesFolder" property to assign a folder in the local file system into which
                                                                                                                       // Aspose.Words will save all the document's linked resources, such as images and fonts.
                                                                                                                       options.ResourcesFolder = ArtifactsDir + "XamlFixedResourceFolder";

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

                                                                                                                       options.ResourceSavingCallback = callback;

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

                                                                                                                       doc.Save(ArtifactsDir + "XamlFixedSaveOptions.ResourceFolder.xaml", options);

                                                                                                                       foreach (string resource in callback.Resources)
                                                                                                                           Console.WriteLine(resource);
                                                                                                                   }

                                                                                                                   /// <summary>
                                                                                                                   /// Counts and prints URIs of resources created during conversion to fixed .xaml.
                                                                                                                   /// </summary>
                                                                                                                   private class ResourceUriPrinter : IResourceSavingCallback
                                                                                                                   {
                                                                                                                       public ResourceUriPrinter()
                                                                                                                       {
                                                                                                                           Resources = new List<string>();
                                                                                                                       }

                                                                                                                       void IResourceSavingCallback.ResourceSaving(ResourceSavingArgs args)
                                                                                                                       {
                                                                                                                           Resources.Add($"Resource \"{args.ResourceFileName}\"\n\t{args.ResourceFileUri}");

                                                                                                                           // If we specified a resource folder alias, we would also need
                                                                                                                           // to redirect each stream to put its resource in the alias folder.
                                                                                                                           args.ResourceStream = new FileStream(args.ResourceFileUri, FileMode.Create);
                                                                                                                           args.KeepResourceStreamOpen = false;
                                                                                                                       }

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