We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Incorrect parsing of a text document

I am using Aspose Words for .NET 14.11.0.0

I have a very simple .txt document that consists of a single line:
“1 billion dollars”

I have a very simple C# program:

var document = new Document(@"billion dollars.txt");
Console.WriteLine(document.GetText());

This program outputs “billion dollars”.

I guess that Aspose assumes that “1” is an indicator of a list, but this is incorrect in my case.

Is there a way I can prevent Aspose from consuming my “1” in this situation?

Hi Artem,

Thanks for your inquiry. Please use Document.ToString(SaveFormat.Text) to get the text of document. Hope this helps you.

If the problem still remains, please attach your input Txt document here for testing. I will investigate the issue on my side and provide you more information.

Hi, Tahir. Thanks for the reply.

I’ve tried to use document.ToString(SaveFormat.Text), but this still returns “billion dollars”.

I’ve attached a file. Please have a look

Hi Artem,

Thanks for sharing the detail. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-11243. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Artem,

Thanks for your patience. Please use the latest version of Aspose.Words for .NET 14.12.0 and use LoadOptions.AllowTrailingWhitespaceForListItems property as shown in following code example to achieve your requirements.

LoadOptions options = new LoadOptions();
options.AllowTrailingWhitespaceForListItems = false;
options.LoadFormat = LoadFormat.Text;
Document doc = new Document(MyDir + "billion+dollars.txt", options);
doc.Save(MyDir + "Out.docx");

This property allows to specify how numbered list items are recognized when document is imported from plain text format. The default value is true.

  • This property is used only when loading plain text documents.
  • If set to true, lists recognition algorithm allows list numbers to end with either dot or whitespace character.
  • If this option is set to false then the list item is only recognized as such if the leading number is ending with dot “.” symbol.

Please let us know if you have any more queries.