utilvo-pdf-merger Documentation¶
utilvo-pdf-merger is a lightweight, zero-dependency multi-language library for inspecting PDF binary headers (%PDF-1.x), counting leaf /Type /Page dictionary objects, validating xref tables and %%EOF markers, and merging multiple PDF byte streams into a consolidated document.
Built as the open-source companion library for the Merge PDF document processing utility, utilvo-pdf-merger allows developers to pre-validate PDF buffers, count total pages across multi-file batches, and concatenate PDF streams programmatically.
Online Utility: Merge PDF
Source Code Repository: https://github.com/utilvo/utilvo-pdf-merger
How It Works¶
Header & Integrity Inspection (``inspect_pdf``): Reads the first 1,024 bytes of each buffer to verify the
%PDF-1.xspecification header and scans the trailer for a valid%%EOFmarker.Page Tree Counting (``count_pdf_pages``): Scans indirect dictionary objects matching
/Type /Pageto count leaf page nodes while excluding parent/Type /Pagescontainers.Indirect Object Renumbering & ``xref`` Reconstruction (``merge_pdf_bytes``): Extracts page content streams across all input documents, assigns sequential object IDs under a unified
/Type /Pagesroot array (/Kids [...]), and calculates exact byte offsets to emit a standards-compliantxreftable andtrailerdictionary.
Installation¶
Python (PyPI):
pip install utilvo-pdf-merger
Node.js (npm):
npm install utilvo-pdf-merger
Rust (Crates.io):
cargo add utilvo-pdf-merger
Go:
go get github.com/utilvo/utilvo-pdf-merger
Usage Example¶
from utilvo_pdf_merger import inspect_pdf, count_pdf_pages, merge_pdf_bytes
info = inspect_pdf(pdf_bytes)
print(info["version"], info["page_count"], info["is_valid"])
merged_pdf = merge_pdf_bytes([doc_a_bytes, doc_b_bytes])