Aspose::Words::Saving::XamlFlowSaveOptions Class Reference

Detailed Description

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

Examples

Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.

void ImageFolder()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto callback = MakeObject<ExXamlFlowSaveOptions::ImageUriPrinter>(ArtifactsDir + u"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.
auto options = MakeObject<XamlFlowSaveOptions>();
ASSERT_EQ(SaveFormat::XamlFlow, options->get_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->set_ImagesFolder(ArtifactsDir + u"XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options->set_ImagesFolderAlias(ArtifactsDir + u"XamlFlowImageFolderAlias");
options->set_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.
System::IO::Directory::CreateDirectory_(options->get_ImagesFolderAlias());
doc->Save(ArtifactsDir + u"XamlFlowSaveOptions.ImageFolder.xaml", options);
for (auto resource : callback->get_Resources())
{
std::cout << callback->get_ImagesFolderAlias() << "/" << resource << std::endl;
}
}
class ImageUriPrinter : public IImageSavingCallback
{
public:
{
return pr_ImagesFolderAlias;
}
SharedPtr<System::Collections::Generic::List<String>> get_Resources()
{
return pr_Resources;
}
ImageUriPrinter(String imagesFolderAlias)
{
pr_ImagesFolderAlias = imagesFolderAlias;
pr_Resources = MakeObject<System::Collections::Generic::List<String>>();
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
get_Resources()->Add(args->get_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->set_ImageStream(MakeObject<System::IO::FileStream>(String::Format(u"{0}/{1}", get_ImagesFolderAlias(), args->get_ImageFileName()),
args->set_KeepImageStreamOpen(false);
}
private:
String pr_ImagesFolderAlias;
SharedPtr<System::Collections::Generic::List<String>> pr_Resources;
};
static ASPOSECPP_SHARED_API void CreateDirectory_(const String &path)
System::String get_ImagesFolderAlias() const
Specifies the name of the folder used to construct image URIs written into an XAML document....
@ XamlFlow
Beta. Saves the document in the Extensible Application Markup Language (XAML) format as a flow docume...

#include <Aspose.Words.Cpp/Model/Saving/XamlFlowSaveOptions.h>

+ Inheritance diagram for Aspose::Words::Saving::XamlFlowSaveOptions:

Public Member Functions

 XamlFlowSaveOptions ()
 Initializes a new instance of this class that can be used to save a document in the XamlFlow format. More...
 
 XamlFlowSaveOptions (SaveFormat saveFormat)
 Initializes a new instance of this class that can be used to save a document in the XamlFlow or XamlFlowPack format. More...
 
SharedPtr< IImageSavingCallbackget_ImageSavingCallback ()
 Allows to control how images are saved when a document is saved to XAML. More...
 
String get_ImagesFolder () const
 Specifies the physical folder where images are saved when exporting a document to XAML format. Default is an empty string. More...
 
String get_ImagesFolderAlias () const
 Specifies the name of the folder used to construct image URIs written into an XAML document. Default is an empty string. More...
 
SaveFormat get_SaveFormat () override
 Specifies the format in which the document will be saved if this save options object is used. Can only be XamlFlow. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_ImageSavingCallback (SharedPtr< IImageSavingCallback > value)
 Setter for get_ImageSavingCallback. More...
 
void set_ImagesFolder (String value)
 Setter for get_ImagesFolder. More...
 
void set_ImagesFolderAlias (String value)
 Setter for get_ImagesFolderAlias. More...
 
void set_SaveFormat (SaveFormat value) override
 Setter for get_SaveFormat. More...
 
- Public Member Functions inherited from SaveOptions
bool get_AllowEmbeddingPostScriptFonts () const
 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. More...
 
SharedPtr< TimeZoneInfoget_CustomTimeZoneInfo () const
 
String get_DefaultTemplate () const
 Gets or sets path to default template (including filename). Default value for this property is empty string (Empty). More...
 
Dml3DEffectsRenderingMode get_Dml3DEffectsRenderingMode () const
 Gets a value determining how 3D effects are rendered. More...
 
virtual DmlEffectsRenderingMode get_DmlEffectsRenderingMode ()
 Gets or sets a value determining how DrawingML effects are rendered. More...
 
DmlRenderingMode get_DmlRenderingMode () const
 Gets or sets a value determining how DrawingML shapes are rendered. More...
 
bool get_MemoryOptimization () const
 Gets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is false. More...
 
bool get_PrettyFormat () const
 When true, pretty formats output where applicable. Default value is false. More...
 
String get_TempFolder () const
 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. More...
 
bool get_UpdateCreatedTimeProperty () const
 Gets a value determining whether the CreatedTime property is updated before saving. Default value is false;. More...
 
bool get_UpdateFields () const
 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. More...
 
bool get_UpdateLastPrintedProperty () const
 Gets or sets a value determining whether the LastPrinted property is updated before saving. More...
 
bool get_UpdateLastSavedTimeProperty () const
 Gets or sets a value determining whether the LastSavedTime property is updated before saving. More...
 
bool get_UpdateSdtContent () const
 Gets or sets value determining whether content of StructuredDocumentTag is updated before saving. More...
 
bool get_UseAntiAliasing () const
 Gets or sets a value determining whether or not to use anti-aliasing for rendering. More...
 
bool get_UseHighQualityRendering () const
 Gets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms. More...
 
void set_AllowEmbeddingPostScriptFonts (bool value)
 Setter for get_AllowEmbeddingPostScriptFonts. More...
 
void set_CustomTimeZoneInfo (SharedPtr< TimeZoneInfo > value)
 
void set_DefaultTemplate (String value)
 Setter for get_DefaultTemplate. More...
 
void set_Dml3DEffectsRenderingMode (Dml3DEffectsRenderingMode value)
 Sets a value determining how 3D effects are rendered. More...
 
virtual void set_DmlEffectsRenderingMode (DmlEffectsRenderingMode value)
 Setter for get_DmlEffectsRenderingMode. More...
 
void set_DmlRenderingMode (DmlRenderingMode value)
 Setter for get_DmlRenderingMode. More...
 
void set_MemoryOptimization (bool value)
 Setter for get_MemoryOptimization. More...
 
void set_PrettyFormat (bool value)
 Setter for get_PrettyFormat. More...
 
void set_TempFolder (String value)
 Setter for get_TempFolder. More...
 
void set_UpdateCreatedTimeProperty (bool value)
 Sets a value determining whether the CreatedTime property is updated before saving. Default value is false;. More...
 
void set_UpdateFields (bool value)
 Setter for get_UpdateFields. More...
 
void set_UpdateLastPrintedProperty (bool value)
 Setter for get_UpdateLastPrintedProperty. More...
 
void set_UpdateLastSavedTimeProperty (bool value)
 Setter for get_UpdateLastSavedTimeProperty. More...
 
void set_UpdateSdtContent (bool value)
 Setter for get_UpdateSdtContent. More...
 
void set_UseAntiAliasing (bool value)
 Setter for get_UseAntiAliasing. More...
 
void set_UseHighQualityRendering (bool value)
 Setter for get_UseHighQualityRendering. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
virtual ASPOSECPP_SHARED_API bool FastCast (const Details::FastRttiBase &helper, void **out_ptr) const
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int32_t GetHashCode () const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (uint32_t argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from SaveOptions
static SharedPtr< SaveOptionsCreateSaveOptions (SaveFormat saveFormat)
 Creates a save options object of a class suitable for the specified save format. More...
 
static SharedPtr< SaveOptionsCreateSaveOptions (String fileName)
 Creates a save options object of a class suitable for the file extension specified in the given file name. More...
 
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 

Constructor & Destructor Documentation

◆ XamlFlowSaveOptions() [1/2]

Aspose::Words::Saving::XamlFlowSaveOptions::XamlFlowSaveOptions ( )

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

Examples

Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.

void ImageFolder()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto callback = MakeObject<ExXamlFlowSaveOptions::ImageUriPrinter>(ArtifactsDir + u"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.
auto options = MakeObject<XamlFlowSaveOptions>();
ASSERT_EQ(SaveFormat::XamlFlow, options->get_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->set_ImagesFolder(ArtifactsDir + u"XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options->set_ImagesFolderAlias(ArtifactsDir + u"XamlFlowImageFolderAlias");
options->set_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.
System::IO::Directory::CreateDirectory_(options->get_ImagesFolderAlias());
doc->Save(ArtifactsDir + u"XamlFlowSaveOptions.ImageFolder.xaml", options);
for (auto resource : callback->get_Resources())
{
std::cout << callback->get_ImagesFolderAlias() << "/" << resource << std::endl;
}
}
class ImageUriPrinter : public IImageSavingCallback
{
public:
{
return pr_ImagesFolderAlias;
}
SharedPtr<System::Collections::Generic::List<String>> get_Resources()
{
return pr_Resources;
}
ImageUriPrinter(String imagesFolderAlias)
{
pr_ImagesFolderAlias = imagesFolderAlias;
pr_Resources = MakeObject<System::Collections::Generic::List<String>>();
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
get_Resources()->Add(args->get_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->set_ImageStream(MakeObject<System::IO::FileStream>(String::Format(u"{0}/{1}", get_ImagesFolderAlias(), args->get_ImageFileName()),
args->set_KeepImageStreamOpen(false);
}
private:
String pr_ImagesFolderAlias;
SharedPtr<System::Collections::Generic::List<String>> pr_Resources;
};

◆ XamlFlowSaveOptions() [2/2]

Aspose::Words::Saving::XamlFlowSaveOptions::XamlFlowSaveOptions ( Aspose::Words::SaveFormat  saveFormat)

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

Parameters
saveFormatCan be XamlFlow or XamlFlowPack.
Examples

Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.

void ImageFolder()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto callback = MakeObject<ExXamlFlowSaveOptions::ImageUriPrinter>(ArtifactsDir + u"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.
auto options = MakeObject<XamlFlowSaveOptions>();
ASSERT_EQ(SaveFormat::XamlFlow, options->get_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->set_ImagesFolder(ArtifactsDir + u"XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options->set_ImagesFolderAlias(ArtifactsDir + u"XamlFlowImageFolderAlias");
options->set_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.
System::IO::Directory::CreateDirectory_(options->get_ImagesFolderAlias());
doc->Save(ArtifactsDir + u"XamlFlowSaveOptions.ImageFolder.xaml", options);
for (auto resource : callback->get_Resources())
{
std::cout << callback->get_ImagesFolderAlias() << "/" << resource << std::endl;
}
}
class ImageUriPrinter : public IImageSavingCallback
{
public:
{
return pr_ImagesFolderAlias;
}
SharedPtr<System::Collections::Generic::List<String>> get_Resources()
{
return pr_Resources;
}
ImageUriPrinter(String imagesFolderAlias)
{
pr_ImagesFolderAlias = imagesFolderAlias;
pr_Resources = MakeObject<System::Collections::Generic::List<String>>();
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
get_Resources()->Add(args->get_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->set_ImageStream(MakeObject<System::IO::FileStream>(String::Format(u"{0}/{1}", get_ImagesFolderAlias(), args->get_ImageFileName()),
args->set_KeepImageStreamOpen(false);
}
private:
String pr_ImagesFolderAlias;
SharedPtr<System::Collections::Generic::List<String>> pr_Resources;
};

Member Function Documentation

◆ get_ImageSavingCallback()

System::SharedPtr<Aspose::Words::Saving::IImageSavingCallback> Aspose::Words::Saving::XamlFlowSaveOptions::get_ImageSavingCallback ( )

Allows to control how images are saved when a document is saved to XAML.

Examples

Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.

void ImageFolder()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto callback = MakeObject<ExXamlFlowSaveOptions::ImageUriPrinter>(ArtifactsDir + u"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.
auto options = MakeObject<XamlFlowSaveOptions>();
ASSERT_EQ(SaveFormat::XamlFlow, options->get_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->set_ImagesFolder(ArtifactsDir + u"XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options->set_ImagesFolderAlias(ArtifactsDir + u"XamlFlowImageFolderAlias");
options->set_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.
System::IO::Directory::CreateDirectory_(options->get_ImagesFolderAlias());
doc->Save(ArtifactsDir + u"XamlFlowSaveOptions.ImageFolder.xaml", options);
for (auto resource : callback->get_Resources())
{
std::cout << callback->get_ImagesFolderAlias() << "/" << resource << std::endl;
}
}
class ImageUriPrinter : public IImageSavingCallback
{
public:
{
return pr_ImagesFolderAlias;
}
SharedPtr<System::Collections::Generic::List<String>> get_Resources()
{
return pr_Resources;
}
ImageUriPrinter(String imagesFolderAlias)
{
pr_ImagesFolderAlias = imagesFolderAlias;
pr_Resources = MakeObject<System::Collections::Generic::List<String>>();
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
get_Resources()->Add(args->get_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->set_ImageStream(MakeObject<System::IO::FileStream>(String::Format(u"{0}/{1}", get_ImagesFolderAlias(), args->get_ImageFileName()),
args->set_KeepImageStreamOpen(false);
}
private:
String pr_ImagesFolderAlias;
SharedPtr<System::Collections::Generic::List<String>> pr_Resources;
};

◆ get_ImagesFolder()

System::String Aspose::Words::Saving::XamlFlowSaveOptions::get_ImagesFolder ( ) const

Specifies the physical folder where images are saved when exporting a document to XAML format. Default is an empty string.

When you save a Document in XAML format, Aspose.Words needs to save all images embedded in the document as standalone files. ImagesFolder allows you to specify where the images will be saved and ImagesFolderAlias 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 ImagesFolder 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 in the ImagesFolder property or provide custom streams via the ImageSavingCallback event handler.

See also
Aspose::Words::Saving::XamlFlowSaveOptions::get_ImagesFolderAlias
Aspose::Words::Saving::XamlFlowSaveOptions::get_ImageSavingCallback
Examples

Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.

void ImageFolder()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto callback = MakeObject<ExXamlFlowSaveOptions::ImageUriPrinter>(ArtifactsDir + u"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.
auto options = MakeObject<XamlFlowSaveOptions>();
ASSERT_EQ(SaveFormat::XamlFlow, options->get_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->set_ImagesFolder(ArtifactsDir + u"XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options->set_ImagesFolderAlias(ArtifactsDir + u"XamlFlowImageFolderAlias");
options->set_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.
System::IO::Directory::CreateDirectory_(options->get_ImagesFolderAlias());
doc->Save(ArtifactsDir + u"XamlFlowSaveOptions.ImageFolder.xaml", options);
for (auto resource : callback->get_Resources())
{
std::cout << callback->get_ImagesFolderAlias() << "/" << resource << std::endl;
}
}
class ImageUriPrinter : public IImageSavingCallback
{
public:
{
return pr_ImagesFolderAlias;
}
SharedPtr<System::Collections::Generic::List<String>> get_Resources()
{
return pr_Resources;
}
ImageUriPrinter(String imagesFolderAlias)
{
pr_ImagesFolderAlias = imagesFolderAlias;
pr_Resources = MakeObject<System::Collections::Generic::List<String>>();
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
get_Resources()->Add(args->get_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->set_ImageStream(MakeObject<System::IO::FileStream>(String::Format(u"{0}/{1}", get_ImagesFolderAlias(), args->get_ImageFileName()),
args->set_KeepImageStreamOpen(false);
}
private:
String pr_ImagesFolderAlias;
SharedPtr<System::Collections::Generic::List<String>> pr_Resources;
};

◆ get_ImagesFolderAlias()

System::String Aspose::Words::Saving::XamlFlowSaveOptions::get_ImagesFolderAlias ( ) const

Specifies the name of the folder used to construct image URIs written into an XAML document. Default is an empty string.

When you save a Document in XAML format, Aspose.Words needs to save all images embedded in the document as standalone files. ImagesFolder allows you to specify where the images will be saved and ImagesFolderAlias allows to specify how the image URIs will be constructed.

If ImagesFolderAlias is not an empty string, then the image URI written to XAML will be ImagesFolderAlias + <image file name>.

If ImagesFolderAlias is an empty string, then the image URI written to XAML will be ImagesFolder + <image file name>.

If ImagesFolderAlias is set to '.' (dot), then the image file name will be written to XAML without path regardless of other options.

See also
Aspose::Words::Saving::XamlFlowSaveOptions::get_ImagesFolder
Aspose::Words::Saving::XamlFlowSaveOptions::get_ImageSavingCallback
Examples

Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.

void ImageFolder()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto callback = MakeObject<ExXamlFlowSaveOptions::ImageUriPrinter>(ArtifactsDir + u"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.
auto options = MakeObject<XamlFlowSaveOptions>();
ASSERT_EQ(SaveFormat::XamlFlow, options->get_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->set_ImagesFolder(ArtifactsDir + u"XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options->set_ImagesFolderAlias(ArtifactsDir + u"XamlFlowImageFolderAlias");
options->set_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.
System::IO::Directory::CreateDirectory_(options->get_ImagesFolderAlias());
doc->Save(ArtifactsDir + u"XamlFlowSaveOptions.ImageFolder.xaml", options);
for (auto resource : callback->get_Resources())
{
std::cout << callback->get_ImagesFolderAlias() << "/" << resource << std::endl;
}
}
class ImageUriPrinter : public IImageSavingCallback
{
public:
{
return pr_ImagesFolderAlias;
}
SharedPtr<System::Collections::Generic::List<String>> get_Resources()
{
return pr_Resources;
}
ImageUriPrinter(String imagesFolderAlias)
{
pr_ImagesFolderAlias = imagesFolderAlias;
pr_Resources = MakeObject<System::Collections::Generic::List<String>>();
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
get_Resources()->Add(args->get_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->set_ImageStream(MakeObject<System::IO::FileStream>(String::Format(u"{0}/{1}", get_ImagesFolderAlias(), args->get_ImageFileName()),
args->set_KeepImageStreamOpen(false);
}
private:
String pr_ImagesFolderAlias;
SharedPtr<System::Collections::Generic::List<String>> pr_Resources;
};

◆ get_SaveFormat()

Aspose::Words::SaveFormat Aspose::Words::Saving::XamlFlowSaveOptions::get_SaveFormat ( )
overridevirtual

Specifies the format in which the document will be saved if this save options object is used. Can only be XamlFlow.

Examples

Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.

void ImageFolder()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto callback = MakeObject<ExXamlFlowSaveOptions::ImageUriPrinter>(ArtifactsDir + u"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.
auto options = MakeObject<XamlFlowSaveOptions>();
ASSERT_EQ(SaveFormat::XamlFlow, options->get_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->set_ImagesFolder(ArtifactsDir + u"XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options->set_ImagesFolderAlias(ArtifactsDir + u"XamlFlowImageFolderAlias");
options->set_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.
System::IO::Directory::CreateDirectory_(options->get_ImagesFolderAlias());
doc->Save(ArtifactsDir + u"XamlFlowSaveOptions.ImageFolder.xaml", options);
for (auto resource : callback->get_Resources())
{
std::cout << callback->get_ImagesFolderAlias() << "/" << resource << std::endl;
}
}
class ImageUriPrinter : public IImageSavingCallback
{
public:
{
return pr_ImagesFolderAlias;
}
SharedPtr<System::Collections::Generic::List<String>> get_Resources()
{
return pr_Resources;
}
ImageUriPrinter(String imagesFolderAlias)
{
pr_ImagesFolderAlias = imagesFolderAlias;
pr_Resources = MakeObject<System::Collections::Generic::List<String>>();
}
void ImageSaving(SharedPtr<ImageSavingArgs> args) override
{
get_Resources()->Add(args->get_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->set_ImageStream(MakeObject<System::IO::FileStream>(String::Format(u"{0}/{1}", get_ImagesFolderAlias(), args->get_ImageFileName()),
args->set_KeepImageStreamOpen(false);
}
private:
String pr_ImagesFolderAlias;
SharedPtr<System::Collections::Generic::List<String>> pr_Resources;
};

Implements Aspose::Words::Saving::SaveOptions.

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Saving::XamlFlowSaveOptions::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::Saving::XamlFlowSaveOptions::Is ( const System::TypeInfo target) const
overridevirtual

◆ set_ImageSavingCallback()

void Aspose::Words::Saving::XamlFlowSaveOptions::set_ImageSavingCallback ( System::SharedPtr< Aspose::Words::Saving::IImageSavingCallback value)

◆ set_ImagesFolder()

void Aspose::Words::Saving::XamlFlowSaveOptions::set_ImagesFolder ( System::String  value)

◆ set_ImagesFolderAlias()

void Aspose::Words::Saving::XamlFlowSaveOptions::set_ImagesFolderAlias ( System::String  value)

◆ set_SaveFormat()

void Aspose::Words::Saving::XamlFlowSaveOptions::set_SaveFormat ( Aspose::Words::SaveFormat  value)
overridevirtual

◆ Type()

static const System::TypeInfo& Aspose::Words::Saving::XamlFlowSaveOptions::Type ( )
static