director

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package director provides functionality for generating files from HTML using the Rod package. The Director struct contains methods for setting the output format and generating the file.

Example
// starts a new connection and converts the byte array to PNG
fi, _ := NewDirector(internal.PNG).Connect().ConvertHTML([]byte("Example"))
fmt.Printf("File size: %d bytes\n", fi.Filesize)

// saves the file output to "test.png"
filepath := "test.png"
fi.Output(filepath)

// gets file info
info, _ := os.Stat(filepath)
fmt.Printf("New file saved with %d bytes", info.Size())
Output:

File size: 7395 bytes
New file saved with 7395 bytes

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Director

type Director struct {
	// contains filtered or unexported fields
}

Director controls the page conversion methods.

func NewDirector

func NewDirector(ext internal.Ext) *Director

NewDirector opens a new Director instance.

func (*Director) Close

func (d *Director) Close()

Close closes Browser connection.

func (*Director) Connect

func (d *Director) Connect() *Director

Connect starts the Browser connection.

func (*Director) ConvertHTML

func (d *Director) ConvertHTML(html []byte) (*fileinfo.Fileinfo, error)

ConvertHTML converts from a file.

func (*Director) ConvertWebpage

func (d *Director) ConvertWebpage(url string) (*fileinfo.Fileinfo, error)

ConvertWebpage converts from an URL.

func (*Director) SetExt

func (d *Director) SetExt(ext internal.Ext) *Director

SetExt sets the extension to be converted to.

func (*Director) SetFullPage

func (d *Director) SetFullPage(fullPage bool) *Director

SetFullPage sets the pages to be converted. If false, only the first page is selected.

func (*Director) SetLoadTimeout

func (d *Director) SetLoadTimeout(t time.Duration) *Director

SetLoadTimeout controlls max page load time before context is canceled.

func (*Director) SetPageIdleTime

func (d *Director) SetPageIdleTime(t time.Duration) *Director

SetPageIdleTime sets the wait time after the page stops receiving requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL