Native Annotated Review PDF
Create actual visible review highlights in a native incremental PDF copy while retaining the original page content, resources, encryption and signature byte ranges
{"schemaVersion":1,"type":"compare.contract","format":"pdf","side":"after","options":{"maxHighlights":1000}}
Call 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 receives the actual prepared PDF revision
Pascal entry points
HPDFSaveHeadlessContractAnnotatedPDF maps a complete comparison report to source-line highlights, validating page count, text and positioned line geometry against the selected loaded document before export
SaveReviewHighlightsToFile accepts 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 mutates the loaded document's annotations or dirty state
Authenticated DocMDP P3 permits review annotations; P1 and P2 reject 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 continues to protect page contents, resources and signed or locked fields
Limits and cancellation
Initialize 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 retain 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 is requested
Reader verification
Acceptance checks 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; independently removing only the annotations 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 remain separate capabilities
Native review behavior and limits · Native contract comparison