Undesired conversion to enumeration

Hi,

We have a fairly simple text file which we’re converting to RTF using Aspose.Words. The text file contains a couple of lines that start with a ascending numbers like

Das ist ein Test
1. Zeile eins
2. zweite Zeile
3. und noch eine
Zeile ohne Nummer.

Unfortunately, when saving the document as an rtf-file the lines starting with a number are converted to un enumeration. Is there a way to prevent that undesired conversion?

I attached example code also containing the sample text file for your convenience.
ConvertToRtfBug.7z (2.9 KB)

Thanks in advance,
Gerrit

@gbette

To prevent the undesired conversion of lines starting with numbers into an enumeration when converting a text file to RTF using Aspose.Words, you can try the following approach:

  1. Modify the Text Format: Before converting the text file, you can modify the lines that start with numbers to ensure they are treated as regular text rather than a list. For example, you could prepend a character or string that indicates it should not be treated as a list item.

  2. Use a Different Load Format: Ensure that you are loading the text file in a way that does not interpret numbered lines as list items. You might want to explore different loading options or formats that could help maintain the original formatting.

  3. Post-Processing: After converting to RTF, you can programmatically adjust the RTF content to remove any unwanted list formatting. This would involve parsing the RTF and modifying the relevant sections.

Here is a simple code example that demonstrates how to load a text file and save it as RTF, while ensuring that the lines are treated correctly:

using Aspose.Words;

Document doc = new Document("input.txt");
doc.Save("output.rtf");

If the above methods do not resolve the issue, consider checking the Aspose.Words documentation for more advanced options related to formatting and conversion settings.

If you continue to experience issues, you may want to reach out to the Aspose community or support for more tailored assistance.

Sources:
[1]: Convert a Document in Java|Aspose.Words for Java - Aspose Documentation

Thanks for your answer. We’re already using LoadFormat.Text. Please refer to the sample code attached to my first post. From our point of view LoadFormat.Text should treat the content as plain text without interpreting those lines a numbered list. Hence, we consider this behavior as a bug.

@gbette What you are looking for is TxtLoadOptions.AutoNumberingDetection property:

TxtLoadOptions opt = new TxtLoadOptions();
opt.AutoNumberingDetection = false;
Document doc = new Document(@"C:\Temp\in.txt", opt);
doc.Save(@"C:\Temp\out.rtf");

@alexey.noskov Thanks, that works like a charm!

1 Like