Native Linux contract comparison

hpdf_document_compare_json_v1 borrows two loaded document handles and runs native semantic contract comparison or general document comparison, with prepared output through callbacks

{"schemaVersion":1,"type":"compare.contract","format":"html",
 "title":"Contract review","options":{"granularity":"word",
 "ignoreRepeatedHeadersFooters":true,"maxAlignmentCells":2000000},
 "limits":{"memoryBytes":268435456,"resultBytes":4194304,"outputBytes":8388608}}

Semantic contract reports

The native adapter uses the same portable paragraph alignment and difference algorithm as the Windows contract API, including word or sentence changes, cross-page moves, repeated margin exclusion, boilerplate filters and page continuations

Contract reports include comparisonComplete, identical, differenceCount, page and paragraph counts, exclusions, work and alignment counters, plus each change's text, context and locations

Each location contains a zero-based page and paragraph, a one-based character offset, character count and PDF user-space rectangles covering intersecting semantic lines; rectangles represent line geometry

Native glyph extraction preserves nested Form resources and matrices, inherited page boundaries and extraction permissions for plaintext and authenticated AES R5/R6 inputs; pages without extractable text report an extraction failure and require OCR or explicit blank-page removal

Options and limits

options accepts granularity (word or sentence), ignoreCase, ignoreRepeatedHeadersFooters, normalizeMarginDigits, joinPageContinuations, headerMarginPoints, footerMarginPoints, paragraphGapFactor, minimumParagraphSimilarity, minimumRepeatedPages and excludedLineTexts

Explicit positive integer limits include maxPages, maxParagraphs, maxSemanticLines, maxCharacters, maxTokens, maxDifferences, maxAlignmentCells and maxWorkUnits; operation memory and result budgets cap these limits before execution

compare accepts page-count, page-text, object-count, rendered-image, structural and full modes with JSON output; discover available modes through comparisonModes and contract formats through contractFormats

format:json writes the result JSON to the optional binary callback as well as the required result callback; format:html requires a binary callback and writes a standalone UTF-8 review with escaped title and contract wording

format:pdf requires binary output callbacks and creates an actual annotated review copy of side:before or side:after, defaulting to after; options.maxHighlights limits highlighted semantic lines

Lifetime and publication

Keep both handles alive during the call; same-handle comparison is supported and opposite-order concurrent comparisons acquire locks in a stable order

All callbacks run synchronously on the calling thread; resource limits are temporarily applied to each loaded document and restored afterward, including failure and cancellation paths

The call accepts no input callback or file-path members, and preserves both source documents and their revisions; binary and JSON output are prepared and bounded before publication begins

Pascal interface

HPDFCompareHeadlessContracts accepts two THPDFHeadlessDocument objects with existing THPDFContractCompareOptions and returns THPDFContractCompareReport

HPDFHeadlessContractSource exposes the native adapter; HPDFCompareContractSources in HPDFContractCompareCore accepts custom bounded page-count, semantic-page and visible-box callbacks for the portable core

HPDFContractCompareCore owns the shared algorithm, report types and HTML renderer without VCL or LCL dependencies; the existing HPDFContractCompare Windows interface preserves its types, constants and loaded-document entry points through aliases and adapters

THPDFHeadlessDocument.ExtractPageGlyphs and AnalyzePageSemanticText expose positioned glyphs and semantic layout through the same nested-content walker used by ExtractPageText

Native ABI acceptance verifies actual plaintext, AES R5/R6 and nested-Form comparisons, rollback, budgets and lock ordering; independent pypdf and MuPDF readers verify complete differences, exact contexts, offsets and source glyph geometry

Native Linux C ABI · Contract comparison · Remaining delivery plan