We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to add margins to the PDF document

How to Add Margin to PDF document


We can add Margin to the PDF document using the Margins property of the PdfDocument page settings.

The following code snippet shows how to add Margin to PDF document


//Create PDF document

PdfDocument doc = new PdfDocument();


//Create Margin Object

PdfMargins margin = new PdfMargins();


//Set All side border

margin.All = 50;


//Set Each side margin value

margin.Bottom = 50; margin.Left = 50; margin.Right = 50; margin.Top = 50;


//Set margin to PDf Page

doc.PageSettings.Margins = margin;


//Add page to Document

PdfPage page = doc.Pages.Add();


//Draw Rectangle

page.Graphics.DrawRectangle(PdfPens.Red, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height));


//Save Pdf document



//Close Document








Sample Link: http://www.syncfusion.com/downloads/support/directtrac/140556/ze/PdfMargin-1384988095

Article ID: Published Date: Last Revised Date: Platform: Control:
5825 11/30/2015 11/30/2015 Windows Forms PDF
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.