pdf

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const InteractivePdfiumTimeout = 30 * time.Second

InteractivePdfiumTimeout is how long user-facing requests (the reader and the cover-page picker in pkg/pdfpages) wait for the shared pdfium instance. They should fail fast rather than hang. The pool holds a single instance (see initPdfiumPool), so every caller queues behind whoever has it.

Variables

This section is empty.

Functions

func EnsurePdfcpuInit

func EnsurePdfcpuInit()

EnsurePdfcpuInit initializes pdfcpu's global state exactly once. This must be called before any concurrent use of pdfcpu's NewDefaultConfiguration(). Safe to call from multiple goroutines; only the first call does work.

func EnsurePdfiumPoolInit added in v0.0.21

func EnsurePdfiumPoolInit() error

EnsurePdfiumPoolInit initializes the go-pdfium WASM pool if not already done. Safe to call multiple times; initialization happens at most once.

func Parse

func Parse(path string) (*mediafile.ParsedMetadata, error)

Parse reads metadata from a PDF file and returns it in the mediafile.ParsedMetadata format for compatibility with the existing scanner.

func PdfiumInstance added in v0.0.21

func PdfiumInstance(timeout time.Duration) (pdfium.Pdfium, error)

PdfiumInstance returns a pdfium instance from the shared WASM pool. The caller must call instance.Close() when done to return it to the pool.

func RenderPageJPEG added in v0.0.27

func RenderPageJPEG(path string, pageIdx int, dpi int, quality int) ([]byte, string, error)

RenderPageJPEG renders a single page of a PDF to JPEG using the shared pdfium WASM pool. pageIdx is 0-indexed. Its callers all run during Scans (Parse's cover fallback, and the worker's cover recovery and sidecar or plugin cover pages), so it waits scanPdfiumTimeout for the instance. Interactive page rendering goes through pkg/pdfpages instead.

Types

type OutlineEntry added in v0.0.21

type OutlineEntry struct {
	Title     string
	StartPage int // 0-indexed page number
}

OutlineEntry represents a single bookmark from a PDF's outline tree.

func ExtractOutline added in v0.0.21

func ExtractOutline(path string) ([]OutlineEntry, error)

ExtractOutline extracts the bookmark/outline tree from a PDF and returns a flat list of entries with their target page numbers. Returns nil (not an error) if the PDF has no bookmarks. It is part of the Scan path, so it waits scanPdfiumTimeout for the pdfium instance. Outlines are read with PDFium, never pdfcpu: pdfcpu refuses an outline containing /Dest [null ...], which some tooling writes on most bookmarks.

Directories

Path Synopsis
Package incremental reads just enough of a PDF to append an incremental update to it, and writes that update.
Package incremental reads just enough of a PDF to append an incremental update to it, and writes that update.

Jump to

Keyboard shortcuts

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