Aspose::Words::Saving::TxtSaveOptionsBase Class Reference

Detailed Description

The base class for specifying additional options when saving a document into a text based formats.

Examples

Shows how to save a .txt document with a custom paragraph break.

// Create a new document and add some paragraphs
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Paragraph 1.");
builder->Writeln(u"Paragraph 2.");
builder->Write(u"Paragraph 3.");
// When saved to plain text, the paragraphs we created can be separated by a custom string
auto txtSaveOptions = MakeObject<TxtSaveOptions>();
txtSaveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Text);
txtSaveOptions->set_ParagraphBreak(u" End of paragraph.\n\n\t");
doc->Save(ArtifactsDir + u"TxtSaveOptions.ParagraphBreak.txt", txtSaveOptions);
String docText = System::IO::File::ReadAllText(ArtifactsDir + u"TxtSaveOptions.ParagraphBreak.txt");
ASSERT_EQ(String(u"Paragraph 1. End of paragraph.\n\n\t") + u"Paragraph 2. End of paragraph.\n\n\t" + u"Paragraph 3. End of paragraph.\n\n\t", docText);

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

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

Public Member Functions

 TxtSaveOptionsBase ()
 
SharedPtr< Encodingget_Encoding () const
 Specifies the encoding to use when exporting in text formats. Default value is Encoding.UTF8. More...
 
TxtExportHeadersFootersMode get_ExportHeadersFootersMode () const
 Specifies the way headers and footers are exported to the text formats. Default value is PrimaryOnly. More...
 
bool get_ForcePageBreaks () const
 Allows to specify whether the page breaks should be preserved during export. The default value is false. More...
 
String get_ParagraphBreak () const
 Specifies the string to use as a paragraph break when exporting in text formats. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_Encoding (SharedPtr< Encoding > value)
 Setter for get_Encoding. More...
 
void set_ExportHeadersFootersMode (TxtExportHeadersFootersMode value)
 Setter for get_ExportHeadersFootersMode. More...
 
void set_ForcePageBreaks (bool value)
 Setter for get_ForcePageBreaks. More...
 
void set_ParagraphBreak (String value)
 Setter for get_ParagraphBreak. 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...
 
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_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...
 
virtual void set_SaveFormat (SaveFormat value)=0
 Setter for get_SaveFormat. 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

◆ TxtSaveOptionsBase()

Aspose::Words::Saving::TxtSaveOptionsBase::TxtSaveOptionsBase ( )

Member Function Documentation

◆ get_Encoding()

System::SharedPtr<System::Text::Encoding> Aspose::Words::Saving::TxtSaveOptionsBase::get_Encoding ( ) const

Specifies the encoding to use when exporting in text formats. Default value is Encoding.UTF8.

Examples

Shows how to set encoding for a .txt output document.

// Create a new document and add some text from outside the ASCII character set
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"À È Ì Ò Ù.");
// We can use a SaveOptions object to make sure the encoding we save the .txt document in supports our content
auto txtSaveOptions = MakeObject<TxtSaveOptions>();
txtSaveOptions->set_Encoding(System::Text::Encoding::get_UTF8());
doc->Save(ArtifactsDir + u"TxtSaveOptions.Encoding.txt", txtSaveOptions);
String docText = System::Text::Encoding::get_UTF8()->GetString(System::IO::File::ReadAllBytes(ArtifactsDir + u"TxtSaveOptions.Encoding.txt"));
ASSERT_EQ(u"\ufeffÀ È Ì Ò Ù.\r\n", docText);

◆ get_ExportHeadersFootersMode()

Aspose::Words::Saving::TxtExportHeadersFootersMode Aspose::Words::Saving::TxtSaveOptionsBase::get_ExportHeadersFootersMode ( ) const

Specifies the way headers and footers are exported to the text formats. Default value is PrimaryOnly.

Examples

Shows how to specifies the way headers and footers are exported to plain text format.

auto doc = MakeObject<Document>();
// Insert even and primary headers/footers into the document
// The primary header/footers should override the even ones
doc->get_FirstSection()->get_HeadersFooters()->Add(MakeObject<HeaderFooter>(doc, Aspose::Words::HeaderFooterType::HeaderEven));
doc->get_FirstSection()->get_HeadersFooters()->idx_get(Aspose::Words::HeaderFooterType::HeaderEven)->AppendParagraph(u"Even header");
doc->get_FirstSection()->get_HeadersFooters()->Add(MakeObject<HeaderFooter>(doc, Aspose::Words::HeaderFooterType::FooterEven));
doc->get_FirstSection()->get_HeadersFooters()->idx_get(Aspose::Words::HeaderFooterType::FooterEven)->AppendParagraph(u"Even footer");
doc->get_FirstSection()->get_HeadersFooters()->Add(MakeObject<HeaderFooter>(doc, Aspose::Words::HeaderFooterType::HeaderPrimary));
doc->get_FirstSection()->get_HeadersFooters()->idx_get(Aspose::Words::HeaderFooterType::HeaderPrimary)->AppendParagraph(u"Primary header");
doc->get_FirstSection()->get_HeadersFooters()->Add(MakeObject<HeaderFooter>(doc, Aspose::Words::HeaderFooterType::FooterPrimary));
doc->get_FirstSection()->get_HeadersFooters()->idx_get(Aspose::Words::HeaderFooterType::FooterPrimary)->AppendParagraph(u"Primary footer");
// Insert pages that would display these headers and footers
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Page 1");
builder->Writeln(u"Page 2");
builder->Write(u"Page 3");
// Three values are available in TxtExportHeadersFootersMode enum:
// "None" - No headers and footers are exported
// "AllAtEnd" - All headers and footers are placed after all section bodies at the very end of a document
// "PrimaryOnly" - Only primary headers and footers are exported at the beginning and end of each section (default value)
auto saveOptions = MakeObject<TxtSaveOptions>();
saveOptions->set_ExportHeadersFootersMode(txtExportHeadersFootersMode);
doc->Save(ArtifactsDir + u"TxtSaveOptions.ExportHeadersFooters.txt", saveOptions);
String docText = System::IO::File::ReadAllText(ArtifactsDir + u"TxtSaveOptions.ExportHeadersFooters.txt");
switch (txtExportHeadersFootersMode)
{
ASSERT_EQ(String(u"Page 1\r\n") + u"Page 2\r\n" + u"Page 3\r\n" + u"Even header\r\n\r\n" + u"Primary header\r\n\r\n" + u"Even footer\r\n\r\n" + u"Primary footer\r\n\r\n", docText);
break;
ASSERT_EQ(String(u"Primary header\r\n") + u"Page 1\r\n" + u"Page 2\r\n" + u"Page 3\r\n" + u"Primary footer\r\n", docText);
break;
ASSERT_EQ(String(u"Page 1\r\n") + u"Page 2\r\n" + u"Page 3\r\n", docText);
break;
}

