Load an image from data.




void SetData(byte[] data)

[Visual Basic]
Sub SetData(data() As Byte)

Throws Exceptions may throw Exception()



Name Description
data The data containing the graphic.




Load an image from data. The data is expected to be provided as an array of bytes.

The data can be any of the following types: JPEG, GIF, TIFF, BMP, PNG, PSD, PDB, EXIF, WMF, EMF, EPS, PS or SWF (Flash).

Ultimately each import goes through a ReadModule so for details of additional formats supported and the way they are imported, see the ReadModule property.

Different images within the file can be accessed using the Frame property. Different portions of the image can be selected using the Selection property.




Here we read a TIFF file and present the data to the XImage object. We then add the image to our document and then save the PDF.


XImage theImg = new XImage(); Doc doc = new Doc(); // read the data from a file string thePath = Server.MapPath("../mypics/mypic.jpg"); FileStream theStream = File.OpenRead(thePath); byte[] theData = new byte[theStream.Length]; theStream.Read(theData, 0, (int)theStream.Length); theStream.Close(); // place the data into the image theImg.SetData(theData); doc.Rect.Inset(20, 20); doc.AddImageObject(theImg, false); theImg.Clear(); doc.Save(Server.MapPath("imagesetdata.pdf")); doc.Clear();