Implements wkhtmltoimage Go bindings. It can be used to convert HTML documents to images. The package does not use the wkhtmltoimage binary. Instead, it uses the wkhtmltox library directly.
Full documentation can be found at: https://godoc.org/github.com/shezadkhan137/go-wkhtmltoimage
Inspiration and some code taken from https://github.com/adrg/go-wkhtmltopdf
go get github.com/shezadkhan137/go-wkhtmltoimage
package main
import (
"log"
"os"
wk "github.com/shezadkhan137/go-wkhtmltoimage"
)
func main() {
wk.Init()
defer wk.Destroy()
converter, err := wk.NewConverter(
&wk.Config{
Quality: 100,
Fmt: "png",
EnableJavascript: false,
})
if err != nil {
log.Fatal(err)
}
testString := "<html><body><p>This is some html</p></body></html>"
outFile, err := os.Create("testme.png")
if err != nil {
log.Fatal(err)
}
defer outFile.Close()
err = converter.Run(testString, outFile)
if err != nil {
log.Fatal(err)
}
}
See libwkhtmltox for settings and documentation
This project is licensed under the MIT license. See LICENSE for more details.