Hello,
Is there some code we can add to this to center the image ?
public void ImagePlaceHolder_LaidOut( object sender, PlaceHolderLaidOutEventArgs e )
{
string pictureFile = ConfigurationSettings.AppSettings["PathProductpictures"].ToString() + "250\\" + e.LayoutWriter.RecordSets.Current["prodcode"].ToString() + ".jpg";
if (File.Exists(pictureFile)) {
ceTe.DynamicPDF.PageElements.Image picture = new ceTe.DynamicPDF.PageElements.Image(pictureFile,0,0);
picture.SetDpi( 220);
e.ContentArea.Add( picture );
}
}
center a dynamic added image
Re: center a dynamic added image
Support · Sep 27, 2007Hello,
The page elements added in the LaidOut event will be added with respect to the Placeholder's position. The image you are adding will be added in the place of the placeholder.
Do you want to add the image at the center position of the page? If that is the case then you can add the image page element to the page in the center using the X, Y coordinates. X and Y for the image would be the following.
image.X = (page.Dimensions.Body.Width - image.Width)/2;
image.Y = (page.Dimensions.Body.Height - image.Height)/2;
You can access the pages of the report after generating the document object using the Page collection.
Thanks,
ceTe Software Support Team.
Re: center a dynamic added image
Forum member · Sep 27, 2007Hello, no not centered to the page but in the placeholder box ...
Re: center a dynamic added image
Support · Sep 27, 2007Hello,
Yes, you can add the image in the center of the placeholder box without any problem. You will have to specify the X, Y for the image so that it will be placed in the center. Following is the code for the LaidOut event of the placeholder.
private void placeholder1_LaidOut(object sender, PlaceHolderLaidOutEventArgs e)
{
ceTe.DynamicPDF.PageElements.Image image = new ceTe.DynamicPDF.PageElements.Image(@"C:\Temp\logo.tif", 0, 0);
image.X = (e.ContentArea.Width - image.Width)/2;
image.Y = (e.ContentArea.Height - image.Height)/2;
e.ContentArea.Add(image);
}
Thanks,
ceTe Software Support Team.
Re: center a dynamic added image
Forum member · Sep 28, 2007perfect, thanks a lot