Sections with headers


#1

I am creating a document with section headers, but cannot get the header to align to the left.

I have set

heading2.IsAutoSequence = False

heading2.LabelWidth = 0

Is there another setting to get the section header to align with the left margin and the section text?


#2

Hi,

Thank you for considering Aspose.

I don't know why you set the properties of heading. The header should be aligned to left by default. Please refer to http://www.aspose.com/wiki/default.aspx/Aspose.Pdf/SetPageHeaderAndFooter.html. Please elaborate your problem or provide a example if you still can't solve the problem.


#3

The headers are aligned to the left but there seem to be one or two spaces generated and so the header does not line up with the other text.

It looks like there is a space between the generated label and the header text, and if label width is set to 0 the space still remains.


#4

You mean "heading" but not "header", right?

Yes a space is reserved between the label and the text. If you set the label width to 0, Aspose.Pdf will enlarge this value to make sure the label can be displayed and there is a blank. Do you need to remove the blank between the label and text?


#5

Sorry, heading.

Yes, it would be good to have the headings line up with the rest of the document.

On a seperate issue how do I get page numbers into a footer. Is there a current page number variable or a replaceable symbol ?

Is there a list of replaceable symbols?

Also I am generating the sections dynamically with the same code and headers and footers appear fine apart from the first page (after the TOC). Any ideas why that would be?

Appreciate any help.


#6

Making heading lines up with the rest of the document is not supported directly. But you can try setting the labelwidth to a proper value (not 0 but something like 9.8, just equals the width of the length of the text in the label) Which will help you to get the similar effect.

you can find a list of replaceable symbols at http://www.aspose.com/Wiki/default.aspx/Aspose.Pdf/SymbolsListAndPurpose.html. We have just added a new symbol #$REFPAGE which is used to get the page number of a paragraph but it has not been added into this list yet. Please refer to http://www.aspose.com/community/Blogs/tommy.wang/archive/2005/10/23/34237.aspx.

About you last question, you need the TOC page have the same header and footer with the subsequent pages, right? This is not supported but I think we should add support for it soon.


#7

This indents the heading more than the 0 value.

Thanks for that, $p works fine.

It would be nice just to set the header and footers for a document and not have to set it for each section. The problem I am having is not to do with the TOC. I am using the same code to dynamically generate each section in a document, but the first page of sections (ie after the TOC) does not display the header and footer but all the other pages are fine (ie it looks like IsSubsequentPagesOnly has been set, but I have not set IsSubsequentPagesOnly/IsFirstPageOnly)

I tried setting IsFirstPageOnly on the header but the result is the same.

The code I use for each section is:-

CurrentSection = Doc.Sections.Add()
CurrentSection.EvenHeader = CurrentHeader
CurrentSection.OddHeader = CurrentHeader
CurrentSection.EvenFooter = CurrentFooter
CurrentSection.OddFooter = CurrentFooter


#8

If you just want the first page don't display header, you need not use so many section. You can use just one section and set the header for subsequent pages only.

If you still want to use many sections, the header for the first section should be different from the subsequent sections. The header for subsequent sections should be set normally but the header for the first section shuold be set with IsSubsequentPagesOnly = "true".


#9

That worked with many sections.

Thanks.