Aspose::Words::Saving::OoxmlSaveOptions Class Reference

Detailed Description

Can be used to specify additional options when saving a document into the Docx, Docm, Dotx, Dotm or FlatOpc format.

Examples

Shows conversion VML shapes to DML using ISO/IEC 29500:2008 Strict compliance level.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set Word2003 version for document, for inserting image as VML shape
doc->get_CompatibilityOptions()->OptimizeFor(Aspose::Words::Settings::MsWordVersion::Word2003);
builder->InsertImage(ImageDir + u"Transparent background logo.png");
ASSERT_EQ(Aspose::Words::Drawing::ShapeMarkupLanguage::Vml, (System::DynamicCast<Aspose::Words::Drawing::Shape>(doc->GetChild(Aspose::Words::NodeType::Shape, 0, true)))->get_MarkupLanguage());
// Iso29500_2008 does not allow VML shapes
// You need to use OoxmlCompliance.Iso29500_2008_Strict for converting VML to DML shapes
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Docx);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// The markup language of our shape has changed according to the compliance type
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx");
ASSERT_EQ(Aspose::Words::Drawing::ShapeMarkupLanguage::Dml, (System::DynamicCast<Aspose::Words::Drawing::Shape>(doc->GetChild(Aspose::Words::NodeType::Shape, 0, true)))->get_MarkupLanguage());

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

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

Public Member Functions

 OoxmlSaveOptions ()
 Initializes a new instance of this class that can be used to save a document in the Docx format. More...
 
 OoxmlSaveOptions (SaveFormat saveFormat)
 Initializes a new instance of this class that can be used to save a document in the Docx, Docm, Dotx, Dotm or FlatOpc format. More...
 
OoxmlCompliance get_Compliance ()
 Specifies the OOXML version for the output document. The default value is Ecma376_2006. More...
 
CompressionLevel get_CompressionLevel () const
 Specifies the compression level used to save document. The default value is Normal. More...
 
bool get_KeepLegacyControlChars () const
 Keeps original representation of legacy control characters. More...
 
String get_Password () const
 Gets/sets a password to encrypt document using ECMA376 Standard encryption algorithm. More...
 
SaveFormat get_SaveFormat () override
 Specifies the format in which the document will be saved if this save options object is used. Can be Docx, Docm, Dotx, Dotm or FlatOpc. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_Compliance (OoxmlCompliance value)
 Setter for get_Compliance. More...
 
void set_CompressionLevel (CompressionLevel value)
 Specifies the compression level used to save document. The default value is Normal. More...
 
void set_KeepLegacyControlChars (bool value)
 Setter for get_KeepLegacyControlChars. More...
 
void set_Password (String value)
 Setter for get_Password. More...
 
void set_SaveFormat (SaveFormat value) override
 Setter for get_SaveFormat. More...
 
- Public Member Functions inherited from SaveOptions
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_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_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_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)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int 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 (unsigned int 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
 
typedef System::Details::SharedMembersType shared_members_type
 

Constructor & Destructor Documentation

◆ OoxmlSaveOptions() [1/2]

Aspose::Words::Saving::OoxmlSaveOptions::OoxmlSaveOptions ( )

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

Examples

Shows conversion VML shapes to DML using ISO/IEC 29500:2008 Strict compliance level.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set Word2003 version for document, for inserting image as VML shape
doc->get_CompatibilityOptions()->OptimizeFor(Aspose::Words::Settings::MsWordVersion::Word2003);
builder->InsertImage(ImageDir + u"Transparent background logo.png");
ASSERT_EQ(Aspose::Words::Drawing::ShapeMarkupLanguage::Vml, (System::DynamicCast<Aspose::Words::Drawing::Shape>(doc->GetChild(Aspose::Words::NodeType::Shape, 0, true)))->get_MarkupLanguage());
// Iso29500_2008 does not allow VML shapes
// You need to use OoxmlCompliance.Iso29500_2008_Strict for converting VML to DML shapes
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Docx);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// The markup language of our shape has changed according to the compliance type
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx");
ASSERT_EQ(Aspose::Words::Drawing::ShapeMarkupLanguage::Dml, (System::DynamicCast<Aspose::Words::Drawing::Shape>(doc->GetChild(Aspose::Words::NodeType::Shape, 0, true)))->get_MarkupLanguage());

◆ OoxmlSaveOptions() [2/2]

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

Initializes a new instance of this class that can be used to save a document in the Docx, Docm, Dotx, Dotm or FlatOpc format.

Parameters
saveFormatCan be Docx, Docm, Dotx, Dotm or FlatOpc.
Examples

Shows how to support legacy control characters when converting to .docx.

auto doc = MakeObject<Document>(MyDir + u"Legacy control character.doc");
// Note that only one legacy character (ShortDateTime) is supported which declared in the "DOC" format
auto so = MakeObject<OoxmlSaveOptions>(Aspose::Words::SaveFormat::Docx);
so->set_KeepLegacyControlChars(doKeepLegacyControlChars);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.KeepLegacyControlChars.docx", so);
// Open the saved document and verify results
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.KeepLegacyControlChars.docx");
if (doKeepLegacyControlChars)
{
ASSERT_EQ(u"\u0013date \\@ \"MM/dd/yyyy\"\u0014\u0015\f", doc->get_FirstSection()->get_Body()->GetText());
}
else
{
ASSERT_EQ(u"\u001e\f", doc->get_FirstSection()->get_Body()->GetText());
}

Member Function Documentation

◆ get_Compliance()

Aspose::Words::Saving::OoxmlCompliance Aspose::Words::Saving::OoxmlSaveOptions::get_Compliance ( )

Specifies the OOXML version for the output document. The default value is Ecma376_2006.

Examples

Shows conversion VML shapes to DML using ISO/IEC 29500:2008 Strict compliance level.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set Word2003 version for document, for inserting image as VML shape
doc->get_CompatibilityOptions()->OptimizeFor(Aspose::Words::Settings::MsWordVersion::Word2003);
builder->InsertImage(ImageDir + u"Transparent background logo.png");
ASSERT_EQ(Aspose::Words::Drawing::ShapeMarkupLanguage::Vml, (System::DynamicCast<Aspose::Words::Drawing::Shape>(doc->GetChild(Aspose::Words::NodeType::Shape, 0, true)))->get_MarkupLanguage());
// Iso29500_2008 does not allow VML shapes
// You need to use OoxmlCompliance.Iso29500_2008_Strict for converting VML to DML shapes
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Docx);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// The markup language of our shape has changed according to the compliance type
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx");
ASSERT_EQ(Aspose::Words::Drawing::ShapeMarkupLanguage::Dml, (System::DynamicCast<Aspose::Words::Drawing::Shape>(doc->GetChild(Aspose::Words::NodeType::Shape, 0, true)))->get_MarkupLanguage());

◆ get_CompressionLevel()

Aspose::Words::Saving::CompressionLevel Aspose::Words::Saving::OoxmlSaveOptions::get_CompressionLevel ( ) const

Specifies the compression level used to save document. The default value is Normal.

◆ get_KeepLegacyControlChars()

bool Aspose::Words::Saving::OoxmlSaveOptions::get_KeepLegacyControlChars ( ) const

Keeps original representation of legacy control characters.

Examples

Shows how to support legacy control characters when converting to .docx.

auto doc = MakeObject<Document>(MyDir + u"Legacy control character.doc");
// Note that only one legacy character (ShortDateTime) is supported which declared in the "DOC" format
auto so = MakeObject<OoxmlSaveOptions>(Aspose::Words::SaveFormat::Docx);
so->set_KeepLegacyControlChars(doKeepLegacyControlChars);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.KeepLegacyControlChars.docx", so);
// Open the saved document and verify results
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.KeepLegacyControlChars.docx");
if (doKeepLegacyControlChars)
{
ASSERT_EQ(u"\u0013date \\@ \"MM/dd/yyyy\"\u0014\u0015\f", doc->get_FirstSection()->get_Body()->GetText());
}
else
{
ASSERT_EQ(u"\u001e\f", doc->get_FirstSection()->get_Body()->GetText());
}

◆ get_Password()

System::String Aspose::Words::Saving::OoxmlSaveOptions::get_Password ( ) const

Gets/sets a password to encrypt document using ECMA376 Standard encryption algorithm.

In order to save document without encryption this property should be null or empty string.

Examples

Shows how to create a password protected Office Open XML document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
// Create a SaveOptions object with a password and save our document with it
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_Password(u"MyPassword");
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.Password.docx", saveOptions);
// This document cannot be opened like a normal document
auto openDocument = [&doc]()
{
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.Password.docx");
};
ASSERT_THROW(openDocument(), IncorrectPasswordException);
// We can open the document and access its contents by passing the correct password to a LoadOptions object
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.Password.docx", MakeObject<LoadOptions>(u"MyPassword"));
ASSERT_EQ(u"Hello world!", doc->GetText().Trim());

◆ get_SaveFormat()

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

Specifies the format in which the document will be saved if this save options object is used. Can be Docx, Docm, Dotx, Dotm or FlatOpc.

Examples

Shows conversion VML shapes to DML using ISO/IEC 29500:2008 Strict compliance level.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set Word2003 version for document, for inserting image as VML shape
doc->get_CompatibilityOptions()->OptimizeFor(Aspose::Words::Settings::MsWordVersion::Word2003);
builder->InsertImage(ImageDir + u"Transparent background logo.png");
ASSERT_EQ(Aspose::Words::Drawing::ShapeMarkupLanguage::Vml, (System::DynamicCast<Aspose::Words::Drawing::Shape>(doc->GetChild(Aspose::Words::NodeType::Shape, 0, true)))->get_MarkupLanguage());
// Iso29500_2008 does not allow VML shapes
// You need to use OoxmlCompliance.Iso29500_2008_Strict for converting VML to DML shapes
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Docx);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// The markup language of our shape has changed according to the compliance type
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx");
ASSERT_EQ(Aspose::Words::Drawing::ShapeMarkupLanguage::Dml, (System::DynamicCast<Aspose::Words::Drawing::Shape>(doc->GetChild(Aspose::Words::NodeType::Shape, 0, true)))->get_MarkupLanguage());

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

◆ GetType()

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

◆ Is()

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

◆ set_Compliance()

void Aspose::Words::Saving::OoxmlSaveOptions::set_Compliance ( Aspose::Words::Saving::OoxmlCompliance  value)

◆ set_CompressionLevel()

void Aspose::Words::Saving::OoxmlSaveOptions::set_CompressionLevel ( Aspose::Words::Saving::CompressionLevel  value)

Specifies the compression level used to save document. The default value is Normal.

◆ set_KeepLegacyControlChars()

void Aspose::Words::Saving::OoxmlSaveOptions::set_KeepLegacyControlChars ( bool  value)

◆ set_Password()

void Aspose::Words::Saving::OoxmlSaveOptions::set_Password ( System::String  value)

◆ set_SaveFormat()

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

◆ Type()

static const System::TypeInfo& Aspose::Words::Saving::OoxmlSaveOptions::Type ( )
static
@ Word2003
Optimize Aspose.Words behavior to match MS Word 2003 version.
@ Shape
A drawing object, such as an OfficeArt shape, image or an OLE object. A Shape node can contain Paragr...
@ Vml
Vector Markup Language is used to define the shape.
@ Dml
Drawing Markup Language is used to define the shape.
System::ExceptionWrapper< Details_IncorrectPasswordException > IncorrectPasswordException
Thrown if a document is encrypted with a password and the password specified when opening the documen...
Definition: IncorrectPasswordException.h:34
@ Docx
Saves the document as an Office Open XML WordprocessingML Document (macro-free).
@ Iso29500_2008_Strict
ISO/IEC 29500:2008 Strict compliance level.