# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.14.0] - 2026-03-14

### Added

#### PDF Spec Coverage (23 new modules)
- **pdf/write.rs** (MPDF-26) — PDF writer with xref table generation, stream compression, binary header
- **pdf/font.rs** (MPDF-28) — Font subsystem: Standard 14 metrics, glyph widths, text decoding, encoding maps
- **pdf/colorspace.rs** (MPDF-29) — Full colorspace support: DeviceRGB/CMYK/Gray, ICCBased, Indexed, Lab, CalGray/CalRGB, Separation, DeviceN
- **pdf/cmap.rs** (MPDF-30) — CMap parsing: codespace ranges, bfchar/bfrange mappings, UTF-16 surrogate pairs, CID ranges
- **pdf/image.rs** (MPDF-27) — Image extraction: JPEG/Flate/inline images, BitsPerComponent validation, color key masks, RGBA conversion
- **pdf/text_render.rs** (MPDF-31) — Text rendering: glyph positioning, text matrix, font size/spacing, render modes
- **pdf/annot_types.rs** (MPDF-33) — Annotation types: appearance generation, border styles, color parsing, text escaping
- **pdf/barcode.rs** (MPDF-35) — Barcode generation: Code128, Code39, EAN-13, EAN-8, UPC-A with PDF content streams
- **pdf/chart.rs** (MPDF-36) — Chart generation: bar, line, pie, scatter with axis scaling, legends, color cycling
- **pdf/form_write.rs** (MPDF-37) — Form field write-back, FDF/XFDF export
- **pdf/xfa.rs** (MPDF-38) — XFA form detection and field value extraction from hybrid PDFs
- **pdf/interactive.rs** (MPDF-39) — Interactive features: actions (GoTo, URI, JavaScript, etc.), destinations, triggers, named destinations
- **pdf/print_production.rs** (MPDF-40) — Print production: page boxes with inheritance, output intents, separation info, halftone, overprint
- **pdf/certificate.rs** (MPDF-41) — X.509 certificate parsing (DER/ASN.1), PKCS#12 container support, certificate chain validation
- **pdf/cert_encrypt.rs** (MPDF-42) — Certificate-based PDF encryption structures, PKCS#7 envelope parsing
- **pdf/icc.rs** (MPDF-43) — ICC profile parsing: header, tag table, tone curves, RGB→XYZ conversion, sRGB output, profile caching
- **pdf/compliance.rs** (MPDF-44) — PDF/A-1b/2b, PDF/X-1a/3/4, PDF/UA-1 compliance validation with violation reporting
- **pdf/ocr.rs** (MPDF-45) — OCR framework: pluggable engine trait, Tesseract CLI integration, hOCR parsing, searchable PDF generation
- **pdf/transparency.rs** (MPDF-46) — Transparency: 16 blend modes, soft masks (alpha/luminosity), extended graphics state, Porter-Duff compositing
- **pdf/tagged.rs** (MPDF-47) — Tagged PDF: structure tree parsing, 40+ structure roles, reading order, PDF/UA validation
- **pdf/pattern.rs** (MPDF-48) — Patterns and shadings: tiling patterns, axial/radial shadings, PDF function evaluation (Type 2 exponential)

#### QPDF Feature Parity (MPDF-9)
- **qpdf/object_handle.rs** — ObjectHandle, Rectangle, PdfMatrix
- **qpdf/page_helper.rs** — Page inspection (media/crop/trim boxes, rotation, resources)
- **qpdf/annotation_helper.rs** — Annotation inspection and flattening
- **qpdf/form_helper.rs** — AcroForm field traversal and manipulation
- **qpdf/name_tree_helper.rs** — PDF Name Tree lookup, insert, remove
- **qpdf/number_tree_helper.rs** — PDF Number Tree operations
- **qpdf/outline_helper.rs** — Bookmark/outline manipulation
- **qpdf/embedded_file_helper.rs** — Embedded file stream management
- **qpdf/file_spec_helper.rs** — File specification dictionaries
- **qpdf/page_doc_helper.rs** — Document-level page operations
- **qpdf/document.rs** — Full PDF document model with xref parsing and object management
- **qpdf/writer.rs** — PDF writer with RC4/AES-128/AES-256 encryption
- **qpdf/job.rs** — Declarative PdfJob transformation API

