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>
-----------------------------
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:
https://releases.aspose.com/words/net
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:
<html>
<body>
1234567890
</body>
</html>
Output: test.html & test2.html(formatted for display)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="Aspose.Words for .NET 13.5.0.0" />
<title>
</title>
</head>
<body>
<div>
<p style="margin:0pt"><span style="font-family:'Times New Roman'; font-size:12pt"> Here is simple html text: 1234567890 </span></p>
</div>
</body>
</html>
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,