I’m looking into converting a part of word document into html/text and I need to detect custom tabstops and convert them the corresponding characters. (A tab stop can have different deliminator like "."or “_”)
At the moment I want to just replace the content of a tabstop into characters directly in the word document, and later convert it to html.
Do you have any suggested implementation, or any other suggestion on how to do that?
@cornelcc,
Please see these sample input and output Word documents (Docs.zip (9.8 KB)) have different Tab Stops. You can use the following code to change different settings:
Document doc = new Document(MyDir + @"ParasWithTabStops.docx");
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
for (int i = 0; i < para.ParagraphFormat.TabStops.Count; i++)
{
TabStop ts = para.ParagraphFormat.TabStops[i];
// Apply different settings
ts.Leader = TabLeader.Line;
}
}
doc.Save(MyDir + @"18.2.docx");
Also you can use Node.ToString Method (SaveFormat) method to export the content of the node(s) into a string in the specified format such as HTML. Hope, this helps.
Thank you Awais, it worked as you suggested.