Native Annotated Review PDF

Create actual visible review highlights in a native incremental PDF copy whilst retaining the original page content, resources, encryption and signature byte ranges

{"schemaVersion":1,"type":"compare.contract","format":"pdf","side":"after","options":{"maxHighlights":1000}}

Invoke hpdf_document_compare_json_v1 with two loaded handles, a required PDF output callback and a required result callback; side selects before or after and defaults to after

The JSON result contains the complete semantic comparison, mediaType:application/pdf and the selected side; the binary callback is handed the actual prepared PDF revision

Pascal entry points

HPDFSaveHeadlessContractAnnotatedPDF maps a complete comparison report to source-line highlights, validating the page count, text and positioned line geometry against the selected loaded document before export

SaveReviewHighlightsToFile takes explicit page rectangles and Unicode captions for other review workflows

Output and permissions

Each highlight has a real Highlight annotation, rectangle, quadrilateral, Unicode contents, print flag and normal Form appearance with a yellow fill and Multiply transparency

Existing annotations and signature widgets remain present; neither entry point touches the loaded document's annotations or dirty state

Authenticated DocMDP P3 allows review annotations; P1 and P2 refuse them before publication, as do more restrictive authenticated field-lock permissions and encrypted user permissions without annotation rights

Valid P3 review revisions may be reopened and saved again; validation preserves original widgets exactly once and keeps protecting page contents, resources and signed or locked fields

Limits and cancellation

Initialise THPDFHeadlessReviewOptions.Default before changing MaxHighlights, MaxWorkingBytes or CancellationToken; defaults are 10000 highlights and 67108864 preparation bytes

Document object, object-byte, file-byte and depth limits also apply; captions require valid UTF-16 without NUL, and rectangles require finite, bounded coordinates and positive dimensions

The writer prepares privately, flushes the staging file and publishes by atomic rename; source aliases, validation failures, exhausted budgets and cancellation keep an existing destination and remove unpublished staging files

Use one shared cancellation token for a document and its review options; temporary document limits are restored even when cancellation has been requested

Reader verification

Acceptance covers plaintext, nested Forms, AES R5/R6, Unicode captions, repeat revisions, trusted CAdES signature preservation, actual visible MuPDF pixels and both source sides through fragmented native callbacks

A reader may select transparent page compositing from annotation resources even with annotation drawing disabled, changing text antialiasing; removing only the annotations on its own restores the exact original page pixels

Comparison rectangles cover affected semantic lines rather than exact character outlines; general image comparison heat maps and annotated non-contract comparisons stay separate capabilities

Native review behaviour and limits · Native contract comparison