Free Support Forum - aspose.com

Page with header/footer

I’m using Aspose.Word for .NET. My program produces a page which has a header, a footer and a image in the page’s body. I want to resize the image to fill all the space left in the body. But the content of header and footer are customized by end-user and I don’t know how large the height of header/footer will be.
How can I know the remaining space left after adding the header/footer into the page in order to resize the image?

Hi

Thanks for your inquiry. I think that you should use HeaderDistance and FooterDistance properties or BottomMargin and TopMargin properties. See the following code snippet.

doc.FirstSection.PageSetup.HeaderDistance;

doc.FirstSection.PageSetup.FooterDistance;

Or

doc.FirstSection.PageSetup.TopMargin;

doc.FirstSection.PageSetup.BottomMargin;

Also see the following link.

http://www.aspose.com/Products/Aspose.Words/Api/Aspose.Words.PageSetup.HeaderDistance.html

Best regards.

Hi,
I have the same problem with nkpham. But your suggest doesn’t solve the problem.

Let me describe again:
I’m creating an application that allows users to input content in HTML for header and footer, and insert one picture.
By using Aspose.Words, output must has header & footer and image in a page. If the image is too high, it must be resized to fix into the page.
How can I know the height of header/footer so that I can resize the image?

Hi

Thanks for your inquiry. I think that you can try to use the following code to calculate maximum height and width of image.

PageSetup pageSetup = doc.FirstSection.PageSetup;

double imageWidth = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin;

double imageHeight = pageSetup.PageHeight - pageSetup.TopMargin - pageSetup.BottomMargin;

I hope that this will help you.

Best regards,