Doc AddXObject Function. Add a Form or Image XObject to the current page. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

Add a Form or Image XObject to the current page.

 

   
Syntax  

[C#]
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

 

   

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

 

   

Notes
 

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.

 

   

Example
 

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

[C#]
using (Doc doc = new Doc()) {
  doc.Rect.Inset(50, 50);
  doc.Transform.Rotate(20, 200, 200);
  doc.Color.SetRgb(200, 200, 255);
  doc.FillRect();
  PixMap pm = new PixMap(doc.ObjectSoup);
  Image img = Image.FromFile("mypic.png");
  pm.SetBitmap(img as Bitmap, true);
  doc.AddXObject(pm);
  doc.Save("examplePixMapBitmap.pdf");
}

[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)
    doc.FillRect()
    Dim pm As New PixMap(doc.ObjectSoup)
    Dim img As Image = Image.FromFile("mypic.png")
    pm.SetBitmap(TryCast(img, Bitmap), True)
    doc.AddXObject(pm)
    doc.Save("examplePixMapBitmap.pdf")
  End Using
End Sub


examplePixMapBitmap.pdf