◆ get_ForcePageBreaks()

bool Aspose::Words::Saving::TxtSaveOptionsBase::get_ForcePageBreaks ( ) const

Allows to specify whether the page breaks should be preserved during export. The default value is false.

Examples

Shows how to specify whether the page breaks should be preserved during export.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Page 1");
builder->Writeln(u"Page 2");
builder->Writeln(u"Page 3");
// If ForcePageBreaks is set to true then the output document will have form feed characters in place of page breaks
// Otherwise, they will be line breaks
auto saveOptions = MakeObject<TxtSaveOptions>();
saveOptions->set_ForcePageBreaks(forcePageBreaks);
doc->Save(ArtifactsDir + u"TxtSaveOptions.PageBreaks.txt", saveOptions);
// If we load the document using Aspose.Words again, the page breaks will be preserved/lost depending on ForcePageBreaks
doc = MakeObject<Document>(ArtifactsDir + u"TxtSaveOptions.PageBreaks.txt");
ASSERT_EQ(forcePageBreaks ? 3 : 1, doc->get_PageCount());

◆ get_ParagraphBreak()

System::String Aspose::Words::Saving::TxtSaveOptionsBase::get_ParagraphBreak ( ) const

Specifies the string to use as a paragraph break when exporting in text formats.

The default value is CrLf.

Examples

Shows how to save a .txt document with a custom paragraph break.

// Create a new document and add some paragraphs
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Paragraph 1.");
builder->Writeln(u"Paragraph 2.");
builder->Write(u"Paragraph 3.");
// When saved to plain text, the paragraphs we created can be separated by a custom string
auto txtSaveOptions = MakeObject<TxtSaveOptions>();
txtSaveOptions->set_SaveFormat(Aspose::Words::SaveFormat::Text);
txtSaveOptions->set_ParagraphBreak(u" End of paragraph.\n\n\t");
doc->Save(ArtifactsDir + u"TxtSaveOptions.ParagraphBreak.txt", txtSaveOptions);
String docText = System::IO::File::ReadAllText(ArtifactsDir + u"TxtSaveOptions.ParagraphBreak.txt");
ASSERT_EQ(String(u"Paragraph 1. End of paragraph.\n\n\t") + u"Paragraph 2. End of paragraph.\n\n\t" + u"Paragraph 3. End of paragraph.\n\n\t", docText);

◆ GetType()

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

◆ Is()

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

◆ set_Encoding()

void Aspose::Words::Saving::TxtSaveOptionsBase::set_Encoding ( System::SharedPtr< System::Text::Encoding value)

◆ set_ExportHeadersFootersMode()

void Aspose::Words::Saving::TxtSaveOptionsBase::set_ExportHeadersFootersMode ( Aspose::Words::Saving::TxtExportHeadersFootersMode  value)

◆ set_ForcePageBreaks()

void Aspose::Words::Saving::TxtSaveOptionsBase::set_ForcePageBreaks ( bool  value)

◆ set_ParagraphBreak()

void Aspose::Words::Saving::TxtSaveOptionsBase::set_ParagraphBreak ( System::String  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Saving::TxtSaveOptionsBase::Type ( )
static
String
@ PageBreak
Explicit page break.
@ HeaderEven
Header for even numbered pages.
@ PrimaryOnly
Only primary headers and footers are exported at the beginning and end of each section.
static ASPOSECPP_SHARED_API String ReadAllText(const String &path, const EncodingPtr &encoding=Text::Encoding::get_UTF8())
@ AllAtEnd
All headers and footers are placed after all section bodies at the very end of a document.
@ Text
Saves the document in the plain text format.
static ASPOSECPP_SHARED_API EncodingPtr get_UTF8()
@ None
No headers and footers are exported.
static ASPOSECPP_SHARED_API ArrayPtr< uint8_t > ReadAllBytes(const String &path)
@ HeaderPrimary
Primary header, also used for odd numbered pages.
@ FooterEven
Footer for even numbered pages.
@ FooterPrimary
Primary footer, also used for odd numbered pages.