Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
In this article, we will learn what options can be useful for working with a text document via Aspose.Words. Please note that this is not a complete list of available options, but only an example of working with some of them.
You can use the AddBidiMarks property to specify whether to add bi-directional marks before each BiDi run when exporting in plain text format. Aspose.Words inserts Unicode Character ‘RIGHT-TO-LEFT MARK’ (U+200F) before each bi-directional Run in the text. This option corresponds to “Add bi-directional marks” option in MS Word File Conversion dialogue when you export to a Plain Text format. Note that it appears in dialogue only if any of Arabic or Hebrew editing languages are added in MS Word.
The following code example shows how to use AddBidiMarks property. The default value of this property is false:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"Input.docx"); | |
System::SharedPtr<TxtSaveOptions> saveOptions = System::MakeObject<TxtSaveOptions>(); | |
saveOptions->set_AddBidiMarks(true); | |
System::String outputPath = outputDataDir + u"WorkingWithTxt.AddBidiMarks.txt"; | |
doc->Save(outputPath, saveOptions); |
Aspose.Words can import list item of a text file as list numbers or plain text in its document object model. The DetectNumberingWithWhitespaces property allows to specify how numbered list items are recognized when a document is imported from plain text format:
The following code example shows how to use this property:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<TxtLoadOptions> loadOptions = System::MakeObject<TxtLoadOptions>(); | |
loadOptions->set_DetectNumberingWithWhitespaces(false); | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"LoadTxt.txt", loadOptions); | |
System::String outputPath = outputDataDir + u"WorkingWithTxt.DetectNumberingWithWhitespaces.docx"; | |
doc->Save(outputPath); |
You can control the way of handling leading and trailing spaces during loading TXT file. The leading spaces could be trimmed, preserved or converted to indent and trailing spaces could be trimmed or preserved.
The following code example shows how to trim leading and trailing spaces while importing TXT file:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<TxtLoadOptions> loadOptions = System::MakeObject<TxtLoadOptions>(); | |
loadOptions->set_LeadingSpacesOptions(TxtLeadingSpacesOptions::Trim); | |
loadOptions->set_TrailingSpacesOptions(TxtTrailingSpacesOptions::Trim); | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"LoadTxt.txt", loadOptions); | |
System::String outputPath = outputDataDir + u"WorkingWithTxt.HandleSpacesOptions.docx"; | |
doc->Save(outputPath); |
If you want to export header and footer in output TXT document, you can use the ExportHeadersFootersMode property. This property specifies the way headers and footers are exported to the plain text format.
The following code example shows how to export headers and footers to plain text format:
Aspose.Words introduced the TxtListIndentation class that allows specifying how list levels are indented while exporting to a plain text format. While working with TxtSaveOption, the ListIndentation property is provided to specify the character to be used for indenting list levels and count specifying how many characters to use as indentation per one list level.
The default value for character property is ‘\0’ indicating that there is no indentation. For count property, the default value is 0 which means no indentation.
The following code example shows how to export list levels using tab characters:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"input_document"); | |
System::SharedPtr<TxtSaveOptions> options = System::MakeObject<TxtSaveOptions>(); | |
options->get_ListIndentation()->set_Count(1); | |
options->get_ListIndentation()->set_Character(u'\t'); | |
doc->Save(outputDataDir + u"WorkingWithTxt.UseTabCharacterPerLevelForListIndentation.txt", options); |
The following code example shows how to export list levels using space characters:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"input_document"); | |
System::SharedPtr<TxtSaveOptions> options = System::MakeObject<TxtSaveOptions>(); | |
options->get_ListIndentation()->set_Count(3); | |
options->get_ListIndentation()->set_Character(u' '); | |
doc->Save(outputDataDir + u"WorkingWithTxt.UseSpaceCharacterPerLevelForListIndentation.txt", options); |
The following code example shows how to export list levels using default indentation:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<Document> doc1 = System::MakeObject<Document>(inputDataDir + u"input_document"); | |
doc1->Save(outputDataDir + u"WorkingWithTxt.DefaultLevelForListIndentation1.txt"); | |
//Document doc2 = new Document("input_document"); | |
System::SharedPtr<Document> doc2 = System::MakeObject<Document>(inputDataDir + u"Input.docx"); | |
System::SharedPtr<TxtSaveOptions> options = System::MakeObject<TxtSaveOptions>(); | |
doc2->Save(outputDataDir + u"WorkingWithTxt.DefaultLevelForListIndentation2.txt", options); |
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.