Document Margins

Jan 20, 2011 at 7:51 PM

I searched the discussions and didn't find anything regarding how I can set the document margins so that they're .5" instead of 1"

Is it because the function doesn't exist or am I overlooking something?

Any help would be greatly appreciated!



Andrew Tatum

Oct 5, 2011 at 9:09 PM

I'll second that motion!  Any way to change the margins?

Apr 10, 2013 at 10:54 AM
Is there any solution for this problem ??
Dec 14, 2013 at 12:19 PM
In C#

Just keep in mind - the property is a float property so requires an F suffix.

doc = DocX.Create(fileName);
        // Create a float var that contains doc Margins properties.
        float leftMargin = doc.MarginLeft;
        float rightMargin = doc.MarginRight;
        // Modify using your own vars.
        leftMargin = 25F;
        rightMargin = 25F

        // Or simply work the margins by setting the property directly. 
        doc.MarginLeft = 50F;
        doc.MarginRight = 25F;
        doc.MarginTop = 25F;
        doc.MarginBottom = 25F; 

Marked as answer by MadBoy on 12/22/2013 at 5:45 AM
Dec 14, 2013 at 12:20 PM
I should mention what you are refering to as .5 I believe is 5.0 in this usage.
Dec 22, 2013 at 12:45 PM
Thanks Mark. I've added your example into Examples source codes for easy access.