We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Position in Points Relative to Page

Hello,

is there a way to determine the position relative to the top of the page.
Like it is provided by the MS Word API:
? application.ActiveWindow.Selection.Information(wdVerticalPositionRelativeToPage)

In practice i have the problem to calculate the availabe height of the page.
At best in relation to the current position.

I have already tried to remove TopMargin, BottomMargin, FooterDistance and HeaderDistance from the PageHeight Property of the attached document.
But the result is something about 714 points. If is set the inserted inlineShape Height to this value, the shapes height exceeds the availabe space.

Thanks for your help.

Greetings,

Sacha End

Hi Sacha,

Thanks for your request. MS Word document is flow document and does not contain any information about its layout into lines and pages. So there is no way to determine on which page and where on the page some particular node is located.

In Aspose.Words we use our own Rendering Engine, which layouts Word document into pages. Using this Rendering Engine it is possible to determine position of the particular node. But currently there is no public API to achieve this. But we have plans to expose layout information. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is supported. The feature ID is WORDSNET-2978.

I have already tried to remove TopMargin, BottomMargin, FooterDistance and HeaderDistance from the PageHeight Property of the attached document.
But the result is something about 714 points. If is set the inserted inlineShape Height to this value, the shapes height exceeds the availabe space.

I have tested the scenario with following code snippet and have not found any issue while using latest version of Aspose.Words for .NET. Can you please share some more information about this issue?

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
PageSetup ps = doc.FirstSection.PageSetup;
double height = ps.PageHeight - ps.TopMargin - ps.BottomMargin - ps.FooterDistance - ps.HeaderDistance;
Shape img = builder.InsertImage(@"d:\image.jpg");
img.Height = height;
doc.Save(MyDir + "AsposeOut.docx");

Hello,
thanks for the information and the sample code.
With your code and the attached document, you should receive a heigh of approximately 714 points.
Using this height the image is greater than the available space in the body of the document.
You can see the footline overlaps the image.
I have found a reslution command line directly in word, described in my first mail. With this command line i receive a position about approximately approximately 104 points at the top, further removing the bottom margin and footer distance, i receive an available height from about approximately 680 points, which solves the problem.
Perhaps you have an idea to reach the same information using the aspose api ?
Thank you in advance.
Greetings
Sacha End

Hi Sacha,

Thanks for sharing the details. It is nice to hear from you that you have solved your problem.

Your document has four section with different height. I have not found the issue with image size, please see the attached images. The section which contain the image has height = 29.7 cm which is equal to 841 points and PageSetup.PageHeight returns the correct page height. Please let us know if you have any more queries.

Document doc = new Document(MyDir+"target.doc");
foreach (Section section in doc.Sections)
{
    PageSetup ps = section.PageSetup;
    double height = ps.PageHeight - ps.TopMargin - ps.BottomMargin - ps.FooterDistance - ps.HeaderDistance;
    Console.Write(height);
}

The issues you have found earlier (filed as WORDSNET-2978) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(72)