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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

page margin

Thread ID:





88903 Aug 14,2009 09:15 AM UTC Aug 14,2009 11:05 AM UTC ASP.NET Web Forms (Classic) 1
Tags: PDF
Asked On August 14, 2009 09:15 AM UTC

How I can set the page margin?

Thank you.

Sri Subhashini M [Syncfusion]
Replied On August 14, 2009 11:05 AM UTC

Hi Pegaso,

Thank you for your interest in Essential PDF.

Setting Margin to PDF document

We can set margin to PDF document not to the PDF pages with the help of the Margins class. Kindly refer the below code snippet which demonstrates setting margin values,

//Create a new document.
PdfDocument doc = new PdfDocument();
// Set margin
doc.PageSettings.Margins.Bottom = 2f;
doc.PageSettings.Margins.Right = 3f;
//Add a page
PdfPage page = doc.Pages.Add();
//Create Pdf graphics for the page
PdfGraphics g = page.Graphics;
//Create a solid brush
PdfBrush brush = new PdfSolidBrush(Color.Black);
float fontSize = 20f;
//Set the font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, fontSize);
//Draw the text
g.DrawString("Hello world!", font, brush,new PointF(20,20));

Please try the above code snippet and let me know if you need any information.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon