Hi Team,
Test File - BPIA-1087.docx (25.9 KB)
image.png (7.9 KB)
for the line which is inserted as first line of document, for this track change getting as 2nd change, and track change inside the box was getting as first. and for newly inserted line was getting parent paragraph as content which is in the box. pls find attached document above.
image.png (12.8 KB)
@sireesha.manne Both order and the insertion parent paragraph content are correct. Text box in your document has a floating position and actually is a child of the first paragraph and goes as a first node of it. You can check this if unzip your document and explore document.xml
:
<w:p w14:paraId="46784066" w14:textId="29B8FD61" w:rsidR="00BA4AB3" w:rsidRPr="009C2ECC" w:rsidRDefault="00A73431" w:rsidP="00BD2A20">
<w:r w:rsidRPr="00C17459">
<w:rPr>
<w:noProof/>
<w:lang w:eastAsia="de-CH"/>
</w:rPr>
<mc:AlternateContent>
<!-- here is the textbox.... -->
</mc:AlternateContent>
</w:r>
<w:ins w:id="4" w:author="Vipin Semwal" w:date="2022-06-08T16:51:00Z">
<w:r>
<w:t>Adding new line at the top</w:t>
</w:r>
</w:ins>
</w:p>
When you get text of the parent paragraph of the insertion revision it also includes the text all children including textbox.
we got an issue like classic technical correct vs business correct issue. From a business requirement the order needs to follow the visual flow of the document. Technically the construction of the document leads to a different order which is different to the visual perspective. So can we check when content is in a floating box to determine if the coordinates of the floating box is below other text. If yes - ‘override’ the default position of the text inside box.
@sireesha.manne You can try using LayoutCollector and LayoutEnumenrator to calculate rectangles each paragraph with revision occupy. For example see the following code:
Document doc = new Document(@"C:\Temp\in.docx");
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumenrator = new LayoutEnumerator(doc);
foreach (Revision r in doc.Revisions)
{
// Get revision parent paragraph entity,
// which will be used to calculate the rectangle it occupy.
object entity = collector.GetEntity(r.ParentNode.GetAncestor(NodeType.Paragraph));
if (entity != null)
{
enumenrator.Current = entity;
Console.WriteLine(enumenrator.Rectangle);
}
}
Thanks, @alexey.noskov, is any chance to get track changes based on the ‘y’ coordinate! then we may get track changes in which order we are seeing in the document visually (or) any other way to get track changes how we see in document irrespective of the position of shapes(like rectangles et.,) included in the document!
@sireesha.manne Unfortunately, there is no built-in way to get nodes in visual order using Aspose.Words. Nodes are in the order they are read from the document into the DOM. The only possible way it to calculate absolute position of some node is using LayoutCollector
and LayoutEnumerator
classes.