Add a Form or Image XObject to the current page.




int AddXObject(Objects.PixMap pm)
int AddXObject(Objects.FormXObject pm)

[Visual Basic]
Function AddXObject(pm As Objects.PixMap) As Integer
Function AddXObject(pm As Objects.FormXObject) As Integer



Name Description
pm The image to be added to the page.
return The Object ID of the newly added Image Object.




Add a Form or Image XObject into the current rectangle on the current page.

Form and Image XObjects represent a drawing sequence external to the main content stream of the page. Image XObjects represent a raster bitmap in one of a variety of color spaces. Form XObjects represent a separate content stream with a separate sequence of drawing commands.

For example a Form XObject might be used to represent a "Draft" stamp which might then be applied on various pages at various locations. The fact that this stamp is an external object allows the viewing application to cache the representation and also allows changes to the stamp to affect the appearance of multiple instances.




This example shows how to load an image into a PixMap and then draw it on the current page using the AddXObject method.

using (Doc doc = new Doc()) {
  doc.Rect.Inset(50, 50);
  doc.Transform.Rotate(20, 200, 200);
  doc.Color.SetRgb(200, 200, 255);
  PixMap pm = new PixMap(doc.ObjectSoup);
  Image img = Image.FromFile("mypic.png");
  pm.SetBitmap(img as Bitmap, true);

[Visual Basic]
Sub ...
  Using doc As New Doc()
    doc.Rect.Inset(50, 50)
    doc.Transform.Rotate(20, 200, 200)
    doc.Color.SetRgb(200, 200, 255)
    Dim pm As New PixMap(doc.ObjectSoup)
    Dim img As Image = Image.FromFile("mypic.png")
    pm.SetBitmap(TryCast(img, Bitmap), True)
  End Using
End Sub