Aspose::Words::Saving::TxtSaveOptions Class Reference

Detailed Description

Can be used to specify additional options when saving a document into the Text format.

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/TxtSaveOptions.h>

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

Public Member Functions

 TxtSaveOptions ()
 
bool get_AddBidiMarks () const
 Specifies whether to add bi-directional marks before each BiDi run when exporting in plain text format. The default value is false. More...
 
SharedPtr< TxtListIndentationget_ListIndentation () const
 Gets a ListIndentation object that specifies how many and which character to use for indentation of list levels. By default it is zero count of character '\0', that means no indentation. More...
 
bool get_PreserveTableLayout () const
 Specifies whether the program should attempt to preserve layout of tables when saving in the plain text format. The default value is false. More...
 
SaveFormat get_SaveFormat () override
 Specifies the format in which the document will be saved if this save options object is used. Can only be Text. More...
 
bool get_SimplifyListLabels () const
 Specifies whether the program should simplify list labels in case of complex label formatting not being adequately represented by plain text. If set to true, numbered list labels are written in simple numeric format and itemized list labels as simple ASCII characters. The default value is false. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_AddBidiMarks (bool value)
 Setter for get_AddBidiMarks. More...
 
void set_PreserveTableLayout (bool value)
 Setter for get_PreserveTableLayout. More...
 
void set_SaveFormat (SaveFormat value) override
 Setter for get_SaveFormat. More...
 
void set_SimplifyListLabels (bool value)
 Setter for get_SimplifyListLabels. More...
 
- Public Member Functions inherited from TxtSaveOptionsBase
 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...
 
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...
 
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 TxtSaveOptionsBase
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

◆ TxtSaveOptions()

Aspose::Words::Saving::TxtSaveOptions::TxtSaveOptions ( )

Member Function Documentation

◆ get_AddBidiMarks()

bool Aspose::Words::Saving::TxtSaveOptions::get_AddBidiMarks ( ) const

Specifies whether to add bi-directional marks before each BiDi run when exporting in plain text format. The default value is false.

Examples

Shows how to insert Unicode Character 'RIGHT-TO-LEFT MARK' (U+200F) before each bi-directional Run in text.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
builder->get_ParagraphFormat()->set_Bidi(true);
builder->Writeln(u"שלום עולם!");
builder->Writeln(u"مرحبا بالعالم!");
auto saveOptions = MakeObject<TxtSaveOptions>();
saveOptions->set_AddBidiMarks(addBidiMarks);
saveOptions->set_Encoding(System::Text::Encoding::get_Unicode());
doc->Save(ArtifactsDir + u"TxtSaveOptions.AddBidiMarks.txt", saveOptions);
String docText = System::Text::Encoding::get_Unicode()->GetString(System::IO::File::ReadAllBytes(ArtifactsDir + u"TxtSaveOptions.AddBidiMarks.txt"));
if (addBidiMarks)
{
ASSERT_EQ(u"\ufeffHello world!‎\r\nשלום עולם!‏\r\nمرحبا بالعالم!‏\r\n\r\n", docText);
ASSERT_TRUE(docText.Contains(u"\u200f"));
}
else
{
ASSERT_EQ(u"\ufeffHello world!\r\nשלום עולם!\r\nمرحبا بالعالم!\r\n\r\n", docText);
ASSERT_FALSE(docText.Contains(u"\u200f"));
}

◆ get_ListIndentation()

System::SharedPtr<Aspose::Words::Saving::TxtListIndentation> Aspose::Words::Saving::TxtSaveOptions::get_ListIndentation ( ) const

Gets a ListIndentation object that specifies how many and which character to use for indentation of list levels. By default it is zero count of character '\0', that means no indentation.

Examples

Shows how to configure list indenting when converting to plaintext.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create a list with three levels of indentation
builder->get_ListFormat()->ApplyNumberDefault();
builder->Writeln(u"Item 1");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Item 2");
builder->get_ListFormat()->ListIndent();
builder->Write(u"Item 3");
// Microsoft Word list objects get lost when converting to plaintext
// We can create a custom representation for list indentation using pure plaintext with a SaveOptions object
// In this case, each list item will be left-padded by 3 space characters times its list indent level
auto txtSaveOptions = MakeObject<TxtSaveOptions>();
txtSaveOptions->get_ListIndentation()->set_Count(3);
txtSaveOptions->get_ListIndentation()->set_Character(u' ');
doc->Save(ArtifactsDir + u"TxtSaveOptions.TxtListIndentation.txt", txtSaveOptions);
String docText = System::IO::File::ReadAllText(ArtifactsDir + u"TxtSaveOptions.TxtListIndentation.txt");
ASSERT_EQ(String(u"1. Item 1\r\n") + u" a. Item 2\r\n" + u" i. Item 3\r\n", docText);

