Adds an image to the current page.

 

   

Syntax
 

[C#]
virtual int AddImageObject(XImage image)
virtual int AddImageObject(XImage image, bool transparent)

[Visual Basic]
Overridable Function AddImageObject(image As XImage) As Integer
Overridable Function AddImageObject(image As XImage, transparent As Boolean) As Integer

Throws Exceptions may throw Exception()

 

   

Params
 
Name Description
image

An XImage containing the image to be added to the page.

transparent

Whether transparency information should be preserved. This parameter overrides the PreserveTransparency property of the XReadOptions used to create the XImage. If this parameter is not specified and the XImage has been created without a XReadOptions, this parameter is defaulted to false.

return The ID of the newly added Image Object. If the image is added as multiple objects, such as if it has been created with an XReadOptions with ReadModule of SwfVector (with a non-null Operation), Xps, or XpsAny, the ID is zero. If XReadOptions.Operation has been null, the temporary SwfImportOperation allows this method to return the ID of the GraphicLayer for the frame of XReadOptions.Frame.

 

   

Notes
 

If the XImage has been created with an XReadOptions with ReadModule that uses an Operation, the operation will be invoked and the result depends on the operation. Otherwise, this method gets an image from the Image object and adds it to the current page returning the ID of the newly added object.

Adds the Selection of the current Frame returning the ID of the newly added object.

Images embedded using this method are always inserted using indirect mode. Indirect mode is not as fast as pass-through mode. However it allows greater flexibility and the use of many different image formats.

If the Transparent parameter is set to true then any transparency information will be preserved. This allows you to add formats such as transparent GIF, PNG with alpha channel, or images with masks set using the Image.SetMask method.

The image is scaled to fill the current Rect. It is transformed using the current Transform.

If the width or height of the current rectangle is zero the image is auto-sized. If you are working in TopDown mode the image is positioned with its top left pinned at the location indicated by the rectangle. If you are not in TopDown mode the bottom left of the image is pinned at the location indicated by the rectangle. In both cases the natural dimensions of the supplied image are used to determine the displayed width and height resulting in a 72 dpi output.

 

   

Example
 

The following code adds a transparent GIF against a gray background.

[C#]
XImage theImg = new XImage();
theImg.SetFile(Server.MapPath("../mypics/mypic.gif"));
Doc theDoc = new Doc();
theDoc.Color.String = "200 200 200";
theDoc.FillRect();
theDoc.Rect.String = "0 0 0 0";
theDoc.AddImageObject(theImg, true);
theImg.Clear();
theDoc.Save(Server.MapPath("docaddimageobject.pdf"));
theDoc.Clear();

[Visual Basic]
Dim theImg As XImage = New XImage()
theImg.SetFile(Server.MapPath("../mypics/mypic.gif"))
Dim theDoc As Doc = New Doc()
theDoc.Color.String = "200 200 200"
theDoc.FillRect()
theDoc.Rect.String = "0 0 0 0"
theDoc.AddImageObject(theImg, True)
theImg.Clear()
theDoc.Save(Server.MapPath("docaddimageobject.pdf"))
theDoc.Clear()


docaddimageobject.pdf