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

Free Support Forum - aspose.com

Text to HTML with html within the text

I am trying to convert a text doucment that has text along with HTML to an HTML document. The results are not what I expected, I lose the text of the html tags, which are supposed to be considered text. I have tried to using LoapOptions with the LoadFormat set as Text, but I get the same result.

.NET

Aspose.Words.LoadOptions lo = new Aspose.Words.LoadOptions(Aspose.Words.LoadFormat.Text,null,null);

Document doc = new Document(filepath, lo);

doc.Save(newfilepath, Aspose.Words.SaveFormat.Html);

Example: test.txt

Here is simple html text:

<html>
<body>
1234567890
</body>
</html>

END

-----------------------------

Hi,

Thanks for your inquiry. After an initial test with Aspose.Words 13.5.0, I was unable to reproduce this issue on my side. Please upgrade to the latest version of Aspose.Words from the following link:
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/default.aspx

I hope, this helps.

Moreover, I have attached sample input/output documents here for your reference. If we can help you with anything else, please feel free to ask.

Best regards,

Thank you for responding to my issue. I have downloaded the lastest Words . NET (13.5) and my results are the same. Below is my test file and the output along with the code I used to generate the output.

Input: test.txt

Here is simple html text:


1234567890

Output: test.html & test2.html (formatted for display)













Here is simple html text: 1234567890







Program.cs:

Document doc;

try{

doc = new Document("C:\\test.txt");

doc.Save("C:\\test.html");

doc.Save("C:\\test2.html",Aspose.Words.SaveFormat.Html);

}

catch (Exception e){

Console.WriteLine("Error: e.Message");

}


Hi,


Thanks for the additional information. Please specify the LoadOptions and try run the following code snippet. This will fix the issue:

Aspose.Words.LoadOptions
loadOptions =
new Aspose.Words.LoadOptions();

loadOptions.LoadFormat = LoadFormat.Text;

Document doc = new Document(@"C:\Temp\Docs\test.txt", loadOptions);

doc.Save(@"C:\Temp\docs\outputputfixed.html");


Best regards,