printpdf

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package printpdf prints a web page to PDF with the system's own web engine, offscreen: WebKit through WKWebView on macOS, WebKitGTK on Linux (spec_desktop_024). The desktop app's Export as PDF prints the Markdown preview this way, so the PDF looks as the preview does, highlighted code and Mermaid diagrams included, with no browser to install.

The engine runs on the UI thread: inside the app that's Wails's; a program without Wails (a test) starts one with InitUI and RunMainLoop.

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("printing the page took too long")

ErrTimeout is returned when the page didn't print in time.

View Source
var ErrUnsupported = errors.New("printing to PDF isn't supported on this system")

ErrUnsupported is returned where the system has no engine to print with.

Functions

func InitUI

func InitUI() bool

InitUI readies GTK for a program without Wails, such as this package's tests, on the main thread; false where there's no display.

func Print

func Print(html, pageSize string, timeout time.Duration) ([]byte, error)

Print renders html (a whole page, its styles and pictures inline) on pages of pageSize ("A4" or "Letter"; A4 otherwise) and returns the PDF. Scripts don't run, and the page can't navigate anywhere.

func RunMainLoop

func RunMainLoop()

RunMainLoop runs GTK's main loop on the calling thread, which must be the main one, after InitUI, and never returns.

Types

This section is empty.

Jump to

Keyboard shortcuts

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