Mapping Nodes Coordinates to It's Coordinates on an Image

Hi there,

I am able to get the coordinate of nodes in a word document using the LayoutEnumerator and LayoutCollector. I am trying to draw a rectangle on a particular node after transforming the document to an Image:
This is the code I used to transform the document into an Image:
List pageImages = new List();
// the format being either PNG, JPG or GIF
SaveFormat saveFormat = GetFormat(imageOptions.ImageFormat);
ImageSaveOptions saveOptions = new
ImageSaveOptions(saveFormat);
for(int i= 0; i < _document.PageCount; i++)
{
MemoryStream stream = new MemoryStream();
saveOptions.PageIndex = i;
_document.Save(stream, saveOptions);
stream.Seek(0, SeekOrigin.Begin);
pageImages.Add(stream);
}
return pageImages;

When I render the stream to an Image and using the Graphics object draw a rectangle on the coordinates I obtained from the LayoutEnumerator, the position doesn’t match at all.

Things that I have tried:
1.) transforming the node( eg a span with text “we”) coordinates to pixels using this formula 1pt = 1.333333px.
2.) Obtaining through calculations the DPI settings Aspose uses to create the Image and adding that to the Y coord of a node.
3.) getting the page’s pixels from the points, subtracting the page’s heightInPoints from the page’s heightInPixels and dividing by 2 and adding to the Node’s Y coord.

I tried all the above and still, none of them maps the node’s coordinate to its position on the Image.

My question is this: I want to know if it’s possible to hook into the process of creating the Image and obtain the true coordinates of the node.
This is the doucment I am using for the process: source.zip (10.2 KB)

@Trickstar,

To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Aspose.Words 19.3 generated output document (image) showing the undesired behavior
  • Your expected document showing the correct output. You can create expected document by using MS Word for example.
  • Please also create a simplified standalone console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.