I need to include an image from a SharePoint 2010 document library. I have the url of the image. I've tried many different things to no avail, I thought it would be simple like the below snipet:
Image image = new Image(Server.MapPath(imageUrl), 0, 115)
But no. Any ideas?
Display image from a URL
Re: Display image from a URL
Support · Nov 27, 2012Hello,
Yes, it is not possible to use url as argument in the Image class constructor. You can achieve your requirements by using the WebClient class and retrieve the image in the form of byte array using the url. Once you get the byte array then you can use this to build ImageData object and then use this ImageData object to build Image object. Below is the sample code for it.
//Create WebClient class object.
WebClient webClientObj = new WebClient();
//Get the imagedata using DownloadData method of the WebClient class by passing the url.
byte[] byteData=webClientObj.DownloadData(url);
//Build ImageData object by passing the retrived image which in in the form of byte array.
ImageData imageDataObj=ImageData.GetImage(byteData);
//Pass the imageData to Image class contructor
Image image = new Image(imageDataObj, 0, 0);
Thanks,
ceTe Software Support Team.
Re: Display image from a URL
Forum member · Nov 27, 2012Thanks!
Re: Display image from a URL
Forum member · Dec 15, 2012How to display image in table row from url ?
Re: Display image from a URL
Forum member · Dec 15, 2012How to display image in table row from url and Current path ?
Re: Display image from a URL
Support · Dec 17, 2012Hello,
You can add image to the cell of the Table2 without any problem using our DynamicPDF product. If you are getting the image from url then you can use the above posted code which uses WebClient class to load the image and build the Image page element and then add this Image object to the cell of the Table2. Please refer documentation on adding page elements to the Table2 page element here
.
If you are using file path of the image to load then you can use overloaded Image class constructor which takes file path as argument and then add this Image object to the cell of the Table2. Please refer documentation on Image class here
.
Thanks,
ceTe Software Support Team.