◆ get_PreserveTableLayout()

bool Aspose::Words::Saving::TxtSaveOptions::get_PreserveTableLayout ( ) const

Specifies whether the program should attempt to preserve layout of tables when saving in the plain text format. The default value is false.

Examples

Shows how to preserve the layout of tables when converting to plaintext.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a table
builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, cell 1");
builder->InsertCell();
builder->Write(u"Row 1, cell 2");
builder->EndRow();
builder->InsertCell();
builder->Write(u"Row 2, cell 1");
builder->InsertCell();
builder->Write(u"Row 2, cell 2");
builder->EndTable();
// Tables, with their borders and widths do not translate to plaintext
// However, we can configure a SaveOptions object to arrange table contents to preserve some of the table's appearance
auto txtSaveOptions = MakeObject<TxtSaveOptions>();
txtSaveOptions->set_PreserveTableLayout(preserveTableLayout);
doc->Save(ArtifactsDir + u"TxtSaveOptions.TableLayout.txt", txtSaveOptions);
String docText = System::IO::File::ReadAllText(ArtifactsDir + u"TxtSaveOptions.TableLayout.txt");
if (preserveTableLayout)
{
ASSERT_EQ(String(u"Row 1, cell 1 Row 1, cell 2\r\n") + u"Row 2, cell 1 Row 2, cell 2\r\n\r\n", docText);
}
else
{
ASSERT_EQ(String(u"Row 1, cell 1\r\n") + u"Row 1, cell 2\r\n" + u"Row 2, cell 1\r\n" + u"Row 2, cell 2\r\n\r\n", docText);
}

◆ get_SaveFormat()

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

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

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);

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

◆ get_SimplifyListLabels()

bool Aspose::Words::Saving::TxtSaveOptions::get_SimplifyListLabels ( ) const

Specifies whether the program should simplify list labels in case of complex label formatting not being adequately represented by plain text. If set to true, numbered list labels are written in simple numeric format and itemized list labels as simple ASCII characters. The default value is false.

Examples

Shows how to change the appearance of lists when converting to plaintext.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create a bulleted list with five levels of indentation
builder->get_ListFormat()->ApplyBulletDefault();
builder->Writeln(u"Item 1");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Item 2");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Item 3");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Item 4");
builder->get_ListFormat()->ListIndent();
builder->Write(u"Item 5");
// The SimplifyListLabels flag will convert some list symbols
// into ASCII characters such as *, o, +, > etc, depending on list level
auto txtSaveOptions = MakeObject<TxtSaveOptions>();
txtSaveOptions->set_SimplifyListLabels(simplifyListLabels);
doc->Save(ArtifactsDir + u"TxtSaveOptions.SimplifyListLabels.txt", txtSaveOptions);
String docText = System::IO::File::ReadAllText(ArtifactsDir + u"TxtSaveOptions.SimplifyListLabels.txt");
if (simplifyListLabels)
{
ASSERT_EQ(String(u"* Item 1\r\n") + u" > Item 2\r\n" + u" + Item 3\r\n" + u" - Item 4\r\n" + u" o Item 5\r\n", docText);
}
else
{
ASSERT_EQ(String(u"· Item 1\r\n") + u"o Item 2\r\n" + u"§ Item 3\r\n" + u"· Item 4\r\n" + u"o Item 5\r\n", docText);
}

◆ GetType()

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

◆ Is()

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

◆ set_AddBidiMarks()

void Aspose::Words::Saving::TxtSaveOptions::set_AddBidiMarks ( bool  value)

◆ set_PreserveTableLayout()

void Aspose::Words::Saving::TxtSaveOptions::set_PreserveTableLayout ( bool  value)

◆ set_SaveFormat()

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

◆ set_SimplifyListLabels()

void Aspose::Words::Saving::TxtSaveOptions::set_SimplifyListLabels ( bool  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Saving::TxtSaveOptions::Type ( )
static
String
static ASPOSECPP_SHARED_API String ReadAllText(const String &path, const EncodingPtr &encoding=Text::Encoding::get_UTF8())
@ Text
Saves the document in the plain text format.
static ASPOSECPP_SHARED_API EncodingPtr get_Unicode()
static ASPOSECPP_SHARED_API ArrayPtr< uint8_t > ReadAllBytes(const String &path)