HomeUniDoc
...

Package unihtml

Overview ▾

Package unihtml contains a plugin for the UniDoc.

Index ▾

Variables
func Connect(path string) error
func ConnectOptions(o Options) error
type Document
    func NewDocument(path string) (*Document, error)
    func NewDocumentFromString(html string) (*Document, error)
    func (d *Document) ContainerComponent(container creator.Drawable) (creator.Drawable, error)
    func (d *Document) GeneratePageBlocks(ctx creator.DrawContext) ([]*creator.Block, creator.DrawContext, error)
    func (d *Document) GetContent() content.Content
    func (d *Document) GetPdfPages(ctx context.Context) ([]*model.PdfPage, error)
    func (d *Document) SetLandscapeOrientation()
    func (d *Document) SetMarginBottom(margin sizes.Length)
    func (d *Document) SetMarginLeft(margin sizes.Length)
    func (d *Document) SetMarginRight(margin sizes.Length)
    func (d *Document) SetMarginTop(margin sizes.Length)
    func (d *Document) SetMargins(left, right, top, bottom float64)
    func (d *Document) SetPageHeight(pageHeight sizes.Length) error
    func (d *Document) SetPageSize(pageSize sizes.PageSize) error
    func (d *Document) SetPageWidth(pageWidth sizes.Length) error
    func (d *Document) SetPos(x, y float64)
    func (d *Document) SetTimeoutDuration(duration time.Duration)
    func (d *Document) TrimLastPageContent()
    func (d *Document) WaitReady(sel string, by ...selector.ByType)
    func (d *Document) WaitTime(duration time.Duration)
    func (d *Document) WaitVisible(sel string, by ...selector.ByType)
    func (d *Document) WriteToFile(outputPath string) error
type Options

Package files

client.go doc.go document.go

Variables

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

func Connect(path string) error

Connect creates UniHTML HTTP Client and tries to establish connection with the server.

func ConnectOptions

func ConnectOptions(o Options) error

ConnectOptions creates UniHTML HTTP Client and tries to establish connection with the server.

type Document

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

func NewDocument(path string) (*Document, error)

NewDocument creates new HTML Document used as an input for the creator.Drawable.

func NewDocumentFromString

func NewDocumentFromString(html string) (*Document, error)

NewDocumentFromString creates a new Document from the provided HTML string.

func (*Document) ContainerComponent

func (d *Document) ContainerComponent(container creator.Drawable) (creator.Drawable, error)

ContainerComponent implements creator.containerElement interface.

func (*Document) GeneratePageBlocks

func (d *Document) GeneratePageBlocks(ctx creator.DrawContext) ([]*creator.Block, creator.DrawContext, error)

GeneratePageBlocks implements creator.Drawable interface.

func (*Document) GetContent

func (d *Document) GetContent() content.Content

GetContent returns the content of the document.

func (*Document) GetPdfPages

func (d *Document) GetPdfPages(ctx context.Context) ([]*model.PdfPage, error)

GetPdfPages is a function that converts provided input content and

func (*Document) SetLandscapeOrientation

func (d *Document) SetLandscapeOrientation()

SetLandscapeOrientation sets document landscape page orientation.

func (*Document) SetMarginBottom

func (d *Document) SetMarginBottom(margin sizes.Length)

SetMarginBottom sets the left margin.

func (*Document) SetMarginLeft

func (d *Document) SetMarginLeft(margin sizes.Length)

SetMarginLeft sets the left margin.

func (*Document) SetMarginRight

func (d *Document) SetMarginRight(margin sizes.Length)

SetMarginRight sets the left margin.

func (*Document) SetMarginTop

func (d *Document) SetMarginTop(margin sizes.Length)

SetMarginTop sets the left margin.

func (*Document) SetMargins

func (d *Document) SetMargins(left, right, top, bottom float64)

SetMargins sets the Document Margins.

func (*Document) SetPageHeight

func (d *Document) SetPageHeight(pageHeight sizes.Length) error

SetPageHeight sets the page height for given document.

func (*Document) SetPageSize

func (d *Document) SetPageSize(pageSize sizes.PageSize) error

SetPageSize sets the page default size.

func (*Document) SetPageWidth

func (d *Document) SetPageWidth(pageWidth sizes.Length) error

SetPageWidth sets the page width for given document.

func (*Document) SetPos

func (d *Document) SetPos(x, y float64)

SetPos sets the absolute position. Changes object positioning to absolute.

func (*Document) SetTimeoutDuration

func (d *Document) SetTimeoutDuration(duration time.Duration)

SetTimeoutDuration sets the timeout duration the default timeout is 15 seconds.

func (*Document) TrimLastPageContent

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 (*Document) WaitReady

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 (*Document) WaitTime

func (d *Document) WaitTime(duration time.Duration)

WaitTime sets the waiting time before the webpage is rendered to PDF.

func (*Document) WaitVisible

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 (*Document) WriteToFile

func (d *Document) WriteToFile(outputPath string) error

WriteToFile writes the document to a file defined by the output path.

type Options

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
}

Subdirectories

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.