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.

Center image on the page

Thread ID:

Created:

Updated:

Platform:

Replies:

89455 Aug 25,2009 06:27 AM Aug 26,2009 04:26 AM ASP.NET Web Forms (Classic) 1
loading
Tags: PDF
pegaso
Asked On August 25, 2009 06:27 AM

Hi,
i would like center a lot of images in the page. I've try this code:

foreach (...
{

x = ((doc.Pages[doc.Pages.Count - 1].Graphics.ClientSize.Width) - Img.Width) / 2;

PointF location = new PointF(_x, _lastLineY + 20);
SizeF size = new SizeF(Img.Width, Img.Height);
RectangleF rect = new RectangleF(location, size);
Img.Draw(doc.Pages[doc.Pages.Count - 1], rect);

}

but only first image is centered, the others images shifts on the left... why?

Thank you.

Sri Subhashini M [Syncfusion]
Replied On August 26, 2009 04:26 AM

Hi Pegaso,

Thank you for your interest in Essential PDF.

Drawing image in center of the PDF document

I was able to reproduce the issue which you mentioned here. Kindly refer the modified code snippet,


PdfImage Img = PdfBitmap.FromFile(images[i]);
x = (doc.Pages[i].Graphics.ClientSize.Width) / 2;
float imgw = Img.Width / 2 ;
PointF location = new PointF(x - imgw, _lastLineY + 20);
SizeF size = new SizeF(Img.Width, Img.Height);
RectangleF rect = new RectangleF(location, size);
doc.Pages[i].Graphics.DrawImage(Img, rect);


Please do find the sample from the below specified location and let me know if this helps,

http://files.syncfusion.com/samples/PDF.Windows/PDF_Window_F89455.zip

Regards,
Suba

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.

;