#### FFI Bindings (MPDF-34)
- **ffi/pdf_writer.rs** — Writer FFI: create, add objects, write output
- **ffi/font_info.rs** — Font FFI: glyph width, text decoding
- **ffi/image_ops.rs** — Image FFI: decode, dimensions, RGBA conversion

#### Form Enhancements (MPDF-32)
- Hex string parsing in form field extraction
- `/Opt` array parsing for choice field options
- `/Kids` recursive field traversal for nested forms
- Radio button detection via `/Ff` bit 15
- `/AS` appearance state extraction for checkbox/radio when `/V` absent
- `/TU` tooltip and `/DA` default appearance parsing

#### Tests
- Comprehensive test suite with 109 new tests across core modules
- 3,012 total library tests

### Changed
- **Refactored large modules into smaller, focused submodules**:
  - `src/ffi/pdf_object.rs` (2077 lines) → 9 focused modules
  - `src/pdf/filter.rs` (1490 lines) → 12 focused modules
  - `src/fitz/buffer.rs` (1430 lines) → 3 focused modules (core, reader, writer)
- Improved test coverage from 72.28% to **81.54%** (base library)

### Fixed
- Fixed flate compression test reliability by using longer repetitive data for better compression ratios
- Fixed Pixmap creation in parallel tests to include alpha channel requirement
- Extensive defensive programming: checked arithmetic, bounds validation, overflow prevention across all new modules

## [0.13.3] - 2026-03-13

### Added
- Annotation type definitions and appearance generation for 28 types (MPDF-33)
- Text rendering pipeline with glyph positioning (MPDF-31)
- CMap module for character code to Unicode/CID mapping (MPDF-30)
- Comprehensive streaming PDF test suite (MPDF-6)

### Fixed
- Single-pass text escaping, deterministic appearance states (MPDF-33)
- Surrogate pair checked arithmetic, codespace validation (MPDF-30)
- Rect normalization, number parsing for int and real types (MPDF-33)
- CID range off-by-one, hex validation (MPDF-30)
- Hardcoded `/tmp` paths replaced with `std::env::temp_dir` (MPDF-24)
- TJ offset sign, unicode mapping, configurable em square (MPDF-31)
- Loop xref detection to skip all startxref occurrences (MPDF-3/4/5/7/8)
- Disabled broken benchmarks and docs pipeline steps (MPDF-49)

## [0.13.2] - 2026-03-13

### Changed
- Re-tagged release after Go module checksum conflict

## [0.13.1] - 2026-03-13

### Added
- Phase 2 content stream rendering operators (MPDF-17)
- Phase 1 critical codec and document structure fixes (MPDF-10)

### Fixed
- Increased backward search window from 200 to 4096 bytes for page copy (MPDF-7)
- Prevented SIGABRT in OverlayPDF by catching panics at FFI boundary (MPDF-23)
- Form XObject resource handling and clip stack balance (MPDF-17)
- Corrected startxref offsets in test PDFs and fixtures (MPDF-17)

## [0.13.0] - 2026-03-13

### Fixed
- Removed stale bookmarks and create standalone Catalog for ObjStm PDFs (MPDF-8)
- Preserved Catalog object number in overlay merge (MPDF-8)

## [0.12.0] - 2026-03-13

### Fixed
- Flattened compressed object streams before reorder and bookmark operations (MPDF-7)

## [0.11.10] - 2026-03-13

### Fixed
- Removed stale bookmarks and created standalone Catalog for ObjStm PDFs (MPDF-8)

## [0.11.9] - 2026-03-13

### Fixed
- Preserved Catalog object number in overlay merge and prioritized page tree traversal (MPDF-8)

## [0.11.8] - 2026-03-13

### Fixed
- `count_pages` and `find_page_objects` for PDFs with compressed object streams (MPDF-7)

## [0.11.7] - 2026-03-13

### Added
- Comprehensive streaming PDF test suite (MPDF-6)

### Fixed
- Corrected XRef offset calculations in PDF builders (MPDF-6)

## [0.11.6] - 2026-03-13

### Fixed
- Bookmark handling for page objects in compressed object streams

## [0.11.5] - 2026-03-13

### Fixed
- FFI error string cleanup with proper defer patterns
- Bookmark handling for cross-reference streams
- Added scan limit for FFI safety

## [0.11.4] - 2026-03-12

