AnalyzePageSkewJSON

Image processing, document inspection, rendering

Description

Measures the rotation needed to straighten horizontal text and line structure on a scanned PDF page and returns deterministic JSON without changing the document

Syntax

Delphi

Function TPDFlib.AnalyzePageSkewJSON(Page: Integer; DPI: Double= 0;
  MaxAngle: Double= 0; AngleStep: Double= 0): WideString;

ActiveX

Function PDFlib::AnalyzePageSkewJSON(Page As Long, DPI As Double,
  MaxAngle As Double, AngleStep As Double) As String

DLL

const wchar_t* DLAnalyzePageSkewJSON(int InstanceID, int Page,
  double DPI, double MaxAngle, double AngleStep);
const char* DLAnalyzePageSkewJSONA(int InstanceID, int Page,
  double DPI, double MaxAngle, double AngleStep);

Parameters

PageThe one-based page number
DPIThe analysis resolution from 24 through 1200 before RenderScale; zero selects 96 DPI
MaxAngleThe symmetric search range from 0.1 through 45 degrees; zero selects 7 degrees
AngleStepThe coarse sweep step from 0.01 through MaxAngle; zero selects 1 degree, followed by automatic fine refinement

Return values

Returns JSON fields for page, correction angle, score-ratio confidence, peak score, automatic grayscale threshold, sampled foreground count, sample step, evaluated angle count, raster dimensions, and effective DPI

The angle is the correction to apply in PDF user space; positive values rotate counterclockwise and negative values rotate clockwise

Returns an empty string when validation, rendering, or analysis fails

Remarks

The implementation renders one bounded top-down bitmap, automatically lowers effective DPI when necessary to stay within four million pixels, computes an automatic luminance threshold, and scores differential row profiles through a coarse-to-fine angle search

Blank or nearly solid pages are successful analyses with zero confidence and no correction

The previously selected page is restored before the method returns

LastErrorCode is 116 for invalid page or search parameters and 520 for rendering or analysis failures

See also

DeskewPage, DeskewPageRange, ApplyOCRTextLayer