Documentation ¶
Overview ¶
Package pdfrender contains HTML to PDF implementations
Index ¶
Constants ¶
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") // PDF printing triggered only when callback event is received. WaitLifecycleEventCallback = WaitLifecycleEvent("callback") )
Wait Lifecycle events.
const (
DefaultWaitLifecycleEvent = WaitLifecycleEventLoad
)
Default values for RenderConfig.
Variables ¶
var WaitLifecycleEvents = []WaitLifecycleEvent{ WaitLifecycleEventInit, WaitLifecycleEventLoad, WaitLifecycleEventDOMContentLoaded, WaitLifecycleEventFirstPaint, WaitLifecycleEventFirstContentfulPaint, WaitLifecycleEventFirstMeaningfulPaintCandidate, WaitLifecycleEventNetworkAlmostIdle, WaitLifecycleEventFirstMeaningfulPaint, WaitLifecycleEventNetworkIdle, WaitLifecycleEventCallback, }
WaitLifecycleEvents list of allowed WaitLifecycleEvent.
Functions ¶
This section is empty.
Types ¶
type CallbackEvent ¶ added in v0.11.1
type CallbackEvent struct{}
CallbackEvent send from page to internal server.
type CallbackEventChan ¶ added in v0.11.1
type CallbackEventChan chan CallbackEvent
CallbackEventChan is channel for CallbackEvent.
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 TemplateName TemplateName }
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
func (err *InvalidWaitLifecycleEventError) Error() string
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 ¶
RenderPoolStats container stats of render pool.
type WaitLifecycleEvent ¶ added in v0.9.1
type WaitLifecycleEvent string
WaitLifecycleEvent is type for waited LifecycleEvent.
func (WaitLifecycleEvent) IsCallback ¶ added in v0.11.1
func (event WaitLifecycleEvent) IsCallback() bool
IsCallback return true if event is callback.
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.