The examples make use of a function named AddImagePage. This function simply creates an appropriate Doc object, adds the image and returns the ImageLayer which was added.
[C#]
private ImageLayer AddImagePage(Doc doc, string path) {
using (XImage img = XImage.FromFile(path, null)) {
doc.MediaBox.SetSides(0, 0, img.Width, img.Height);
doc.Page = doc.AddPage();
doc.Rect.String = doc.MediaBox.String;
int id = doc.AddImageObject(img);
return (ImageLayer)doc.ObjectSoup[id];
}
}
[Visual Basic]
Private Function AddImagePage(doc As Doc, path As String) As ImageLayer
Using img As XImage = XImage.FromFile(path, Nothing)
doc.MediaBox.SetSides(0, 0, img.Width, img.Height)
doc.Page = doc.AddPage()
doc.Rect.[String] = doc.MediaBox.[String]
Dim id As Integer = doc.AddImageObject(img)
Return DirectCast(doc.ObjectSoup(id), ImageLayer)
End Using
End Function
|
|
|