Ahmed Shair
Ahmed Shair

Reputation: 99

How can we set page margins for word document using aspose.words in .Net

I'm using Aspose.Words in .Net and I need to set page margins from each side, page orientation and header footer distance using Aspose.Words?

Upvotes: 1

Views: 2047

Answers (1)

Zeeshan Mahboob
Zeeshan Mahboob

Reputation: 194

You can set page margins for Word document in different ways. But below is the easiest way to do this:

            Document() doc = new Document();

            DocumentBuilder(doc) builder = new DocumentBuilder(doc)
            {
                PageSetup =
                {
                    Orientation = Word.Orientation.Portrait,
                    PaperSize = Word.PaperSize.Letter,
                    LeftMargin = 72.0,
                    RightMargin = 72.0,
                    TopMargin = 72.0,
                    BottomMargin = 72.0
                },

            };

Upvotes: 3

Related Questions