Hi,
How to get the table of content item body in Bytes[]
Please find the attached Document - TOC.zip (14.7 KB)
Hi,
How to get the table of content item body in Bytes[]
Please find the attached Document - TOC.zip (14.7 KB)
You can build logic on the following code to extract TOC items:
Document doc = new Document("E:\\TOC\\TOC.doc");
foreach (Field field in doc.Range.Fields)
{
if (field.Type.Equals(Aspose.Words.Fields.FieldType.FieldHyperlink))
{
FieldHyperlink hyperlink = (FieldHyperlink)field;
if (hyperlink.SubAddress != null && hyperlink.SubAddress.StartsWith("_Toc"))
{
Paragraph tocItem = (Paragraph)field.Start.GetAncestor(NodeType.Paragraph);
Console.WriteLine(tocItem.ToString(SaveFormat.Text).Trim());
Console.WriteLine("------------------");
}
}
}
Hope, this helps.
Hi @awais.hafeez,
Agenda - Compare the word files with section by section / Section by Multiple sections in table with before and after format.
We are working with Groupdocs.Compare to compare Word file sections,
Earlier we had tried with
Now trying to convert Sections into bytes[] and then compare both Sections
Groupdocs.Compare is working fine with bytes[] to bytes[] comparison
but we are stuck with Converting sections into bytes[]
Please use the following code to get byte[] of every Section in Word document:
Document doc = new Document("E:\\temp\\in.docx");
foreach (Section sec in doc.Sections)
{
Document temp = (Document) doc.Clone(false);
temp.RemoveAllChildren();
Section importedSec = (Section) temp.ImportNode(sec, true);
temp.Sections.Add(importedSec);
MemoryStream stream = new MemoryStream();
temp.Save(stream, SaveFormat.Docx);
byte[] secBytes = stream.ToArray();
}
Hope, this helps.