Documentation
¶
Overview ¶
Package html2image provides a simple wrapper around wkhtmltoimage (http://wkhtmltopdf.org/) binary.
Package html2image provides a simple wrapper around wkhtmltoimage (http://wkhtmltopdf.org/) binary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateImage ¶
func GenerateImage(options *ImageOptions) ([]byte, error)
GenerateImage creates an image from an input. It returns the image ([]byte) and any error encountered.
func GeneratePDF ¶ added in v0.1.3
func GeneratePDF(options *ImageOptions) ([]byte, error)
GenerateImage creates an image from an input. It returns the image ([]byte) and any error encountered.
Types ¶
type ImageOptions ¶
type ImageOptions struct {
// BinaryPath the path to your wkhtmltoimage binary. REQUIRED
//
// Must be absolute path e.g /usr/local/bin/wkhtmltoimage
BinaryPath string
// Input is the content to turn into an image. REQUIRED
//
// Can be a url (http://example.com), a local file (/tmp/example.html), or html as a string (send "-" and set the HTML value)
Input string
// Format is the type of image to generate
//
// jpg, png, svg, bmp supported. Defaults to local wkhtmltoimage default
Format string
// Height is the height of the screen used to render in pixels.
//
// Default is calculated from page content. Default 0 (renders entire page top to bottom)
Height int
// Width is the width of the screen used to render in pixels.
//
// Note that this is used only as a guide line. Default 1024
Width int
// Quality determines the final image quality.
//
// Values supported between 1 and 100. Default is 94
Quality int
// Crop-x determines the final image crop from x
CropX int
// Crop-y determines the final image crop from y
CropY int
// Crop-w determines the final image crop width
CropW int
// Crop-h determines the final image crop height
CropH int
// HTML is a string of html to render into and image.
//
// Only needed to be set if Input is set to "-"
HTML string
// Output controls how to save or return the image.
//
// Leave nil to return a []byte of the image. Set to a path (/tmp/example.png) to save as a file.
Output string
// Use this zoom factor (default 1)
Zoom float64
//Smart Width
SmartWidth bool
//to enable caching by default. Set true to Disable Web caching.
DisableWebCache bool
}
ImageOptions represent the options to generate the image.
Click to show internal directories.
Click to hide internal directories.