Aspose::Words::Saving::SaveOptions Class Referenceabstract

Detailed Description

This is an abstract base class for classes that allow the user to specify additional options when saving a document into a particular format.

Examples

Shows how to use a specific encoding when saving a document to .epub.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Use a SaveOptions object to specify the encoding for a document that we will save.
auto saveOptions = MakeObject<HtmlSaveOptions>();
saveOptions->set_SaveFormat(SaveFormat::Epub);
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
// By default, an output .epub document will have all its contents in one HTML part.
// A split criterion allows us to segment the document into several HTML parts.
// We will set the criteria to split the document into heading paragraphs.
// This is useful for readers who cannot read HTML files more significant than a specific size.
saveOptions->set_DocumentSplitCriteria(DocumentSplitCriteria::HeadingParagraph);
// Specify that we want to export document properties.
saveOptions->set_ExportDocumentProperties(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.Doc2EpubSaveOptions.epub", saveOptions);

#include <Aspose.Words.Cpp/Saving/SaveOptions.h>

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

Public Member Functions

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. 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_ExportGeneratorName () const
 When true, causes the name and version of Aspose.Words to be embedded into produced files. Default value is true. More...
 
bool get_FlatOpcXmlMappingOnly () const
 Gets or sets value determining which document formats are allowed to be mapped by XmlMapping. By default only FlatOpc document format is allowed to be mapped. More...
 
ImlRenderingMode get_ImlRenderingMode () const
 Gets or sets a value determining how ink (InkML) objects 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...
 
SharedPtr< IDocumentSavingCallbackget_ProgressCallback () const
 Called during saving a document and accepts data about saving progress. More...
 
virtual SaveFormat get_SaveFormat ()=0
 Specifies the format in which the document will be saved if this save options object is used. 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...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_AllowEmbeddingPostScriptFonts (bool value)
 Setter for get_AllowEmbeddingPostScriptFonts. More...
 
void set_CustomTimeZoneInfo (const SharedPtr< TimeZoneInfo > &value)
 
void set_DefaultTemplate (const 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_ExportGeneratorName (bool value)
 Setter for get_ExportGeneratorName. More...
 
void set_FlatOpcXmlMappingOnly (bool value)
 Setter for get_FlatOpcXmlMappingOnly. More...
 
void set_ImlRenderingMode (ImlRenderingMode value)
 Setter for get_ImlRenderingMode. More...
 
void set_MemoryOptimization (bool value)
 Setter for get_MemoryOptimization. More...
 
void set_PrettyFormat (bool value)
 Setter for get_PrettyFormat. More...
 
void set_ProgressCallback (const SharedPtr< IDocumentSavingCallback > &value)
 Setter for get_ProgressCallback. More...
 
virtual void set_SaveFormat (SaveFormat value)=0
 Setter for get_SaveFormat. More...
 
void set_TempFolder (const 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...
 

Static Public Member Functions

static SharedPtr< SaveOptionsCreateSaveOptions (SaveFormat saveFormat)
 Creates a save options object of a class suitable for the specified save format. More...
 
static SharedPtr< SaveOptionsCreateSaveOptions (const 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 ()
 

Member Function Documentation

◆ CreateSaveOptions() [1/2]

static System::SharedPtr< Aspose::Words::Saving::SaveOptions > Aspose::Words::Saving::SaveOptions::CreateSaveOptions ( Aspose::Words::SaveFormat  saveFormat)
static

Creates a save options object of a class suitable for the specified save format.

Parameters
saveFormatThe save format for which to create a save options object.
Returns
An object of a class that derives from SaveOptions.
Examples

Shows an option to optimize memory consumption when rendering large documents to PDF.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
SharedPtr<SaveOptions> saveOptions = SaveOptions::CreateSaveOptions(SaveFormat::Pdf);
// Set the "MemoryOptimization" property to "true" to lower the memory footprint of large documents' saving operations
// at the cost of increasing the duration of the operation.
// Set the "MemoryOptimization" property to "false" to save the document as a PDF normally.
saveOptions->set_MemoryOptimization(memoryOptimization);
doc->Save(ArtifactsDir + u"PdfSaveOptions.MemoryOptimization.pdf", saveOptions);

◆ CreateSaveOptions() [2/2]

static System::SharedPtr< Aspose::Words::Saving::SaveOptions > Aspose::Words::Saving::SaveOptions::CreateSaveOptions ( const System::String fileName)
static

Creates a save options object of a class suitable for the file extension specified in the given file name.

Parameters
fileNameThe extension of this file name determines the class of the save options object to create.
Returns
An object of a class that derives from SaveOptions.
Examples

Shows how to set a default template for documents that do not have attached templates.

auto doc = MakeObject<Document>();
// Enable automatic style updating, but do not attach a template document.
doc->set_AutomaticallyUpdateStyles(true);
ASSERT_EQ(String::Empty, doc->get_AttachedTemplate());
// Since there is no template document, the document had nowhere to track style changes.
// Use a SaveOptions object to automatically set a template
// if a document that we are saving does not have one.
SharedPtr<SaveOptions> options = SaveOptions::CreateSaveOptions(u"Document.DefaultTemplate.docx");
options->set_DefaultTemplate(MyDir + u"Business brochure.dotx");
doc->Save(ArtifactsDir + u"Document.DefaultTemplate.docx", options);

◆ get_AllowEmbeddingPostScriptFonts()

bool Aspose::Words::Saving::SaveOptions::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.

Note, Word does not embed PostScript fonts, but can open documents with embedded fonts of this type.

This option only works when EmbedTrueTypeFonts of the FontInfos property is set to true.

Examples

Shows how to save the document with PostScript font.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Name(u"PostScriptFont");
builder->Writeln(u"Some text with PostScript font.");
// Load the font with PostScript to use in the document.
auto otf = MakeObject<MemoryFontSource>(System::IO::File::ReadAllBytes(FontsDir + u"AllegroOpen.otf"));
doc->set_FontSettings(MakeObject<FontSettings>());
doc->get_FontSettings()->SetFontsSources(MakeArray<SharedPtr<FontSourceBase>>({otf}));
// Embed TrueType fonts.
doc->get_FontInfos()->set_EmbedTrueTypeFonts(true);
// Allow embedding PostScript fonts while embedding TrueType fonts.
// Microsoft Word does not embed PostScript fonts, but can open documents with embedded fonts of this type.
SharedPtr<SaveOptions> saveOptions = SaveOptions::CreateSaveOptions(SaveFormat::Docx);
saveOptions->set_AllowEmbeddingPostScriptFonts(true);
doc->Save(ArtifactsDir + u"Document.AllowEmbeddingPostScriptFonts.docx", saveOptions);

◆ get_CustomTimeZoneInfo()

System::SharedPtr< System::TimeZoneInfo > Aspose::Words::Saving::SaveOptions::get_CustomTimeZoneInfo ( ) const

◆ get_DefaultTemplate()

System::String Aspose::Words::Saving::SaveOptions::get_DefaultTemplate ( ) const

Gets or sets path to default template (including filename). Default value for this property is empty string.

Examples

Shows how to set a default template for documents that do not have attached templates.

auto doc = MakeObject<Document>();
// Enable automatic style updating, but do not attach a template document.
doc->set_AutomaticallyUpdateStyles(true);
ASSERT_EQ(String::Empty, doc->get_AttachedTemplate());
// Since there is no template document, the document had nowhere to track style changes.
// Use a SaveOptions object to automatically set a template
// if a document that we are saving does not have one.
SharedPtr<SaveOptions> options = SaveOptions::CreateSaveOptions(u"Document.DefaultTemplate.docx");
options->set_DefaultTemplate(MyDir + u"Business brochure.dotx");
doc->Save(ArtifactsDir + u"Document.DefaultTemplate.docx", options);

◆ get_Dml3DEffectsRenderingMode()

Aspose::Words::Saving::Dml3DEffectsRenderingMode Aspose::Words::Saving::SaveOptions::get_Dml3DEffectsRenderingMode ( ) const

Gets a value determining how 3D effects are rendered.

◆ get_DmlEffectsRenderingMode()

virtual Aspose::Words::Saving::DmlEffectsRenderingMode Aspose::Words::Saving::SaveOptions::get_DmlEffectsRenderingMode ( )
virtual

Gets or sets a value determining how DrawingML effects are rendered.

The default value is Simplified.

This property is used when the document is exported to fixed page formats.

Examples

Shows how to configure the rendering quality of DrawingML effects in a document as we save it to PDF.

auto doc = MakeObject<Document>(MyDir + u"DrawingML shape effects.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.None" to discard all DrawingML effects.
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Simplified"
// to render a simplified version of DrawingML effects.
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Fine" to
// render DrawingML effects with more accuracy and also with more processing cost.
options->set_DmlEffectsRenderingMode(effectsRenderingMode);
ASSERT_EQ(DmlRenderingMode::DrawingML, options->get_DmlRenderingMode());
doc->Save(ArtifactsDir + u"PdfSaveOptions.DrawingMLEffects.pdf", options);

Reimplemented in Aspose::Words::Saving::PdfSaveOptions.

◆ get_DmlRenderingMode()

Aspose::Words::Saving::DmlRenderingMode Aspose::Words::Saving::SaveOptions::get_DmlRenderingMode ( ) const

Gets or sets a value determining how DrawingML shapes are rendered.

The default value is Fallback.

This property is used when the document is exported to fixed page formats.

Examples

Shows how to configure the rendering quality of DrawingML effects in a document as we save it to PDF.

auto doc = MakeObject<Document>(MyDir + u"DrawingML shape effects.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.None" to discard all DrawingML effects.
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Simplified"
// to render a simplified version of DrawingML effects.
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Fine" to
// render DrawingML effects with more accuracy and also with more processing cost.
options->set_DmlEffectsRenderingMode(effectsRenderingMode);
ASSERT_EQ(DmlRenderingMode::DrawingML, options->get_DmlRenderingMode());
doc->Save(ArtifactsDir + u"PdfSaveOptions.DrawingMLEffects.pdf", options);

Shows how to render fallback shapes when saving to PDF.

auto doc = MakeObject<Document>(MyDir + u"DrawingML shape fallbacks.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "DmlRenderingMode" property to "DmlRenderingMode.Fallback"
// to substitute DML shapes with their fallback shapes.
// Set the "DmlRenderingMode" property to "DmlRenderingMode.DrawingML"
// to render the DML shapes themselves.
options->set_DmlRenderingMode(dmlRenderingMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.DrawingMLFallback.pdf", options);

◆ get_ExportGeneratorName()

bool Aspose::Words::Saving::SaveOptions::get_ExportGeneratorName ( ) const

When true, causes the name and version of Aspose.Words to be embedded into produced files. Default value is true.

Examples

Shows how to disable adding name and version of Aspose.Words into produced files.

auto doc = MakeObject<Document>();
// Use https://docs.aspose.com/words/net/generator-or-producer-name-included-in-output-documents/ to know how to check the result.
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_ExportGeneratorName(false);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.ExportGeneratorName.docx", saveOptions);

◆ get_FlatOpcXmlMappingOnly()

bool Aspose::Words::Saving::SaveOptions::get_FlatOpcXmlMappingOnly ( ) const

Gets or sets value determining which document formats are allowed to be mapped by XmlMapping. By default only FlatOpc document format is allowed to be mapped.

Examples

Shows how to binding structured document tags to any format.

// If true - SDT will contain raw HTML text.
// If false - mapped HTML will parsed and resulting document will be inserted into SDT content.
auto loadOptions = MakeObject<LoadOptions>();
loadOptions->set_FlatOpcXmlMappingOnly(isFlatOpcXmlMappingOnly);
auto doc = MakeObject<Document>(MyDir + u"Structured document tag with HTML content.docx", loadOptions);
SharedPtr<SaveOptions> saveOptions = SaveOptions::CreateSaveOptions(SaveFormat::Pdf);
saveOptions->set_FlatOpcXmlMappingOnly(isFlatOpcXmlMappingOnly);
doc->Save(ArtifactsDir + u"LoadOptions.FlatOpcXmlMappingOnly.pdf", saveOptions);

◆ get_ImlRenderingMode()

Aspose::Words::Saving::ImlRenderingMode Aspose::Words::Saving::SaveOptions::get_ImlRenderingMode ( ) const

Gets or sets a value determining how ink (InkML) objects are rendered.

The default value is InkML.

This property is used when the document is exported to fixed page formats.

Examples

Shows how to render Ink object.

auto doc = MakeObject<Document>(MyDir + u"Ink object.docx");
// Set 'ImlRenderingMode.InkML' ignores fall-back shape of ink (InkML) object and renders InkML itself.
// If the rendering result is unsatisfactory,
// please use 'ImlRenderingMode.Fallback' to get a result similar to previous versions.
auto saveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Jpeg);
saveOptions->set_ImlRenderingMode(ImlRenderingMode::InkML);
doc->Save(ArtifactsDir + u"ImageSaveOptions.RenderInkObject.jpeg", saveOptions);

◆ get_MemoryOptimization()

bool Aspose::Words::Saving::SaveOptions::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.

Examples

Shows an option to optimize memory consumption when rendering large documents to PDF.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
SharedPtr<SaveOptions> saveOptions = SaveOptions::CreateSaveOptions(SaveFormat::Pdf);
// Set the "MemoryOptimization" property to "true" to lower the memory footprint of large documents' saving operations
// at the cost of increasing the duration of the operation.
// Set the "MemoryOptimization" property to "false" to save the document as a PDF normally.
saveOptions->set_MemoryOptimization(memoryOptimization);
doc->Save(ArtifactsDir + u"PdfSaveOptions.MemoryOptimization.pdf", saveOptions);

◆ get_PrettyFormat()

bool Aspose::Words::Saving::SaveOptions::get_PrettyFormat ( ) const

When true, pretty formats output where applicable. Default value is false.

Set to true to make HTML, MHTML, EPUB, WordML, RTF, DOCX and ODT output human readable. Useful for testing or debugging.

Examples

Shows how to enhance the readability of the raw code of a saved .html document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
auto htmlOptions = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
htmlOptions->set_PrettyFormat(usePrettyFormat);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.PrettyFormat.html", htmlOptions);
// Enabling pretty format makes the raw html code more readable by adding tab stop and new line characters.
String html = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.PrettyFormat.html");
if (usePrettyFormat)
{
ASSERT_EQ(String(u"<html>\r\n") + u"\t<head>\r\n" + u"\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n" +
u"\t\t<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\r\n" +
String::Format(u"\t\t<meta name=\"generator\" content=\"{0} {1}\" />\r\n", BuildVersionInfo::get_Product(),
u"\t\t<title></title>\r\n" + u"\t</head>\r\n" + u"\t<body style=\"font-family:'Times New Roman'; font-size:12pt\">\r\n" +
u"\t\t<div>\r\n" + u"\t\t\t<p style=\"margin-top:0pt; margin-bottom:0pt\">\r\n" + u"\t\t\t\t<span>Hello world!</span>\r\n" +
u"\t\t\t</p>\r\n" + u"\t\t\t<p style=\"margin-top:0pt; margin-bottom:0pt\">\r\n" +
u"\t\t\t\t<span style=\"-aw-import:ignore\">&#xa0;</span>\r\n" + u"\t\t\t</p>\r\n" + u"\t\t</div>\r\n" + u"\t</body>\r\n</html>\r\n",
html);
}
else
{
ASSERT_EQ(String(u"<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />") +
u"<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />" +
String::Format(u"<meta name=\"generator\" content=\"{0} {1}\" /><title></title></head>", BuildVersionInfo::get_Product(),
u"<body style=\"font-family:'Times New Roman'; font-size:12pt\">" +
u"<div><p style=\"margin-top:0pt; margin-bottom:0pt\"><span>Hello world!</span></p>" +
u"<p style=\"margin-top:0pt; margin-bottom:0pt\"><span style=\"-aw-import:ignore\">&#xa0;</span></p></div></body></html>",
html);
}

◆ get_ProgressCallback()

System::SharedPtr< Aspose::Words::Saving::IDocumentSavingCallback > Aspose::Words::Saving::SaveOptions::get_ProgressCallback ( ) const

Called during saving a document and accepts data about saving progress.

Progress is reported when saving to Docx, FlatOpc, Docm, Dotm, Dotx, Html, Mhtml, Epub, XamlFlow, or XamlFlowPack.

◆ get_SaveFormat()

virtual Aspose::Words::SaveFormat Aspose::Words::Saving::SaveOptions::get_SaveFormat ( )
pure virtual

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

Examples

Shows how to use a specific encoding when saving a document to .epub.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Use a SaveOptions object to specify the encoding for a document that we will save.
auto saveOptions = MakeObject<HtmlSaveOptions>();
saveOptions->set_SaveFormat(SaveFormat::Epub);
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
// By default, an output .epub document will have all its contents in one HTML part.
// A split criterion allows us to segment the document into several HTML parts.
// We will set the criteria to split the document into heading paragraphs.
// This is useful for readers who cannot read HTML files more significant than a specific size.
saveOptions->set_DocumentSplitCriteria(DocumentSplitCriteria::HeadingParagraph);
// Specify that we want to export document properties.
saveOptions->set_ExportDocumentProperties(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.Doc2EpubSaveOptions.epub", saveOptions);

Implemented in Aspose::Words::Saving::DocSaveOptions, Aspose::Words::Saving::HtmlFixedSaveOptions, Aspose::Words::Saving::HtmlSaveOptions, Aspose::Words::Saving::ImageSaveOptions, Aspose::Words::Saving::MarkdownSaveOptions, Aspose::Words::Saving::OdtSaveOptions, Aspose::Words::Saving::OoxmlSaveOptions, Aspose::Words::Saving::PclSaveOptions, Aspose::Words::Saving::PdfSaveOptions, Aspose::Words::Saving::PsSaveOptions, Aspose::Words::Saving::RtfSaveOptions, Aspose::Words::Saving::SvgSaveOptions, Aspose::Words::Saving::TxtSaveOptions, Aspose::Words::Saving::WordML2003SaveOptions, Aspose::Words::Saving::XamlFixedSaveOptions, Aspose::Words::Saving::XamlFlowSaveOptions, and Aspose::Words::Saving::XpsSaveOptions.

◆ get_TempFolder()

System::String Aspose::Words::Saving::SaveOptions::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.

When Aspose.Words saves a document, it needs to create temporary internal structures. By default, these internal structures are created in memory and the memory usage spikes for a short period while the document is being saved. When saving is complete, the memory is freed and reclaimed by the garbage collector.

If you are saving a very large document (thousands of pages) and/or processing many documents at the same time, then the memory spike during saving can be significant enough to cause the system to throw OutOfMemoryException. Specifying a temporary folder using TempFolder will cause Aspose.Words to keep the internal structures in temporary files instead of memory. It reduces the memory usage during saving, but will decrease the save performance.

The folder must exist and be writable, otherwise an exception will be thrown.

Aspose.Words automatically deletes all temporary files when saving is complete.

Examples

Shows how to use the hard drive instead of memory when saving a document.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When we save a document, various elements are temporarily stored in memory as the save operation is taking place.
// We can use this option to use a temporary folder in the local file system instead,
// which will reduce our application's memory overhead.
auto options = MakeObject<DocSaveOptions>();
options->set_TempFolder(ArtifactsDir + u"TempFiles");
// The specified temporary folder must exist in the local file system before the save operation.
System::IO::Directory::CreateDirectory_(options->get_TempFolder());
doc->Save(ArtifactsDir + u"DocSaveOptions.TempFolder.doc", options);
// The folder will persist with no residual contents from the load operation.
ASSERT_EQ(0, System::IO::Directory::GetFiles(options->get_TempFolder())->get_Length());

◆ get_UpdateCreatedTimeProperty()

bool Aspose::Words::Saving::SaveOptions::get_UpdateCreatedTimeProperty ( ) const

Gets a value determining whether the CreatedTime property is updated before saving. Default value is false;.

◆ get_UpdateFields()

bool Aspose::Words::Saving::SaveOptions::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.

Examples

Shows how to update all the fields in a document immediately before saving it to PDF.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert text with PAGE and NUMPAGES fields. These fields do not display the correct value in real time.
// We will need to manually update them using updating methods such as "Field.Update()", and "Document.UpdateFields()"
// each time we need them to display accurate values.
builder->Write(u"Page ");
builder->InsertField(u"PAGE", u"");
builder->Write(u" of ");
builder->InsertField(u"NUMPAGES", u"");
builder->InsertBreak(BreakType::PageBreak);
builder->Writeln(u"Hello World!");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "UpdateFields" property to "false" to not update all the fields in a document right before a save operation.
// This is the preferable option if we know that all our fields will be up to date before saving.
// Set the "UpdateFields" property to "true" to iterate through all the document
// fields and update them before we save it as a PDF. This will make sure that all the fields will display
// the most accurate values in the PDF.
options->set_UpdateFields(updateFields);
// We can clone PdfSaveOptions objects.
ASPOSE_ASSERT_NS(options, options->Clone());
doc->Save(ArtifactsDir + u"PdfSaveOptions.UpdateFields.pdf", options);

◆ get_UpdateLastPrintedProperty()

bool Aspose::Words::Saving::SaveOptions::get_UpdateLastPrintedProperty ( ) const

Gets or sets a value determining whether the LastPrinted property is updated before saving.

Examples

Shows how to update a document's "Last printed" property when saving.

auto doc = MakeObject<Document>();
doc->get_BuiltInDocumentProperties()->set_LastPrinted(System::DateTime(2019, 12, 20));
// This flag determines whether the last printed date, which is a built-in property, is updated.
// If so, then the date of the document's most recent save operation
// with this SaveOptions object passed as a parameter is used as the print date.
auto saveOptions = MakeObject<DocSaveOptions>();
saveOptions->set_UpdateLastPrintedProperty(isUpdateLastPrintedProperty);
// In Microsoft Word 2003, this property can be found via File -> Properties -> Statistics -> Printed.
// It can also be displayed in the document's body by using a PRINTDATE field.
doc->Save(ArtifactsDir + u"DocSaveOptions.UpdateLastPrintedProperty.doc", saveOptions);
// Open the saved document, then verify the value of the property.
doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.UpdateLastPrintedProperty.doc");
ASPOSE_ASSERT_NE(isUpdateLastPrintedProperty, System::DateTime(2019, 12, 20) == doc->get_BuiltInDocumentProperties()->get_LastPrinted());

Shows how to update a document's "CreatedTime" property when saving.

auto doc = MakeObject<Document>();
doc->get_BuiltInDocumentProperties()->set_CreatedTime(System::DateTime(2019, 12, 20));
// This flag determines whether the created time, which is a built-in property, is updated.
// If so, then the date of the document's most recent save operation
// with this SaveOptions object passed as a parameter is used as the created time.
auto saveOptions = MakeObject<DocSaveOptions>();
saveOptions->set_UpdateCreatedTimeProperty(isUpdateCreatedTimeProperty);
doc->Save(ArtifactsDir + u"DocSaveOptions.UpdateCreatedTimeProperty.docx", saveOptions);
// Open the saved document, then verify the value of the property.
doc = MakeObject<Document>(ArtifactsDir + u"DocSaveOptions.UpdateCreatedTimeProperty.docx");
ASPOSE_ASSERT_NE(isUpdateCreatedTimeProperty, System::DateTime(2019, 12, 20) == doc->get_BuiltInDocumentProperties()->get_CreatedTime());

◆ get_UpdateLastSavedTimeProperty()

bool Aspose::Words::Saving::SaveOptions::get_UpdateLastSavedTimeProperty ( ) const

Gets or sets a value determining whether the LastSavedTime property is updated before saving.

Examples

Shows how to determine whether to preserve the document's "Last saved time" property when saving.

auto doc = MakeObject<Document>(MyDir + u"Document.docx");
ASSERT_EQ(System::DateTime(2021, 5, 11, 6, 32, 0), doc->get_BuiltInDocumentProperties()->get_LastSavedTime());
// When we save the document to an OOXML format, we can create an OoxmlSaveOptions object
// and then pass it to the document's saving method to modify how we save the document.
// Set the "UpdateLastSavedTimeProperty" property to "true" to
// set the output document's "Last saved time" built-in property to the current date/time.
// Set the "UpdateLastSavedTimeProperty" property to "false" to
// preserve the original value of the input document's "Last saved time" built-in property.
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_UpdateLastSavedTimeProperty(updateLastSavedTimeProperty);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.LastSavedTime.docx", saveOptions);
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.LastSavedTime.docx");
System::DateTime lastSavedTimeNew = doc->get_BuiltInDocumentProperties()->get_LastSavedTime();
if (updateLastSavedTimeProperty)
{
ASSERT_GT(System::DateTime::get_Now(), lastSavedTimeNew.AddDays(-1));
ASSERT_LT(System::DateTime::get_Now(), lastSavedTimeNew.AddDays(1));
}
else
{
ASSERT_EQ(System::DateTime(2021, 5, 11, 6, 32, 0), lastSavedTimeNew);
}

◆ get_UpdateSdtContent()

bool Aspose::Words::Saving::SaveOptions::get_UpdateSdtContent ( ) const

Gets or sets value determining whether content of StructuredDocumentTag is updated before saving.

Examples

Shows how to update structured document tags while saving a document to PDF.

auto doc = MakeObject<Document>();
// Insert a drop-down list structured document tag.
auto tag = MakeObject<StructuredDocumentTag>(doc, SdtType::DropDownList, MarkupLevel::Block);
tag->get_ListItems()->Add(MakeObject<SdtListItem>(u"Value 1"));
tag->get_ListItems()->Add(MakeObject<SdtListItem>(u"Value 2"));
tag->get_ListItems()->Add(MakeObject<SdtListItem>(u"Value 3"));
// The drop-down list currently displays "Choose an item" as the default text.
// Set the "SelectedValue" property to one of the list items to get the tag to
// display that list item's value instead of the default text.
tag->get_ListItems()->set_SelectedValue(tag->get_ListItems()->idx_get(1));
doc->get_FirstSection()->get_Body()->AppendChild(tag);
// Create a "PdfSaveOptions" object to pass to the document's "Save" method
// to modify how that method saves the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "UpdateSdtContent" property to "false" not to update the structured document tags
// while saving the document to PDF. They will display their default values as they were at the time of construction.
// Set the "UpdateSdtContent" property to "true" to make sure the tags display updated values in the PDF.
options->set_UpdateSdtContent(updateSdtContent);
doc->Save(ArtifactsDir + u"StructuredDocumentTag.UpdateSdtContent.pdf", options);

◆ get_UseAntiAliasing()

bool Aspose::Words::Saving::SaveOptions::get_UseAntiAliasing ( ) const

Gets or sets a value determining whether or not to use anti-aliasing for rendering.

The default value is false. When this value is set to true anti-aliasing is used for rendering.

This property is used when the document is exported to the following formats: Tiff, Png, Bmp, Jpeg, Emf. When the document is exported to the Html, Mhtml, Epub and Azw3 formats this option is used for raster images.

Examples

Shows how to improve the quality of a rendered document with SaveOptions.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(60);
builder->Writeln(u"Some text.");
SharedPtr<SaveOptions> options = MakeObject<Aspose::Words::Saving::ImageSaveOptions>(SaveFormat::Jpeg);
doc->Save(ArtifactsDir + u"Document.ImageSaveOptions.Default.jpg", options);
options->set_UseAntiAliasing(true);
options->set_UseHighQualityRendering(true);
doc->Save(ArtifactsDir + u"Document.ImageSaveOptions.HighQuality.jpg", options);

◆ get_UseHighQualityRendering()

bool Aspose::Words::Saving::SaveOptions::get_UseHighQualityRendering ( ) const

Gets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms.

The default value is false.

This property is used when the document is exported to image formats: Tiff, Png, Bmp, Jpeg, Emf.

Examples

Shows how to improve the quality of a rendered document with SaveOptions.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_Size(60);
builder->Writeln(u"Some text.");
SharedPtr<SaveOptions> options = MakeObject<Aspose::Words::Saving::ImageSaveOptions>(SaveFormat::Jpeg);
doc->Save(ArtifactsDir + u"Document.ImageSaveOptions.Default.jpg", options);
options->set_UseAntiAliasing(true);
options->set_UseHighQualityRendering(true);
doc->Save(ArtifactsDir + u"Document.ImageSaveOptions.HighQuality.jpg", options);

◆ GetType()

◆ Is()

◆ set_AllowEmbeddingPostScriptFonts()

void Aspose::Words::Saving::SaveOptions::set_AllowEmbeddingPostScriptFonts ( bool  value)

◆ set_CustomTimeZoneInfo()

void Aspose::Words::Saving::SaveOptions::set_CustomTimeZoneInfo ( const System::SharedPtr< System::TimeZoneInfo > &  value)

◆ set_DefaultTemplate()

void Aspose::Words::Saving::SaveOptions::set_DefaultTemplate ( const System::String value)

◆ set_Dml3DEffectsRenderingMode()

void Aspose::Words::Saving::SaveOptions::set_Dml3DEffectsRenderingMode ( Aspose::Words::Saving::Dml3DEffectsRenderingMode  value)

Sets a value determining how 3D effects are rendered.

◆ set_DmlEffectsRenderingMode()

virtual void Aspose::Words::Saving::SaveOptions::set_DmlEffectsRenderingMode ( Aspose::Words::Saving::DmlEffectsRenderingMode  value)
virtual

◆ set_DmlRenderingMode()

void Aspose::Words::Saving::SaveOptions::set_DmlRenderingMode ( Aspose::Words::Saving::DmlRenderingMode  value)

◆ set_ExportGeneratorName()

void Aspose::Words::Saving::SaveOptions::set_ExportGeneratorName ( bool  value)

◆ set_FlatOpcXmlMappingOnly()

void Aspose::Words::Saving::SaveOptions::set_FlatOpcXmlMappingOnly ( bool  value)

◆ set_ImlRenderingMode()

void Aspose::Words::Saving::SaveOptions::set_ImlRenderingMode ( Aspose::Words::Saving::ImlRenderingMode  value)

◆ set_MemoryOptimization()

void Aspose::Words::Saving::SaveOptions::set_MemoryOptimization ( bool  value)

◆ set_PrettyFormat()

void Aspose::Words::Saving::SaveOptions::set_PrettyFormat ( bool  value)

◆ set_ProgressCallback()

void Aspose::Words::Saving::SaveOptions::set_ProgressCallback ( const System::SharedPtr< Aspose::Words::Saving::IDocumentSavingCallback > &  value)

◆ set_SaveFormat()

◆ set_TempFolder()

void Aspose::Words::Saving::SaveOptions::set_TempFolder ( const System::String value)

◆ set_UpdateCreatedTimeProperty()

void Aspose::Words::Saving::SaveOptions::set_UpdateCreatedTimeProperty ( bool  value)

Sets a value determining whether the CreatedTime property is updated before saving. Default value is false;.

◆ set_UpdateFields()

void Aspose::Words::Saving::SaveOptions::set_UpdateFields ( bool  value)

◆ set_UpdateLastPrintedProperty()

void Aspose::Words::Saving::SaveOptions::set_UpdateLastPrintedProperty ( bool  value)

◆ set_UpdateLastSavedTimeProperty()

void Aspose::Words::Saving::SaveOptions::set_UpdateLastSavedTimeProperty ( bool  value)

◆ set_UpdateSdtContent()

void Aspose::Words::Saving::SaveOptions::set_UpdateSdtContent ( bool  value)

◆ set_UseAntiAliasing()

void Aspose::Words::Saving::SaveOptions::set_UseAntiAliasing ( bool  value)

◆ set_UseHighQualityRendering()

void Aspose::Words::Saving::SaveOptions::set_UseHighQualityRendering ( bool  value)

◆ Type()

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