Loading...
Searching...
No Matches
TextSearch.h
Go to the documentation of this file.
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5#ifndef PDFTRON_H_CPPPDFTextSearch
6#define PDFTRON_H_CPPPDFTextSearch
7
8#include <PDF/PDFDoc.h>
9#include <Common/UString.h>
10#include <PDF/Highlights.h>
11#include <C/PDF/TRN_TextSearch.h>
12
13namespace pdftron {
14 namespace PDF {
15
20{
21public:
22
26 operator bool () { return IsFound(); }
27
31 bool IsFound() const;
32
36 bool IsDocEnd() const;
37
41 bool IsPageEnd() const;
42
46 int GetPageNumber() const;
47
52
58
64
65
66
67// @cond PRIVATE_DOC
68
69#ifndef SWIGHIDDEN
71 SearchResult(const SearchResult& b);
72 SearchResult(int, TRN_TextSearchResultCode rc, UString r, UString a, Highlights h);
73#endif
74// @endcond
75
76private:
77 int page_num;
78 TRN_TextSearchResultCode resCode;
79 UString result;
80 UString ambient;
81 Highlights hlts;
82};
83
84
174{
175public:
176
182
186 typedef TRN_UInt32 Mode;
187
192 {
193 //use regular expressions
195
196 //match case-sensitively
198
199 //match the entire word
201
202 //search upward (from the end of the file and from the bottom of a page)
204
205 //tells the search process to return when each page is finished; this is
206 //useful when a user needs Run() to return periodically so that certain
207 //things (e.g., UI) can be updated from time to time.
209
210 //tells the search process to compute Highlight information.
212
213 //tells the search process to compute the ambient string of the found pattern.
214 //This is useful if a user wants to examine or display what surrounds the
215 //found pattern.
217
218 //refrain from replacing newlines with spaces
220
221 //use Z-order as reading order for text
223 };
224
239 bool Begin(PDFDoc& doc, const UString& pattern, Mode mode, int start_page = -1, int end_page = -1);
240
251
260 bool SetPattern(const UString& pattern);
261
266 Mode GetMode() const;
267
281 void SetMode( Mode mode );
282
287 void SetRightToLeftLanguage(bool flag);
288
296 int GetCurrentPage() const;
297
309
313 void Destroy();
314
315
316/* {{codegen: TextSearch}} */
317
323 void SetAmbientLettersBefore(int ambient_letters_before);
324
330 void SetAmbientLettersAfter(int ambient_letters_after);
331
337 void SetAmbientWordsBefore(int ambient_words_before);
338
344 void SetAmbientWordsAfter(int ambient_words_after);
345/* {{codegen: TextSearch}} */
346
347// @cond PRIVATE_DOC
348
349 #ifndef SWIGHIDDEN
350 TRN_TextSearch mp_textsearch;
351 #endif /* SWIGHIDDEN */
352private:
353 TextSearch(const TextSearch&);
354 TextSearch& operator= (const TextSearch&);
355// @endcond
356
357};
358
359
360#include <Impl/TextSearch.inl>
361
362 }; // namespace PDF
363}; // namespace pdftron
364
365#endif // PDFTRON_H_CPPPDFTextSearch
Highlights GetHighlights() const
UString GetAmbientString() const
UString GetMatch() const
void SetAmbientLettersBefore(int ambient_letters_before)
void SetAmbientLettersAfter(int ambient_letters_after)
bool Begin(PDFDoc &doc, const UString &pattern, Mode mode, int start_page=-1, int end_page=-1)
void SetRightToLeftLanguage(bool flag)
void SetMode(Mode mode)
bool SetPattern(const UString &pattern)
void SetOCGContext(OCG::Context *context)
void SetAmbientWordsAfter(int ambient_words_after)
void SetAmbientWordsBefore(int ambient_words_before)