### Fixed
- `split_pdf` producing empty pages for PDFs with object streams (LI-261)

## [0.11.3] - 2026-03-04

### Changed
- Optimized hot paths across core library
- Default bookmarks to closed state

## [0.11.2] - 2026-03-04

### Fixed
- Prevented SIGABRT on binary PDFs in bookmark operations (MPDF-2)
- Thread-unique temp file paths in page merge

## [0.11.1] - 2026-03-03

### Fixed
- Thread-unique temp file paths in `page_merge` to prevent race conditions
- Handled `/Type/Pages` (no space) in `count_pages`

## [0.11.0] - 2026-03-03

### Added
- `fz_page_rotation` FFI for page rotation via `fz_*` handles
- Performance, platypus, typography stubs in enhanced module

### Fixed
- Page box parser handling `/Type/Page` (no space) and excluding `/Type /Pages`

## [0.10.4] - 2026-03-03

### Added
- `get_bookmarks` FFI function
- Font and glyph stubs with `ttf-parser`
- Real `reorder_pages` implementation with page copy + merge
- Release workflow script and documentation

### Fixed
- ARM64 cross-compilation in CI pipeline (zune-jpeg neon feature)

## [0.10.3] - 2026-03-03

### Added
- Bundled ARM64 native libraries

### Fixed
- `ExtractBookmarks` reader returning page 0 for all bookmarks
- CI pipeline Docker images and build steps

## [0.10.1] - 2026-03-02

### Fixed
- Bookmark page tree traversal for correct page ordering
- Method aliases and missing exports to match test expectations

## [0.10.0] - 2026-02-27

### Changed
- Replaced all stub FFI implementations with real logic

## [0.9.5] - 2026-02-26

### Fixed
- Recursive page tree traversal in bookmarks
- Empty bookmark titles handling
- Parenthesis unescaping in bookmark text

## [0.9.4] - 2026-02-26

### Added
- `mp_get_bookmarks` FFI function

### Fixed
- Bookmark writer: sibling linking, outline root, and trailer generation

## [0.9.3] - 2026-02-25

### Added
- Page rendering for scanned PDFs with embedded JPEGs

### Fixed
- Robust page count and MediaBox parsing in document FFI

### Changed
- Suppressed noisy object stream warnings in release builds

## [0.9.2] - 2026-02-24

### Fixed
- Included shared library in Go module
- Updated all dependencies to latest versions
- macOS cross-compilation step made non-blocking in CI

## [0.9.1] - 2026-02-17

### Added
- Object stream page count detection
- ExtGState resource transfer for transparent highlights

### Fixed
- Outline test expectation for 0-indexed page pass-through
- Indirect resource references in overlay ExtGState merging
- Object stream parser UTF-8 byte slicing issue
- Double page index increment in bookmark restoration
- Pinned Go memory before passing to CGO in `createTextOverlayNative`
- Prioritized object stream parsing for large PDFs

## [0.9.0] - 2026-01-22

### Added
- QPDF-inspired functionality module with pipelines, tokenizer, XRef streams
- Text overlay and font embedding support in writer
- CreateHighlightOverlay API for PDF highlighting
- Convenience APIs and extended test coverage

### Fixed
- Handle type correctness in C header and Go bindings (uint64_t for pointer safety)
- Buffer pool tests marked as serial for isolation

## [0.8.0] - 2026-01-17

### Added
- Linux distribution package builds (Debian/RPM)
- Man pages for libmicropdf

### Fixed
- Byte-level PDF merge preserving streams
- Page copying with resource preservation
- Content extraction for PDFs with compact syntax
- Page count estimation for compressed PDFs
- Overlay handling for variable spacing in `/Contents` reference pattern

### Changed
- Go bindings require native CGO bindings (mock mode removed)

## [0.7.0] - 2026-01-15

### Added
- rpath support in Go bindings to eliminate `LD_LIBRARY_PATH` requirement
- PDF validation and overlay support in FFI

### Fixed
- PDF parsing, page count, and outline iterator bugs
- Page box manager and split PDF functionality
- Go `splitPDF` now returns file paths

## [0.6.0] - 2026-01-14

### Added
- Multi-architecture builds (x64 + ARM64) in CI
- Automatic native library download system for `go-micropdf`
- Missing FFI wrappers for lexmata-identification migration

