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

Free Support Forum - aspose.com

How to control the document ruler?

Hi,I think to control a word document ruler by aspose.word.

Please tell me . Thank you.


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I suppose you need to change page margins. If so, please see the following link to learn how to achieve this:


Best regards.

Thanks, alexey.noskov.

I want to copy ruler of the other document to a new document.

For example:

Document srcDoc = new Document(srcFilePath);

Document newDoc = new Docment();

DocumentBuilder builder = new DocumentBuilder(newDoc);

builder.PageSetup... = srcDoc...

I don't know how to do it.

Thank you.


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can use code like the following to achieve this:

// Open the source document.

Document src = new Document(@"in.doc");

// Open/create the destination document.

Document dst = new Document();

// Get PageSetup of the first sections of the both documents.

PageSetup srcPs = src.FirstSection.PageSetup;

PageSetup dstPs = dst.FirstSection.PageSetup;

// Import page setup from the source document into the destination.

dstPs.LeftMargin = srcPs.LeftMargin;

dstPs.RightMargin = srcPs.RightMargin;

dstPs.TopMargin = srcPs.TopMargin;

dstPs.BottomMargin = srcPs.BottomMargin;

// etc..............

Hope this helps.

Best regards.