Recursive AI

Changelog

All onepdf Go docs

All notable changes to this project are documented in this file. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[1.0.1]

Fixed

  • A damaged file whose objects name their type through a reference no longer causes a panic while the document is repaired; the file opens repaired or returns an error.

[1.0.0]

First release. recursiveai.org/go/onepdf is a pure-Go PDF library: no cgo, no bindings, no WebAssembly, and no dependency beyond the Go standard library and onefont-go (used by layout). Go 1.24 or later.

Reading

  • Opens a file, a byte slice or an io.ReaderAt; reads classic and cross-reference-stream tables, hybrid-reference files, object streams, linearized files and every incremental revision, loading objects lazily.
  • Repairs damaged files: rebuilds the cross-reference table by scanning, fixes wrong stream lengths, tolerates missing endobj and broken trailers, and records each repair as a diagnostic. Strict mode turns repairs into errors.
  • Decrypts the standard security handler (RC4 40 and 128 bit, AES-128, AES-256; revisions 2 to 6) with the user or owner password.
  • Decodes Flate, LZW, ASCIIHex, ASCII85, RunLength, CCITT Group 3 and 4, Crypt and the PNG and TIFF predictors with our own code. DCT, JPX and JBIG2 go through a decoder registry that returns raw samples; the library applies every PDF image rule (/Decode, Adobe CMYK, colour-key masks, /SMask, stencil masks) itself.
  • Exposes the document model: pages and boxes, metadata (Info and XMP), outlines, page labels, destinations, named destinations, annotations, optional content, embedded files, AcroForm fields and the structure tree.
  • Limits on object counts, nesting, decoded sizes, image samples and per-page work are checked before memory is allocated and can be changed by the caller. Errors are values that match sentinel categories with errors.Is.

Interpreting pages

  • Interprets content streams into a device.Device: paths, glyph runs with outlines and Unicode, images, shadings, clips, transparency groups, soft masks, tiling patterns, Type 3 glyphs, marked content and annotation appearances.
  • Colour spaces including ICC, Lab, Indexed, Separation and DeviceN; functions of types 0, 2, 3 and 4; shading types 1 to 7.
  • Reads Type 1, CFF, TrueType, OpenType and Type 3 fonts, predefined CJK CMaps and the standard 14 font metrics. Fonts that are not embedded come from a provider you register, such as the fonts module.
  • device/displaylist records a page, replays it with culling, and reads and writes the shared text form.

Text extraction

  • Glyphs, words, lines and blocks in reading order, from the structure tree when the file is tagged and from page geometry otherwise; plain text in reading, content and layout order; bidirectional and vertical text; the shared JSON form.
  • Unicode comes from /ToUnicode, encodings and glyph names, the font's own tables and predefined CMaps.

Writing and editing

  • Saves a new file or appends an incremental update, as a classic table or with cross-reference and object streams, with AES or RC4 encryption. The same input and document ID give the same bytes.
  • Merges, splits, reorders, rotates, deletes and imports pages, keeping outlines, links, names, labels and form fields.
  • Fills, resets and flattens forms and generates missing field and annotation appearances.
  • Creates content: text in the standard fonts or embedded TrueType and OpenType subsets, paths, images (JPEG, PNG and raw samples), gradients, stamps and watermarks; writes whole documents as a stream.
  • Adds and reads markup annotations, links and file attachments.
  • redact removes text, vector paths and image regions under areas, with the annotations, form values and metadata that go with them, and fails closed when a page cannot be read completely.

Signatures

  • sign verifies signatures against trust anchors you supply, checking the byte range, digest, CMS signature, certificate chain and key usage, timestamps, revocation data you supply, and what changed after signing.
  • Signs with PAdES baseline or adbe.pkcs7.detached, with timestamps, certification and field locks, visible appearances, document timestamps and two-phase signing for keys that live elsewhere. The signing time is the current time unless you set it.
  • Never downloads anything.

PDF/A, PDF/UA and tagging

  • pdfa checks, prepares and saves PDF/A-2 and -3 (levels b and u), and converts existing files, refusing with every reason when a file cannot be converted.
  • pdfua checks, prepares and saves PDF/UA-1 and PDF/UA-2.
  • tag adds a structure tree to an untagged file from roles you supply, reads and edits existing trees, and removes tags.

Layout

  • layout builds documents in code: styled and rich text shaped through onefont-go, boxes, rows and columns, tables with repeated headers, lists, images, headers, footers and page numbers, barcodes, SVG, links and bookmarks. Output is tagged PDF, ready for PDF/UA.
  • layout/hyphen carries hyphenation patterns for 26 languages.

Safety

  • No panic and no hang on hostile input; recursion never follows input depth. Document scripts and actions are never run and the library imports no net or os/exec. A nil context.Context passed to any ...Context function means context.Background().