## [0.5.0] - 2026-01-14

### Added
- Comprehensive FFI bindings to all language adapters (Go, Node.js, Python)
- Python comprehensive test suite
- Artifact downloads and frictionless installation in CI

## [0.4.0] - 2026-01-14

### Added
- Digital signatures and encryption (Category 1)
- PDF/A and PDF/UA compliance features
- Print production tools (Category 2)
- Document composition framework (Category 3)
- HTML to PDF conversion (Category 4)
- Enterprise features architecture in enhanced module

### Changed
- Migrated from GitHub to Bitbucket
- Renamed `np_` FFI prefix to `mp_` prefix

### Fixed
- Python FFI bindings migrated from `np_` to `mp_` prefix

## [0.3.4] - 2025-12-30

### Fixed
- Nested pointer handling in header generation

## [0.3.3] - 2025-12-30

### Fixed
- `np_merge_pdfs` signature in FFI header files

## [0.3.2] - 2025-12-30

### Added
- CI workflow for building Node.js prebuilds and Python wheels
- Automatic distribution of prebuilds and wheels

## [0.3.1] - 2025-12-29

### Fixed
- pkg-config file references from nanopdf to micropdf in Docker builds

## [0.3.0] - 2025-12-29

### Added
- PDF merge function across all bindings (Rust, Go, Node.js, Python)
- PDF merge C++ bindings and native integration for Node.js

## [0.2.0] - 2025-12-28

### Added
- FFI safety module with SAFETY-documented helpers (`cstr_safe!`, `slice_safe!`, `write_safe!`)
- Batch geometry operations with NumPy acceleration (Python)
- TypedArray utilities for high-performance numeric ops (Node.js)
- Batch path operations and CGO pattern audit (Go)
- GPU acceleration module with multi-backend support
- Memory-mapped file support for large PDFs
- Lock-free data structures for concurrency
- SIMD utilities for matrix, color, and buffer operations
- Arena allocator for PDF objects
- Arc-based string interning for PDF Names
- Buffer pool for memory reuse in hot paths
- PDF fuzzing targets and conformance validation
- Tile rendering, table detection, and OCR FFI modules
- XPS, EPUB, SVG, CBZ/CBR, Office document format support
- 50+ new FFI modules (pdf_signature, pdf_layer, pdf_redact, pdf_clean, pdf_recolor, etc.)

### Changed
- Resource tracking with `runtime.SetFinalizer` (Go), `FinalizationRegistry` (Node.js), `__del__` audit (Python)
- `sync.Pool` optimizations for Point, Rect, Matrix, Quad (Go)
- `__slots__` on all geometry types (Python)
- LTO and PGO build optimization profiles
- Commitlint and Husky v9 for commit message validation

## [0.1.3] - 2025-12-25

### Added
- Complete FFI coverage across all modules (100% MuPDF API parity)
- PDF content stream interpreter
- Pixel rendering engine
- Glyph rasterization engine
- Structured text extraction with layout analysis
- PDF annotation and AcroForm field rendering
- Go bindings with 90.5% test coverage
- Node.js bindings with complete API parity
- Python bindings with comprehensive documentation
- Comprehensive PDF test suite with Git LFS fixtures

### Changed
- Refactored FFI layer to eliminate all placeholder implementations
- Improved colorspace and geometry modules for render engine

## [0.1.2] - 2025-12-04

### Fixed
- ARM64 cross-compilation linker configuration in CI

## [0.1.1] - 2025-12-04

### Fixed
- Invalid Docker tag format in CI builds

## [0.1.0] - 2025-12-04

### Added

#### Core Library (`fitz` module)
- **Error handling** with `PdfError` type using `thiserror`
- **Geometry primitives**: `Point`, `Rect`, `IRect`, `Matrix`, `Quad`
- **Buffer** for memory management with MD5 hashing support
- **Stream** abstraction for buffered I/O
- **Colorspace** support (Gray, RGB, CMYK, indexed)
- **Pixmap** for pixel buffer manipulation
- **Document** trait for document abstraction
- **Page** abstraction for page handling

