PDFium Delphi Component Docs

מתודת TextInRectangle

Component: TPdf  ·  Unit: PDFium
מחלץ טקסט בתוך גבול מלבני בדף

Syntax

function TextInRectangle(Left, Top, Right, Bottom: Double): WString;

 

function TextInRectangle(Rectangle: TPdfRectangle): WString;

RectangleTPdfRectangle. A record specifying the bounding rectangle in PDF user-space coordinates (origin at lower-left, Y increases upward).

Return Value

A WString (Unicode string) containing all characters whose bounding boxes intersect the specified rectangle. Returns an empty string if no text is found within the region.

Description

TextInRectangle מחלץ את תוכן הטקסט Unicode הנופל בתוך אזור מלבני נתון בעמוד הנוכחי. זה שימושי לקריאת טקסט מאזור מסוים כגון כותרת עליונה, כותרת תחתונה, תא טבלה או תווית שדה מבלי לעבד את העמוד כולו

מסופקים שני עומסים. הצורה בעלת ארבעת הפרמטרים מקבלת ערכי Left, Top, Right ו-Bottom בודדים. הצורה בעלת הפרמטר היחיד מקבלת רשומת TPdfRectangle, שנוחה כאשר האזור כבר מחושב כמבנה מלבן

קואורדינטות משתמשות במרחב משתמש PDF: המקור בפינה השמאלית-תחתונה של העמוד ו-Y גדל כלפי מעלה. שימו לב ש-Bottom הוא לכן ערך קטן יותר מ-Top עבור מלבן בכיוון רגיל. תווים נכללים בתוצאה אם תיבות התיחום שלהם חופפות את האזור שצוין

כמו Text, מתודה זו קוראת משכבת הטקסט הלוגית של העמוד ופועלת על עמוד PDF טעון

Example

// Extract text from the top header area of an A4 page
// A4: 595 x 842 pt; header = top 60 pt band
Pdf1.LoadFromFile('C:\Docs\report.pdf');
Pdf1.PageIndex := 0;
var HeaderText: WString;
begin
  HeaderText := Pdf1.TextInRectangle(0, 782, 595, 842);
  ShowMessage(HeaderText);
end;

// Using TPdfRectangle overload
var
  Rect: TPdfRectangle;
  CellText: WString;
begin
  Rect.Left := 72; Rect.Bottom := 600;
  Rect.Right := 250; Rect.Top := 640;
  CellText := Pdf1.TextInRectangle(Rect);
end;

See Also

Text, CharacterCount, FindFirst