I am trying to find out if there is any possibility to have the left margin different between the header/footer and the rest of the page (body).
What I would like to achieve is to have the header and footer starting from 0 (left margin) but that the body of the page has the Left Margin of 3.
Currently in the header I have a table.
Any help is welcome.
Thanks for your request. You can try to use ParagraphFormat.LeftIdent property. See the following example.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Section currentSection = builder.CurrentSection;
PageSetup pageSetup = currentSection.PageSetup;
pageSetup.DifferentFirstPageHeaderFooter = true;
// --- Create header for the first page. ---
pageSetup.HeaderDistance = 20;
pageSetup.LeftMargin = 30;
//set leftident for header.
builder.ParagraphFormat.LeftIndent = -30;
builder.Write("Aspose.Words Header/Footer Creation Primer - Title Page.");
builder.Write("Text in body");
// Save the resulting document.
I hope that it will help you.
Thank you for your fast answer.
Indeed we figured out that the only possibility we have is to work with the “LeftIndent” in order to obtain the requested result.
It would be very nice anyway, to have the direct formatting of the footer/header in the way that all the nested object would inherit those settings.
and for the footer
Thank you for you post.
I think that you can’t set different margins for header/footer and for body in MSWord. That’s why you can’t do this using Aspose.Words.
if it is possible, I want
and for the footer
if their any other solution is available to resolve the above cases.
Hi @SV-555 ,
is this any solution available for that above one?!..
I need to give the Margin(left,right,top,bottom) for Header and Footer if any other solution you have?
Thanks for your inquiry. Please use the properties LeftMargin, TopMargin, RightMargin, BottomMargin of PageSetup class as shown below to achieve your requirement. Hope this helps you.
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); PageSetup ps = builder.PageSetup; ps.TopMargin = ConvertUtil.InchToPoint(1.0); ps.BottomMargin = ConvertUtil.InchToPoint(1.0); ps.LeftMargin = ConvertUtil.InchToPoint(1.5); ps.RightMargin = ConvertUtil.InchToPoint(1.5); ps.HeaderDistance = ConvertUtil.InchToPoint(0.2); ps.FooterDistance = ConvertUtil.InchToPoint(0.2);
Thanks, it will applicable for a Page body alone. I want the Left Margin,Right Margin,Top Margin,Bottom Margin for the Headers and Footers.
Thanks in advance
Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. MS Word sets the page margins for page’s body and page header and footer.
In your case, we suggest you please insert the table with one cell, without border and have width 80% of page into header and footer. Insert the content into table.
If you still face problem, please ZIP and attach your input and expected output documents. We will then provide you more information about your query.