Image inclusion

Image inclusion

To include images in your document, a few steps are necessary:

imgfile, err := f.Doc.LoadImageFile("path/to/image.pdf")

to load an image object

type Imagefile struct {
	Format        string
	NumberOfPages int
	PageSizes     map[int]map[string]map[string]float64
	Filename      string
	ScaleX        float64
	ScaleY        float64
	W             int
	H             int
	Box           string
	PageNumber    int
}

You can create an image node from this image object with

imgNode := f.Doc.CreateImageNodeFromImagefile(imgfile, 1, "/MediaBox")

Optionally set the width and the height:

imgNode.Width = width
imgNode.Height = height

Once you have this image node, put it in a vlist node by calling

vl := node.Vpack(imgNode)

and place it on the page with

p.OutputAt(0, bag.MustSP("297mm"), vl)