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.

about the image

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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.

thanks
yang



Sample_93536c41.zip

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

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.

http://www.syncfusion.com/support/user/uploads/Sample_23a4b6c3.zip


Regards,
Suba



Wulong Yang
Replied On August 6, 2008 02:43 AM

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 08:57 AM

Hi,

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.

Regards,
Suba


Eric Rosenblum
Replied On September 4, 2014 04:47 PM

 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);

CONFIRMATION

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.

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.

;