Pure-Go PDF reader — open, extract text/content, optional security stratum, sanitize rewrite.
CGO_ENABLED=0. Selected C libraries are transpiled with ccgo (blobs under internal/, linux/amd64).
Not a writer. For Markdown → PDF/office, see DoWi55 (hpdf55).
go get github.com/hazyhaar/pdfast@latestimport "github.com/hazyhaar/pdfast"
doc, err := pdfast.OpenFile(path)
doc, err := pdfast.OpenFile(path, pdfast.WithSecurity(true)) // untrusted
pages, err := pdfast.ExtractContent(ctx, doc)
pages, err := pdfast.ExtractText(ctx, doc)
out, err := pdfast.Saniscribe(ctx, doc)| Default open | Core structural engine (no full-file active scan) |
WithSecurity(true) |
Active-content scan + obliterate/reject policy |
ExtractContent |
Decompressed page content streams |
ExtractText |
Native text extract |
Saniscribe |
Rewrite cleaned PDF bytes |
| Encrypt / polyglot | Fail at open |
Contract: V1.md. Engines: docs/ENGINES.md.
| Package | Upstream | Role |
|---|---|---|
internal/truetype |
stb_truetype | Font metrics / cmap |
internal/clexer |
stb_c_lexer | Script tokenization (security) |
internal/tinyexpr |
tinyexpr | Type 4 functions |
internal/stbimage |
stb_image | Image decode, flate fallback |
internal/ccittfax |
CCITT Fax | /CCITTFaxDecode |
Do not hand-edit a_linux_amd64.go files.
V1 reader path is the product focus. Re-run benches before publishing speed claims. Default path ≠ security mode cost.
MIT — Copyright (c) 2026 hazyhaar
Upstream C (stb, tinyexpr, …) retain original licenses; see blob headers.