#### PDF Module
- **PDF Object Model**: null, bool, int, real, string, name, array, dict, indirect
- **Compression filters**: FlateDecode, LZWDecode, ASCII85Decode, ASCIIHexDecode, RunLengthDecode
- **Cross-reference (xref) table** handling
- **PDF lexer/tokenizer**
- **PDF encryption/decryption** (pdf_crypt)
- **Interactive forms** (AcroForms) support
- **Annotation** support
- **Font** support (Type1/TrueType/CFF/CID)
- **Archive** support (ZIP/TAR/directories)
- **Image** handling system
- **Text** handling and geometry
- **Device** and display list system

#### FFI (C API Compatibility)
- 100% MuPDF-compatible C headers
- Handle-based safe resource management
- FFI exports for geometry, context, buffer, stream, colorspace, pixmap, document, PDF objects

#### Optional Features
- `parallel` — Rayon-based parallel processing
- `async` — Tokio-based async I/O
- `jpeg2000` — JPEG 2000 image support

#### Build Targets
- Static library (`libmicropdf.a`)
- Dynamic library (`libmicropdf.so`)
- Rust library (rlib)
- Debian and RPM package support

[Unreleased]: https://bitbucket.org/lexmata/micropdf/compare/v0.14.0...HEAD
[0.14.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.13.3...v0.14.0
[0.13.3]: https://bitbucket.org/lexmata/micropdf/compare/v0.13.2...v0.13.3
[0.13.2]: https://bitbucket.org/lexmata/micropdf/compare/v0.13.1...v0.13.2
[0.13.1]: https://bitbucket.org/lexmata/micropdf/compare/v0.13.0...v0.13.1
[0.13.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.12.0...v0.13.0
[0.12.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.10...v0.12.0
[0.11.10]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.9...v0.11.10
[0.11.9]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.8...v0.11.9
[0.11.8]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.7...v0.11.8
[0.11.7]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.6...v0.11.7
[0.11.6]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.5...v0.11.6
[0.11.5]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.4...v0.11.5
[0.11.4]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.3...v0.11.4
[0.11.3]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.2...v0.11.3
[0.11.2]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.1...v0.11.2
[0.11.1]: https://bitbucket.org/lexmata/micropdf/compare/v0.11.0...v0.11.1
[0.11.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.10.4...v0.11.0
[0.10.4]: https://bitbucket.org/lexmata/micropdf/compare/v0.10.3...v0.10.4
[0.10.3]: https://bitbucket.org/lexmata/micropdf/compare/v0.10.1...v0.10.3
[0.10.1]: https://bitbucket.org/lexmata/micropdf/compare/v0.10.0...v0.10.1
[0.10.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.9.5...v0.10.0
[0.9.5]: https://bitbucket.org/lexmata/micropdf/compare/v0.9.4...v0.9.5
[0.9.4]: https://bitbucket.org/lexmata/micropdf/compare/v0.9.3...v0.9.4
[0.9.3]: https://bitbucket.org/lexmata/micropdf/compare/v0.9.2...v0.9.3
[0.9.2]: https://bitbucket.org/lexmata/micropdf/compare/v0.9.1...v0.9.2
[0.9.1]: https://bitbucket.org/lexmata/micropdf/compare/v0.9.0...v0.9.1
[0.9.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.8.0...v0.9.0
[0.8.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.7.0...v0.8.0
[0.7.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.6.0...v0.7.0
[0.6.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.5.0...v0.6.0
[0.5.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.4.0...v0.5.0
[0.4.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.3.4...v0.4.0
[0.3.4]: https://bitbucket.org/lexmata/micropdf/compare/v0.3.3...v0.3.4
[0.3.3]: https://bitbucket.org/lexmata/micropdf/compare/v0.3.2...v0.3.3
[0.3.2]: https://bitbucket.org/lexmata/micropdf/compare/v0.3.1...v0.3.2
[0.3.1]: https://bitbucket.org/lexmata/micropdf/compare/v0.3.0...v0.3.1
[0.3.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.2.0...v0.3.0
[0.2.0]: https://bitbucket.org/lexmata/micropdf/compare/v0.1.3...v0.2.0
[0.1.3]: https://bitbucket.org/lexmata/micropdf/compare/v0.1.2...v0.1.3
[0.1.2]: https://bitbucket.org/lexmata/micropdf/compare/v0.1.1...v0.1.2
[0.1.1]: https://bitbucket.org/lexmata/micropdf/compare/v0.1.0...v0.1.1
[0.1.0]: https://bitbucket.org/lexmata/micropdf/releases/tag/v0.1.0
