pdfkit

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 20 Imported by: 0

README

pdfkit

Test

Easy PDF printing via the Chrome DevTools Protocol.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("closed")

ErrClosed is returned if the printer has been closed.

View Source
var ErrProcessTimeout = errors.New("process timeout")

ErrProcessTimeout is returned if a job timed out while processing.

View Source
var ErrQueueTimeout = errors.New("queue timeout")

ErrQueueTimeout is returned if a job timed out while queueing.

Functions

This section is empty.

Types

type Config

type Config struct {
	QueueSize   int
	Concurrency int
	ServerPort  int
	Logger      func(interface{})
}

Config defines a printer configuration.

type LogError

type LogError struct {
	Lines []string
}

LogError may be returned if the processing failed due to a page error.

func (*LogError) Error

func (e *LogError) Error() string

type Printer

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

Printer prints web pages as PDFs.

func CreatePrinter

func CreatePrinter(config Config) (*Printer, error)

CreatePrinter will create a new printer.

func (*Printer) Close

func (p *Printer) Close() error

Close will close the printer. It will wait for currently processing jobs to finish and cancels queued but not started jobs.

func (*Printer) PrintFile

func (p *Printer) PrintFile(file []byte, timeout time.Duration, assets map[string][]byte) ([]byte, error)

PrintFile will print the provided file and its assets as a PDF.

func (*Printer) PrintURL

func (p *Printer) PrintURL(url string, timeout time.Duration) ([]byte, error)

PrintURL will print the provided URL as a PDF.

Jump to

Keyboard shortcuts

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