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

Free Support Forum - aspose.com

Start to the left and end to the right margins in document using aspose.words?

how to make margins start to the left and end to the right ..see margins screen shot once...

iam getting space in starting of the every page and content is not aligned ?pls check my code and below screen shot with space in start of the page and not aligned once..... pls helpme out...

if (oCurrentDoc.ChildNodes.Count > 0)

{

oCurrentDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;

// Iterate through all paragraphs in the source document to avoid the staying paragraphs together.

foreach (Paragraph para in oCurrentDoc.GetChildNodes(NodeType.Paragraph, true))

{

if (!bHasHeader)

{

if (para.GetAncestor(NodeType.HeaderFooter) != null)

bHasHeader = true;

}

para.ParagraphFormat.KeepWithNext = false;

}

oCurrentDoc.FirstSection.HeadersFooters.LinkToPrevious(false);

oCurrentDoc.FirstSection.PageSetup.PageWidth = oDestDoc.LastSection.PageSetup.PageWidth;

oCurrentDoc.FirstSection.PageSetup.PageHeight = oDestDoc.LastSection.PageSetup.PageHeight;

oCurrentDoc.FirstSection.PageSetup.Orientation = oDestDoc.LastSection.PageSetup.Orientation;

Aspose.Words.DocumentBuilder oDocBuilder;

try

{

oDocBuilder = new Aspose.Words.DocumentBuilder(oDocument);

Aspose.Words.PageSetup oPageSetup = oDocBuilder.PageSetup;

oPageSetup.TopMargin = ConvertUtil.InchToPoint(0.5);

oPageSetup.BottomMargin = ConvertUtil.InchToPoint(0.5);

oPageSetup.LeftMargin = ConvertUtil.InchToPoint(0.5);

oPageSetup.RightMargin = ConvertUtil.InchToPoint(0.5);

if (bHasHeader)

{

oPageSetup.HeaderDistance = ConvertUtil.InchToPoint(1.0);

oPageSetup.FooterDistance = ConvertUtil.InchToPoint(1.0);

}

else

{

oPageSetup.HeaderDistance = ConvertUtil.InchToPoint(0.8);

oPageSetup.FooterDistance = ConvertUtil.InchToPoint(0.8);

}

oDestDoc.AppendDocument(oCurrentDoc, ImportFormatMode.KeepSourceFormatting);

}

Hi

Thanks for your request. But could you please attach the expected output MS Word document. It is difficult to say something with screenshot. We will check your expected output and provide you more information.

Best regards,