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

Free Support Forum - aspose.com

Different header distances for different pages

Hi,

I am trying to edit word documents and in the process need to setup different header distances for the first page and a different header distance for the rest of the pages.
Using the code snippet below:-1:
A.Document doc = new A.Document(inputFileName);
A.DocumentBuilder builder = new A.DocumentBuilder(doc);
//Setup the currect section.
A.Section currentSection = builder.CurrentSection;
A.PageSetup pageSetup = currentSection.PageSetup;
// Different headers/footers for first and the rest of the pages.
pageSetup.DifferentFirstPageHeaderFooter = true;
// — Create header for the first page.
//Setup the header
header = printTemplateInformation.Graphics.Where(x => x.TemplateGraphics.GraphicsType.GraphicsType == “Header”).FirstOrDefault();

            if (header != null)
            {
                //Set the header distance as the summation of the page top and header height
                //pageSetup.HeaderDistance = Convert.ToDouble(header.Height + header.TemplateGraphics.PositionTop).ToPoints();
                builder.MoveToHeaderFooter(A.HeaderFooterType.HeaderFirst);
                builder.InsertImage(header.Path, AD.RelativeHorizontalPosition.Page, header.TemplateGraphics.PositionLeft.ToPoints(), AD.RelativeVerticalPosition.Page,header.TemplateGraphics.PositionTop.ToPoints(), -1, -1, AD.WrapType.None);

            }

However I need this header distance for the first page only and I would like to setup a different header distance for the other pages.

If I use builder.MoveToHeaderFooter(A.HeaderFooterType.HeaderPrimary) and set the header distance after the code above for the rest of the pages, event the first page’s header distance gets altered. Could you please help out please?

@MetLifeUK,

Please attach your input and expected Word documents here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document by using Microsoft Word. We will then provide you code to achieve the same by using Aspose.Words. Thanks for your cooperation.

Best regards,