function DetectPageSkew(out Report: TPdfSkewReport): Boolean;
| Report | TPdfSkewReport. Receives SkewAngle in degrees (positive means clockwise tilt), Confidence from 0 to 1, the SampleWidth and SampleHeight used for detection, a Succeeded flag, and an ErrorMessage |
| Result | Boolean. True when an angle was measured, matching Report.Succeeded |
Detects the skew angle by rendering the page at low resolution and projecting text pixels onto candidate rotation angles; the angle whose projection produces the sharpest line structure wins. Accuracy is about 0.1 degrees
Confidence reflects how much text-line evidence the page offered. A page of running text scores high; a page with a single line or none scores low, and a low score should be treated as "no reliable answer" rather than "no skew"
Detection only measures. To straighten the page, feed the negated angle into a rotation matrix and apply it with TransformPageContent, or render through RenderPageWithMatrix when only the output needs to be corrected
var Report: TPdfSkewReport;
if Pdf.DetectPageSkew(Report) and (Report.Confidence > 0.5) then
ShowMessageFmt('Tilted by %.2f degrees', [Report.SkewAngle]);