Graphics too big to fit space between header and footer.

G

GBPA

I have a program that produces a graphic (JPG file) and inserts it plus a
section
heading plus sometimes a caption at a bookmark, on one single page of a
Word document based on a template that I provide. I can adjust the graphic's
size to fit the page.

Some customers add rather large headers and footers to the template. When
they
try to generate the document, either the heading and text get separated from
the
graphic by a page break or else part of the graphic is obscured by the footer.

How do I programmatically (C#) determine the _real_ size of the space I have
to
work with - page size minus header minus footer? Is there a way?

Thank you,
Gabriel
 
C

Cindy M.

Hi =?Utf-8?B?R0JQQQ==?=,
I have a program that produces a graphic (JPG file) and inserts it plus a
section
heading plus sometimes a caption at a bookmark, on one single page of a
Word document based on a template that I provide. I can adjust the graphic's
size to fit the page.

Some customers add rather large headers and footers to the template. When
they
try to generate the document, either the heading and text get separated from
the
graphic by a page break or else part of the graphic is obscured by the footer.

How do I programmatically (C#) determine the _real_ size of the space I have
to
work with - page size minus header minus footer? Is there a way?
Get the position of the first line of text on the page (either Range or
Selection object) then use the Information property with the
wdVerticalPositionRelativeToPage value.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
G

GBPA

OK, thank you, that helped me get the location of the top of the space I have
available, i.e., just below the header. Here's the call:

float topPosition =
(float)range.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);

Now, for the equally important part two. There is a footer on the page.
How do I figure out how far above the bottom of the page it begins?

Thank you again,
Gabriel
 
C

Cindy M.

Hi =?Utf-8?B?R0JQQQ==?=,
Now, for the equally important part two. There is a footer on the page.
How do I figure out how far above the bottom of the page it begins?
Similar approach, using the Information function. But this time, use it on
the Footer's range (first line). Very roughly (typed off the top of my
head):

mydoc.Sections[index].Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary
).Range

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
G

GBPA

Excellent for "off the top of my head".

The call I used:

float bottomPosition =
(float)range.Sections[index].Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.End;

I use the End for the range of the footer to get its height.

Thank you so much!
Gabriel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top