pdfrender

package
v0.10.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pdfrender contains HTML to PDF implementations

Index

Constants

View Source
const (
	WaitLifecycleEventInit                 = WaitLifecycleEvent("init")
	WaitLifecycleEventLoad                 = WaitLifecycleEvent("load")
	WaitLifecycleEventDOMContentLoaded     = WaitLifecycleEvent("DOMContentLoaded")
	WaitLifecycleEventFirstPaint           = WaitLifecycleEvent("firstPaint")
	WaitLifecycleEventFirstContentfulPaint = WaitLifecycleEvent("firstContentfulPaint")

	WaitLifecycleEventFirstMeaningfulPaintCandidate = WaitLifecycleEvent(
		"firstMeaningfulPaintCandidate",
	)

	WaitLifecycleEventNetworkAlmostIdle    = WaitLifecycleEvent("networkAlmostIdle")
	WaitLifecycleEventFirstMeaningfulPaint = WaitLifecycleEvent("firstMeaningfulPaint")
	WaitLifecycleEventNetworkIdle          = WaitLifecycleEvent("networkIdle")
)

Wait Lifecycle events.

View Source
const (
	DefaultWaitLifecycleEvent = WaitLifecycleEventLoad
)

Default values for RenderConfig.

Variables

WaitLifecycleEvents list of allowed WaitLifecycleEvent.

Functions

This section is empty.

Types

type Assets added in v0.9.1

type Assets interface {
	Open(name string) (io.Reader, error)
}

Assets interface.

type Config

type Config struct {
	Landscape          *bool
	PrintBackground    *bool
	Scale              *float64
	PaperWidth         *float64
	PaperHeight        *float64
	MarginTop          *float64
	MarginBottom       *float64
	MarginLeft         *float64
	MarginRight        *float64
	PreferCSSPageSize  *bool
	WaitLifecycleEvent *WaitLifecycleEvent
}

Config is print config.

type Document

type Document struct {
	BodyHTML     string
	HeaderHTML   *string
	FooterHTML   *string
	TemplateName TemplateName
	Assets       Assets
}

Document wrap HTML with template metadata.

type InvalidWaitLifecycleEventError added in v0.9.1

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

InvalidWaitLifecycleEventError returned when provided unexpected event type.

func NewInvalidWaitLifecycleEventError added in v0.9.1

func NewInvalidWaitLifecycleEventError(eventType string) *InvalidWaitLifecycleEventError

NewInvalidWaitLifecycleEventError construct new InvalidWaitLifecycleEventError.

func (*InvalidWaitLifecycleEventError) Error added in v0.9.1

type PDFRenderer

type PDFRenderer interface {
	RenderPDF(
		ctx context.Context,
		config *Config,
		document Document,
	) (
		[]byte,
		error,
	)
	Info(context.Context) (*RenderInfo, error)
}

PDFRenderer interface.

type RenderInfo

type RenderInfo struct {
	Pool     RenderPoolInfo
	Metadata map[string]string
}

RenderInfo contains pool info and metadata.

type RenderPoolInfo

type RenderPoolInfo struct {
	Stats RenderPoolStats
	Type  string
}

RenderPoolInfo contains stats and type.

type RenderPoolStats

type RenderPoolStats struct {
	Active      int
	Idle        int
	Destroyed   int
	Invalidated int
}

RenderPoolStats container stats of render pool.

type TemplateName

type TemplateName string

TemplateName type.

type WaitLifecycleEvent added in v0.9.1

type WaitLifecycleEvent string

WaitLifecycleEvent is type for waited LifecycleEvent.

func (*WaitLifecycleEvent) Set added in v0.9.1

func (event *WaitLifecycleEvent) Set(value string) error

Set value. On not valid value return InvalidWaitLifecycleEventError.

func (*WaitLifecycleEvent) String added in v0.9.1

func (event *WaitLifecycleEvent) String() string

String return event value.

func (*WaitLifecycleEvent) UnmarshalJSON added in v0.9.1

func (event *WaitLifecycleEvent) UnmarshalJSON(value []byte) error

UnmarshalJSON unmarshal json.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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