Skip to content

shezadkhan137/go-wkhtmltoimage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-wkhtmltoimage

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

Installation

go get github.com/shezadkhan137/go-wkhtmltoimage

Usage

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

License

This project is licensed under the MIT license. See LICENSE for more details.

About

Go wrapper around wkhtmltoimage C bindings

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages