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