XImage SetData Function. Load an image from data. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

Load an image from data.

 

   
Syntax  

[C#]
void SetData(byte[] data)

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

Throws Exceptions may throw Exception()

 

   

Params
 
Name Description
data The data containing the graphic.

 

   

Notes
 

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

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

 

   

Example
 

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.

[C#]
XImage theImg = new XImage();
Doc theDoc = new Doc();
// read the data from a file
string thePath = Server.MapPath("../mypics/mypic.tif");
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);
theDoc.Rect.Inset(20, 20);
theDoc.AddImageObject(theImg, false);
theImg.Clear();
theDoc.Save(Server.MapPath("imagesetdata.pdf"));
theDoc.Clear();

[Visual Basic]
Dim theImg As XImage = New XImage()
Dim theDoc As Doc = New Doc()
' read the data from a file
Dim thePath As String = Server.MapPath("../mypics/mypic.tif")
Dim theStream As FileStream = File.OpenRead(thePath)
Dim theData(theStream.Length) As Byte
theStream.Read(theData, 0, CType(theStream.Length, Integer))
theStream.Close()
' place the data into the image
theImg.SetData(theData)
theDoc.Rect.Inset(20, 20)
theDoc.AddImageObject(theImg, False)
theImg.Clear()
theDoc.Save(Server.MapPath("imagesetdata.pdf"))
theDoc.Clear()


imagesetfile.pdf