ErrContentNotDefined is an error returned when the HTML document content is not defined.
var ErrContentNotDefined = errors.New("html document content not defined")
ErrNoClient is the error used when the client is not defined.
var ErrNoClient = errors.New("UniHTML client not found")
func Connect(path string) error
Connect creates UniHTML HTTP Client and tries to establish connection with the server.
func ConnectOptions(o Options) error
ConnectOptions creates UniHTML HTTP Client and tries to establish connection with the server.
Document is HTML document wrapper that is used for extracting and converting HTML document into PDF pages.
type Document struct {
// contains filtered or unexported fields
}
func NewDocument(path string) (*Document, error)
NewDocument creates new HTML Document used as an input for the creator.Drawable.
func NewDocumentFromString(html string) (*Document, error)
NewDocumentFromString creates a new Document from the provided HTML string.
func (d *Document) ContainerComponent(container creator.Drawable) (creator.Drawable, error)
ContainerComponent implements creator.containerElement interface.
func (d *Document) GeneratePageBlocks(ctx creator.DrawContext) ([]*creator.Block, creator.DrawContext, error)
GeneratePageBlocks implements creator.Drawable interface.
func (d *Document) GetContent() content.Content
GetContent returns the content of the document.
func (d *Document) GetPdfPages(ctx context.Context) ([]*model.PdfPage, error)
GetPdfPages is a function that converts provided input content and
func (d *Document) SetLandscapeOrientation()
SetLandscapeOrientation sets document landscape page orientation.
func (d *Document) SetMarginBottom(margin sizes.Length)
SetMarginBottom sets the left margin.
func (d *Document) SetMarginLeft(margin sizes.Length)
SetMarginLeft sets the left margin.
func (d *Document) SetMarginRight(margin sizes.Length)
SetMarginRight sets the left margin.
func (d *Document) SetMarginTop(margin sizes.Length)
SetMarginTop sets the left margin.
func (d *Document) SetMargins(left, right, top, bottom float64)
SetMargins sets the Document Margins.
func (d *Document) SetPageHeight(pageHeight sizes.Length) error
SetPageHeight sets the page height for given document.
func (d *Document) SetPageSize(pageSize sizes.PageSize) error
SetPageSize sets the page default size.
func (d *Document) SetPageWidth(pageWidth sizes.Length) error
SetPageWidth sets the page width for given document.
func (d *Document) SetPos(x, y float64)
SetPos sets the absolute position. Changes object positioning to absolute.
func (d *Document) SetTimeoutDuration(duration time.Duration)
SetTimeoutDuration sets the timeout duration the default timeout is 15 seconds.
func (d *Document) TrimLastPageContent()
TrimLastPageContent trims the last page content so that next creator blocks are located just at the end of given block.
func (d *Document) WaitReady(sel string, by ...selector.ByType)
WaitReady waits for the provided selector to be ready. A selector might be i.e. `#example` for id and `.example` for classes. The second parameter defines how to match given selector.
func (d *Document) WaitTime(duration time.Duration)
WaitTime sets the waiting time before the webpage is rendered to PDF.
func (d *Document) WaitVisible(sel string, by ...selector.ByType)
WaitVisible waits for the provided selector to be ready. A selector might be i.e. `#example` for id and `.example` for classes. The second parameter defines how to match given selector.
func (d *Document) WriteToFile(outputPath string) error
WriteToFile writes the document to a file defined by the output path.
Options are the HTML Client options used for establishing the connection.
type Options struct { // Hostname defines the hostname for the client. Default value: 'localhost'. Hostname string // Port defines the port at which the server works. Default value: '8080' Port int // Secure is the flag that states if the connection uses HTTPS protocol. Default Value: 'false'. Secure bool // Prefix is an option setting used when the server is working with the URI prefix. Default Value: ''. Prefix string }
Name | Synopsis |
---|---|
.. | |
cli | |
cmd | |
client | Package client contains HTML Converter HTTP Client. |
common | Package common contains common properties used by the subpackages. |
content | |
examples | Package examples contains different usage of the UniHTML. |
directory | |
graph | |
links | |
margins-and-properties | |
resume | |
simple | |
weburl | |
selector | |
server | |
cmd | |
common | Package common contains commonly used server abstractions. |
handlers | |
private | |
public | |
middlewares | |
server | |
sizes | Package sizes defines basic types that determines the size units i.e. |
unihtml | Package unihtml contains a plugin for the UniDoc. |
cli | |
cmd | |
client | Package client contains HTML Converter HTTP Client. |
common | Package common contains common properties used by the subpackages. |
content | |
selector | |
sizes | Package sizes defines basic types that determines the size units i.e. |