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

about the image

Thread ID:





75644 Aug 5,2008 12:27 AM UTC Sep 4,2014 08:47 PM UTC ASP.NET Web Forms (Classic) 4
Tags: PDF
Wulong Yang
Asked On August 5, 2008 12:27 AM UTC

about the image

g.DrawImage(image, X, Y,Width,Height);

1.what is the unit for the X,Y,Width,Height. is the pixel, or Millimeter?
2.about the X,Y, is the image's center point, or the left-top point?

3.Because I have set g.DrawImage(image, 0, 0,Width,Height); but the image is not at the paper's top left , it has some margins.(you can see the attached picture) Because our database has record the items position(X,Y). So we need to set item's position based on the left-top point of paper. how can we set this margin to zero.



Administrator [Syncfusion]
Replied On August 6, 2008 05:59 AM UTC

Hi Yang,

Thank you for your interest in Syncfusion PDF.

Here is the answers for your questions,

1)DrawString method measurement

DrawString used to draw the specified text string at the specified location with the specified Brush and Font objects. The configuration for the location parameter is SizeF. Those values are representing float values which representing height and width in pixel.

2)Is X,Y the image''s center point or the left-top point?

The X,Y is the System.Drawing.Point that represents the upper-left corner of the specified boundary region.

3)Setting Margin

PDF generates the document with default margin value. We can set the margin value to zero by using the PageSettings class. Kindly use the below code to set the marging value as zero.

// Setting Margin
doc.PageSettings.Margins.All = 0;

Please look into the sample from the below specified location and let me know if this helps.



Wulong Yang
Replied On August 6, 2008 06:43 AM UTC

hi, there is one thing, because you said the unit is Pixel, mm=Pixel*25.4/DPI, if the PDF page is A4(210mm*297). you can see if we want image at the middle of of the PDF page,
Position X(mm)=105mm, y=0, it change to Pixel
X(Pixel)=105mm*96/25.4=396, Y=0, ( my computer's DPI=96)

when you do that,you will find actually it will not show at the middle, is it a bug?

g.DrawImage(image, 396, 0, image.Width, image.Height);

Sri Subhashini M [Syncfusion]
Replied On August 6, 2008 12:57 PM UTC


Essential PDF generates the document with the size values as 596 and 842. Kindly use the below code to draw the image in the middle of the PDF document,

// Drawing the image
g.DrawImage(image, (page.Size.Width / 4) , (page.Size.Height / 2) - image.Height, image.Width, image.Height);

Please let me know if this helps.


Eric Rosenblum
Replied On September 4, 2014 08:47 PM UTC

 PdfImage image = new PdfBitmap(PathToImage);
                //PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Tahoma", 10f, FontStyle.Bold), false);
                // PdfSolidBrush brush = new PdfSolidBrush(Color.DarkBlue);

                float ftImageWidth;
                float ftImageHeight;
                float ftPageWidth;
                float ftPageHeight;

                float.TryParse(image.Width.ToString(), out ftImageWidth);
                float.TryParse(image.Height.ToString(), out ftImageHeight);
                ftPageWidth = page.Graphics.ClientSize.Width;
                ftPageHeight = page.Graphics.ClientSize.Height;

                float myWidth = image.Width;
                float myHeight = image.Height;
                float shrinkFactor;

                float temp;
                if (myWidth > ftPageWidth)

                    shrinkFactor = myWidth / ftPageWidth;
                    myWidth = ftPageWidth;
                    myHeight = myHeight / shrinkFactor;

                if (myHeight > ftPageHeight)
                    shrinkFactor = myHeight / ftPageHeight;
                    myHeight = ftPageHeight;
                    myWidth = myWidth / shrinkFactor;

                g.DrawImage(image, (ftPageWidth - myWidth)/2, (ftPageHeight - myHeight)/2, myWidth, myHeight);


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