Aspose::Words::Saving::DocSaveOptions Class Reference

Detailed Description

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

At the moment provides only the SaveFormat property, but in the future will have other options added, such as an encryption password or digital signature settings.

Examples

Shows how to set save options for older Microsoft Word formats.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto options = MakeObject<DocSaveOptions>(SaveFormat::Doc);
// Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
// Note that this does not encrypt the contents of the document in any way.
options->set_Password(u"MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options->set_SaveRoutingSlip(true);
doc->Save(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", options);
// To be able to load the document,
// we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
ASSERT_THROW(doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc"), IncorrectPasswordException);
auto loadOptions = MakeObject<LoadOptions>(u"MyPassword");
doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", loadOptions);
ASSERT_EQ(u"Hello world!", doc->GetText().Trim());
@ Doc
Saves the document in the Microsoft Word 97 - 2007 Document format.
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:33

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

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

Public Member Functions

 DocSaveOptions ()
 Initializes a new instance of this class that can be used to save a document in the Doc format. More...
 
 DocSaveOptions (SaveFormat saveFormat)
 Initializes a new instance of this class that can be used to save a document in the Doc or Dot format. More...
 
bool get_AlwaysCompressMetafiles () const
 When false, small metafiles are not compressed for performance reason. Default value is true, all metafiles are compressed regardless of its size. More...
 
String get_Password () const
 Gets/sets a password to encrypt document using RC4 encryption method. More...
 
SaveFormat get_SaveFormat () override
 Specifies the format in which the document will be saved if this save options object is used. Can be Doc or Dot. More...
 
bool get_SavePictureBullet () const
 When false, PictureBullet data is not saved to output document. Default value is true. More...
 
bool get_SaveRoutingSlip () const
 When false, RoutingSlip data is not saved to output document. Default value is true. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_AlwaysCompressMetafiles (bool value)
 Setter for get_AlwaysCompressMetafiles. More...
 
void set_Password (String value)
 Setter for get_Password. More...
 
void set_SaveFormat (SaveFormat value) override
 Setter for get_SaveFormat. More...
 
void set_SavePictureBullet (bool value)
 Setter for get_SavePictureBullet. More...
 
void set_SaveRoutingSlip (bool value)
 Setter for get_SaveRoutingSlip. 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

◆ DocSaveOptions() [1/2]

Aspose::Words::Saving::DocSaveOptions::DocSaveOptions ( )

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

Examples

Shows how to set save options for older Microsoft Word formats.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto options = MakeObject<DocSaveOptions>(SaveFormat::Doc);
// Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
// Note that this does not encrypt the contents of the document in any way.
options->set_Password(u"MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options->set_SaveRoutingSlip(true);
doc->Save(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", options);
// To be able to load the document,
// we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
ASSERT_THROW(doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc"), IncorrectPasswordException);
auto loadOptions = MakeObject<LoadOptions>(u"MyPassword");
doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", loadOptions);
ASSERT_EQ(u"Hello world!", doc->GetText().Trim());

◆ DocSaveOptions() [2/2]

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

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

Parameters
saveFormatCan be Doc or Dot.
Examples

Shows how to set save options for older Microsoft Word formats.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto options = MakeObject<DocSaveOptions>(SaveFormat::Doc);
// Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
// Note that this does not encrypt the contents of the document in any way.
options->set_Password(u"MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options->set_SaveRoutingSlip(true);
doc->Save(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", options);
// To be able to load the document,
// we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
ASSERT_THROW(doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc"), IncorrectPasswordException);
auto loadOptions = MakeObject<LoadOptions>(u"MyPassword");
doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", loadOptions);
ASSERT_EQ(u"Hello world!", doc->GetText().Trim());

Member Function Documentation

◆ get_AlwaysCompressMetafiles()

bool Aspose::Words::Saving::DocSaveOptions::get_AlwaysCompressMetafiles ( ) const

When false, small metafiles are not compressed for performance reason. Default value is true, all metafiles are compressed regardless of its size.

Examples

Shows how to change metafiles compression in a document while saving.

// Open a document that contains a Microsoft Equation 3.0 formula.
auto doc = MakeObject<Document>(MyDir + u"Microsoft equation object.docx");
// When we save a document, smaller metafiles are not compressed for performance reasons.
// We can set a flag in a SaveOptions object to compress every metafile when saving.
// Some editors such as LibreOffice cannot read uncompressed metafiles.
auto saveOptions = MakeObject<DocSaveOptions>();
saveOptions->set_AlwaysCompressMetafiles(compressAllMetafiles);
doc->Save(ArtifactsDir + u"DocSaveOptions.AlwaysCompressMetafiles.docx", saveOptions);
if (compressAllMetafiles)
{
ASSERT_LT(10000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"DocSaveOptions.AlwaysCompressMetafiles.docx")->get_Length());
}
else
{
ASSERT_GE(30000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"DocSaveOptions.AlwaysCompressMetafiles.docx")->get_Length());
}

◆ get_Password()

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

Gets/sets a password to encrypt document using RC4 encryption method.

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

Examples

Shows how to set save options for older Microsoft Word formats.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto options = MakeObject<DocSaveOptions>(SaveFormat::Doc);
// Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
// Note that this does not encrypt the contents of the document in any way.
options->set_Password(u"MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options->set_SaveRoutingSlip(true);
doc->Save(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", options);
// To be able to load the document,
// we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
ASSERT_THROW(doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc"), IncorrectPasswordException);
auto loadOptions = MakeObject<LoadOptions>(u"MyPassword");
doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", loadOptions);
ASSERT_EQ(u"Hello world!", doc->GetText().Trim());

◆ get_SaveFormat()

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

Specifies the format in which the document will be saved if this save options object is used. Can be Doc or Dot.

Examples

Shows how to set save options for older Microsoft Word formats.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto options = MakeObject<DocSaveOptions>(SaveFormat::Doc);
// Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
// Note that this does not encrypt the contents of the document in any way.
options->set_Password(u"MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options->set_SaveRoutingSlip(true);
doc->Save(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", options);
// To be able to load the document,
// we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
ASSERT_THROW(doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc"), IncorrectPasswordException);
auto loadOptions = MakeObject<LoadOptions>(u"MyPassword");
doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", loadOptions);
ASSERT_EQ(u"Hello world!", doc->GetText().Trim());

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

◆ get_SavePictureBullet()

bool Aspose::Words::Saving::DocSaveOptions::get_SavePictureBullet ( ) const

When false, PictureBullet data is not saved to output document. Default value is true.

This option is provided for Word 97, which cannot work correctly with PictureBullet data. To remove PictureBullet data, set the option to "false".

Examples

Shows how to omit PictureBullet data from the document when saving.

auto doc = MakeObject<Document>(MyDir + u"Image bullet points.docx");
// Some word processors, such as Microsoft Word 97, are incompatible with PictureBullet data.
// By setting a flag in the SaveOptions object,
// we can convert all image bullet points to ordinary bullet points while saving.
auto saveOptions = MakeObject<DocSaveOptions>(SaveFormat::Doc);
saveOptions->set_SavePictureBullet(false);
doc->Save(ArtifactsDir + u"DocSaveOptions.PictureBullets.doc", saveOptions);

◆ get_SaveRoutingSlip()

bool Aspose::Words::Saving::DocSaveOptions::get_SaveRoutingSlip ( ) const

When false, RoutingSlip data is not saved to output document. Default value is true.

Examples

Shows how to set save options for older Microsoft Word formats.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto options = MakeObject<DocSaveOptions>(SaveFormat::Doc);
// Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
// Note that this does not encrypt the contents of the document in any way.
options->set_Password(u"MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options->set_SaveRoutingSlip(true);
doc->Save(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", options);
// To be able to load the document,
// we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
ASSERT_THROW(doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc"), IncorrectPasswordException);
auto loadOptions = MakeObject<LoadOptions>(u"MyPassword");
doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.SaveAsDoc.doc", loadOptions);
ASSERT_EQ(u"Hello world!", doc->GetText().Trim());

◆ GetType()

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

◆ Is()

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

◆ set_AlwaysCompressMetafiles()

void Aspose::Words::Saving::DocSaveOptions::set_AlwaysCompressMetafiles ( bool  value)

◆ set_Password()

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

◆ set_SaveFormat()

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

◆ set_SavePictureBullet()

void Aspose::Words::Saving::DocSaveOptions::set_SavePictureBullet ( bool  value)

◆ set_SaveRoutingSlip()

void Aspose::Words::Saving::DocSaveOptions::set_SaveRoutingSlip ( bool  value)

◆ Type()

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