Hello,
I’m exporting the content of a word document to HTML.
Are there any options in HtmlSaveOptions
to export bold texts using <strong> </strong>
instead of style="font-weight:bold"
?
Thank you,
Csaba Kiss
Hello,
I’m exporting the content of a word document to HTML.
Are there any options in HtmlSaveOptions
to export bold texts using <strong> </strong>
instead of style="font-weight:bold"
?
Thank you,
Csaba Kiss
To export bold text from a Word document to HTML using <strong>
tags instead of the default style="font-weight:bold"
, you can utilize the HtmlSaveOptions
class in Aspose.Words. However, the current version of Aspose.Words does not provide a direct option to change the output for bold text specifically to <strong>
tags.
As a workaround, you can post-process the generated HTML to replace instances of style="font-weight:bold"
with <strong>
tags. Here’s a simple example of how you might implement this in C#:
using System.IO;
using Aspose.Words;
using Aspose.Words.Saving;
class Program
{
static void Main()
{
// Load the document
Document doc = new Document("path/to/your/document.docx");
// Save the document to HTML
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
doc.Save("output.html", saveOptions);
// Read the generated HTML
string htmlContent = File.ReadAllText("output.html");
// Replace style="font-weight:bold" with <strong>
htmlContent = htmlContent.Replace("style=\"font-weight:bold\"", "<strong>");
// Save the modified HTML
File.WriteAllText("output_modified.html", htmlContent);
}
}
In this example, after saving the document to HTML, the code reads the generated HTML file, replaces the bold style with <strong>
, and then saves the modified content to a new file. This approach allows you to achieve the desired output format.
If you have further questions or need additional assistance, feel free to ask!