User Tools

Site Tools


k23:k23.12:k23.12.4:start

23.12.4 Class Pdf

The class Pdf (gb.poppler) is static and provides 4 numerical constants in relation to the search in a PDF document with the method hPdfDocument.Find(argSuchtext, [ argSuchOption ]):

ConstantValueDescription
CaseSensitive1Case case sensitive
Backwards2Backward search
WholeWordsOnly4Search for whole words only
IgnoreDiacritics8Ignore diacritical characters

Table 23.12.4.1 : Constants of the Pdf class

23.12.4.1 Example

The following source code can be used to search for a specific text in a PDF file. The coordinates of the text-enclosing rectangle are displayed in the IDE console:

Public Sub SearchText(sSearchText As String, Optional iSearchOption As Integer)
 
  Dim i As Integer
  Dim aRectF As New RectF[]
 
  If IsNull(iSearchOption) Then iSearchOption = 0
 
  For i = 0 To $hPdfDocument.Max
      aRectF = $hPdfDocument[i].FindText(sSearchText, iSearchOption)
      If aRectF.Count > 0 Then
         For Each hRectF As RectF In aRectF
             Print "x: "; Round(hRectF.X, -1); "  y: "; Round(hRectF.Y, -1);
             Print "  |  w: "; Round(hRectF.W, -1); "  h: "; Round(hRectF.H, -1)
         Next
      Endif
  Next
 
End

This text is located in the file simpletext.pdf:

Er programmiert in der Programmiersprache Gambas.
Fazit: Gambas ist toll!

Calling the procedure with the search text “Gambas” and two search options:

SearchText("Gambas", Pdf.CaseSensitive Or Pdf.WholeWordsOnly)

results in this display in the console:

Rechteck-Koordinaten:
----------------------------------------
x: 66,6  y: 736,3  |  w: 52,9  h: 15,6
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.
k23/k23.12/k23.12.4/start.txt · Last modified: by 127.0.0.1