exportpdf

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 17 Imported by: 1

Documentation

Overview

Package exportpdf provides server-side PDF rendering adapters for go-export.

It renders HTML templates via an injected HTML renderer and converts them to PDFs using a pluggable engine (wkhtmltopdf or Chromium via chromedp). Rendering is gated by Renderer.Enabled.

Index

Constants

View Source
const DefaultMaxHTMLBytes int64 = 8 * 1024 * 1024

DefaultMaxHTMLBytes guards in-memory HTML buffering before PDF conversion.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChromiumEngine

type ChromiumEngine struct {
	BrowserPath string
	Headless    bool
	Timeout     time.Duration
	Args        []string

	DefaultPDF export.PDFOptions
	// contains filtered or unexported fields
}

ChromiumEngine renders PDF output using a shared headless Chromium instance.

func (*ChromiumEngine) Close

func (e *ChromiumEngine) Close() error

Close releases Chromium resources if they have been initialized.

func (*ChromiumEngine) Render

func (e *ChromiumEngine) Render(ctx context.Context, req RenderRequest) ([]byte, error)

Render executes Chromium-based HTML-to-PDF rendering.

type Engine

type Engine interface {
	Render(ctx context.Context, req RenderRequest) ([]byte, error)
}

Engine renders HTML content into PDF bytes.

type EngineFunc

type EngineFunc func(ctx context.Context, req RenderRequest) ([]byte, error)

EngineFunc adapts a function to an Engine.

func (EngineFunc) Render

func (f EngineFunc) Render(ctx context.Context, req RenderRequest) ([]byte, error)

type RenderRequest

type RenderRequest struct {
	HTML    []byte
	Options export.RenderOptions
}

RenderRequest contains HTML input and render options for PDF engines.

type Renderer

type Renderer struct {
	Enabled      bool
	HTMLRenderer export.Renderer
	Engine       Engine
	MaxHTMLBytes int64
}

Renderer converts HTML templates into PDF output.

func (Renderer) Render

Render renders HTML using the configured HTML renderer and converts it to PDF.

type WKHTMLTOPDFEngine

type WKHTMLTOPDFEngine struct {
	Command string
	Args    []string
	Env     []string
	Timeout time.Duration
}

WKHTMLTOPDFEngine invokes wkhtmltopdf for HTML-to-PDF conversion.

func (WKHTMLTOPDFEngine) Render

func (e WKHTMLTOPDFEngine) Render(ctx context.Context, req RenderRequest) ([]byte, error)

Render executes wkhtmltopdf using stdin/stdout for HTML/PDF.

Jump to

Keyboard shortcuts

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