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 ¶
- type Director
- func (d *Director) Close()
- func (d *Director) Connect() *Director
- func (d *Director) ConvertHTML(html []byte) (*fileinfo.Fileinfo, error)
- func (d *Director) ConvertWebpage(url string) (*fileinfo.Fileinfo, error)
- func (d *Director) SetExt(ext internal.Ext) *Director
- func (d *Director) SetFullPage(fullPage bool) *Director
- func (d *Director) SetLoadTimeout(t time.Duration) *Director
- func (d *Director) SetPageIdleTime(t time.Duration) *Director
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 ¶
NewDirector opens a new Director instance.
func (*Director) ConvertHTML ¶
ConvertHTML converts from a file.
func (*Director) ConvertWebpage ¶
ConvertWebpage converts from an URL.
func (*Director) SetFullPage ¶
SetFullPage sets the pages to be converted. If false, only the first page is selected.
func (*Director) SetLoadTimeout ¶
SetLoadTimeout controlls max page load time before context is canceled.
Click to show internal directories.
Click to hide internal directories.