TPDFlibSBCompare

Editions

Description

TPDFlibSBCompare (unit PDFlibSBCompare) is the first Small Business feature class of the edition class chain. It descends directly from TPDFlib and implements the Small Business methods for structural, visual and text comparison of two documents, for modification-level analysis against a saved revision and for the per-revision change report of the incremental-update chain.

It belongs to the Small Business edition; the Enterprise edition includes every Small Business class, so it is part of both editions. TPDFlibSBInvoice descends from it and adds the next feature group.

Syntax

Delphi

TPDFlibSBCompare = Class(TPDFlib);

Key members

CompareWithStructurally compares the selected document with the saved revision in OldFileName and caches the findings for the GetCompareFinding* methods
GetCompareFindingCountReturns the number of findings cached by the most recent CompareWith call
GetCompareFindingKindReturns the kind of one cached comparison finding, as the ordinal of the kind plus 1
GetCompareFindingObjNumReturns the object number of one cached comparison finding
GetCompareFindingDetailReturns the detail text of one cached comparison finding
AnalyzeModificationsClassifies every change since the saved revision in OldFileName and caches the findings and the overall modification level for the GetModification* methods
GetModificationLevelReturns the overall modification level cached by the most recent AnalyzeModifications call
GetModificationFindingCountReturns the number of findings cached by the most recent AnalyzeModifications call
GetModificationFindingLevelReturns the level of one cached modification finding
GetModificationFindingObjNumReturns the object number of one cached modification finding
GetModificationFindingDetailReturns the detail text of one cached modification finding
CompareRenderedPagesWithRenders both pages at DPI and compares the bitmaps; Comparison receives the measurements and any requested mask and overlay, and ErrorText the reason for a failure
CompareDocumentVisualsWithRenders every page of both documents, pairs the pages by the SHA-256 digest of their raster and returns a JSON report of the page pairs, each reported as changed, size_changed, unchanged, added or removed
CompareFileVisualsLoads the other file and compares it with the selected document page by page at DPI with the colour tolerance ColorTolerance
CompareFileVisualsExRuns the comparison from a JSON options string that can set the resolution, the colour tolerance, the tile size, ignored pixel rectangles, one page pair with mask and overlay output, and a visual alignment with page anchors
SaveVisualComparisonPDFCompares the selected document with a baseline file raster by raster and saves a review PDF that holds a copy of each page of both sides with the difference rectangles drawn on the copies and a label per page; returns a JSON description of the output
ComparePageTextsWithCompares the extracted text of both documents page by page and returns the number of pages whose text differs; FirstDifferentPage receives the first of them
CompareDocumentTextsWithExtracts the text of both documents as words (Granularity 0) or as lines and returns a JSON list of the runs that differ, each with its text and page number on both sides
CreateTextComparisonReportCompares the extracted text of the selected document with a baseline file and returns the comparison as an HTML or JSON report selected by ReportFormat, leaving the selected document in place
SaveTextComparisonPDFCompares the extracted text of the selected document with a baseline file and writes the differences to a review PDF at OutputFileName, leaving the selected document in place
CompareTextBaselineBatchRuns the text comparison for the file pairs of the JSON request and returns the batch envelope with the result of every pair
ConvertFilesBatchRuns the batch of file conversions described by the JSON request and returns the per-file results together with the delivery manifest
GetDocumentRevisionCountBuilds the revision map of the file and returns the number of revisions it holds
GetDocumentRevisionsCompleteReturns 1 when the revision map could follow the whole revision history of the file back to its start, and 0 otherwise
GetDocumentRevisionStartReturns the byte offset at which the revision RevisionIndex begins
GetDocumentRevisionEndReturns the byte offset at which the revision RevisionIndex ends
GetDocumentRevisionKindReturns the change kind of the revision RevisionIndex as its ordinal value
GetDocumentRevisionChangesReturns a string list handle with one line per object the revision RevisionIndex added, modified or freed
GetSignatureRevisionIndexReturns the zero-based index of the revision that ends where the signed byte range of the signature field FieldName ends, or -1 when the range does not end on a revision boundary
ExtractDocumentRevisionWrites the bytes of the document file up to the end of the revision RevisionIndex to OutputFileName, which is the document as it stood after that revision

Remarks

The findings of the most recent CompareWith and AnalyzeModifications calls stay cached in the instance; the GetCompareFinding* and GetModification* methods read that cache. A new CompareWith call clears the comparison findings, a new AnalyzeModifications call clears the modification findings and the level.

The document-wide visual comparison renders every page of both documents and pairs the pages by the SHA-256 digest of the rendered raster; a pair of equal raster size is then compared with the options and reported as changed with its difference regions or as unchanged. SaveVisualComparisonPDF needs a selected document of 1 to 256 pages, an output name with the extension .pdf that does not exist yet, and renders at 72 to 300 DPI, 96 by default.

ExtractDocumentRevision works on the selected document and needs it to be loaded from a file.

On a plain TPDFlib two revision methods do not return 0 but their default value: GetDocumentRevisionKind returns 7 and GetSignatureRevisionIndex returns -1. CompareRenderedPagesWith returns False and sets ErrorText to a message that names the Small Business edition.

Applications normally create TPDFlibSmallBusiness or TPDFlibEnterprise and get the methods of this class through them. The same methods on a plain TPDFlib return 0, an empty string or False and set LastErrorCode to PDFLIB_ERROR_SMALLBUSINESS_REQUIRED.

See also

TPDFlib, TPDFlibSBInvoice, TPDFlibSmallBusiness, TPDFlibEnterprise