Hi,
Thanks for your reply.
For the first issue(remove the underline of <a> tags from your Word file), as far as I know there are <a> tag and <u> tag which will add the underline for text in Html. Spire.Doc analysis <a> tag as a hyperlink. I tested your new file with
Spire.Office Platinum (DLL Only) Version:4.11.2, the list TextRange is not empty and the underline could be removed successfully in the result file. Below is my code.
- Code: Select all
Document doc = new Document();
doc.LoadFromFile(@"..\ Journal_2019-12-16_AR.docx");
List<TextRange> textRanges = new List<TextRange>();
foreach (Section s in doc.Sections)
{
foreach (var obj in s.Tables)
{
Table table = obj as Table;
foreach (TableRow row in table.Rows)
{
foreach (TableCell cell in row.Cells)
{
foreach (DocumentObject cobj in cell.ChildObjects)
{
if (cobj is Paragraph)
{
Paragraph par = cobj as Paragraph;
Field cField = null;
for (int a = 0; a < par.ChildObjects.Count; a++)
{
DocumentObject objj = par.ChildObjects[a];
if (objj is Field)
{
Field field = objj as Field;
if (field.Type == FieldType.FieldHyperlink)
{
cField = field;
}
}
else if (cField != null && objj is FieldMark && (objj as FieldMark).Type == FieldMarkType.FieldEnd && cField.End == objj)
{
int fieldEnd = par.ChildObjects.IndexOf(objj);
if (par.ChildObjects[fieldEnd - 1] is TextRange)
{
textRanges.Add(par.ChildObjects[fieldEnd - 1] as TextRange);
}
}
}
}
//Find embedded table
if (cobj is Table)
{
Table tableC = cobj as Table;
foreach (TableRow rowc in tableC.Rows)
{
foreach (TableCell cellc in rowc.Cells)
{
foreach (DocumentObject cobjc in cellc.ChildObjects)
{
if (cobjc is Paragraph)
{
Paragraph par = cobjc as Paragraph;
//Below code is for finding the hyperlink
Field cField = null;
for (int a = 0; a < par.ChildObjects.Count; a++)
{
DocumentObject objjj = par.ChildObjects[a];
if (objjj is Field)
{
Field field = objjj as Field;
if (field.Type == FieldType.FieldHyperlink)
{
cField = field;
}
}
else if (cField != null && objjj is FieldMark && (objjj as FieldMark).Type == FieldMarkType.FieldEnd && cField.End == objjj)
{
int fieldEnd = par.ChildObjects.IndexOf(objjj);
if (par.ChildObjects[fieldEnd - 1] is TextRange)
{
//find the textrange in hyperlink
textRanges.Add(par.ChildObjects[fieldEnd - 1] as TextRange);
}
}
}
}
}
}
}
}
}
}
}
}
}
for (int b = 0; b < textRanges.Count; b++)
{
//change the underline setting
textRanges[b].CharacterFormat.UnderlineStyle = UnderlineStyle.None;
}
doc.SaveToFile("result.docx", FileFormat.Docx);
If you still have the issue, could you please offer us your input Html and your desired result file for further investigation? You could upload them here or send us(
support@e-iceblue.com) via email.
About the conversion issue, I have reproduced it and logged it into our bug tracking system. Once there is any progress, we will inform you. Apologize for the inconvenience caused.
Best wishes,
Amber
E-iceblue support team