John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 7 | #ifndef PUBLIC_FPDF_TEXT_H_ |
| 8 | #define PUBLIC_FPDF_TEXT_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
| 10 | #include "fpdfview.h" |
| 11 | |
| 12 | // Exported Functions |
| 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | // Function: FPDFText_LoadPage |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 18 | // Prepare information about all characters in a page. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 19 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 20 | // page - Handle to the page. Returned by FPDF_LoadPage function |
| 21 | // (in FPDFVIEW module). |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 22 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 23 | // A handle to the text page information structure. |
| 24 | // NULL if something goes wrong. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 25 | // Comments: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 26 | // Application must call FPDFText_ClosePage to release the text page |
| 27 | // information. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 28 | // |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 29 | DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 30 | |
| 31 | // Function: FPDFText_ClosePage |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 32 | // Release all resources allocated for a text page information |
| 33 | // structure. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 34 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 35 | // text_page - Handle to a text page information structure. |
| 36 | // Returned by FPDFText_LoadPage function. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 37 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 38 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 39 | // |
| 40 | DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page); |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 41 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 42 | // Function: FPDFText_CountChars |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 43 | // Get number of characters in a page. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 44 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 45 | // text_page - Handle to a text page information structure. |
| 46 | // Returned by FPDFText_LoadPage function. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 47 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 48 | // Number of characters in the page. Return -1 for error. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 49 | // Generated characters, like additional space characters, new line |
| 50 | // characters, are also counted. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 51 | // Comments: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 52 | // Characters in a page form a "stream", inside the stream, each |
| 53 | // character has an index. |
| 54 | // We will use the index parameters in many of FPDFTEXT functions. The |
| 55 | // first character in the page |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 56 | // has an index value of zero. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 57 | // |
| 58 | DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); |
| 59 | |
| 60 | // Function: FPDFText_GetUnicode |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 61 | // Get Unicode of a character in a page. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 62 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 63 | // text_page - Handle to a text page information structure. |
| 64 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 65 | // index - Zero-based index of the character. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 66 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 67 | // The Unicode of the particular character. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 68 | // If a character is not encoded in Unicode and Foxit engine can't |
| 69 | // convert to Unicode, |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 70 | // the return value will be zero. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 71 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 72 | DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, |
| 73 | int index); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 74 | |
| 75 | // Function: FPDFText_GetFontSize |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 76 | // Get the font size of a particular character. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 77 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 78 | // text_page - Handle to a text page information structure. |
| 79 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 80 | // index - Zero-based index of the character. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 81 | // Return value: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 82 | // The font size of the particular character, measured in points (about |
| 83 | // 1/72 inch). |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 84 | // This is the typographic size of the font (so called "em size"). |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 85 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 86 | DLLEXPORT double STDCALL FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, |
| 87 | int index); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 88 | |
| 89 | // Function: FPDFText_GetCharBox |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 90 | // Get bounding box of a particular character. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 91 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 92 | // text_page - Handle to a text page information structure. |
| 93 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 94 | // index - Zero-based index of the character. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 95 | // left - Pointer to a double number receiving left position |
| 96 | // of the character box. |
| 97 | // right - Pointer to a double number receiving right position |
| 98 | // of the character box. |
| 99 | // bottom - Pointer to a double number receiving bottom position |
| 100 | // of the character box. |
| 101 | // top - Pointer to a double number receiving top position of |
| 102 | // the character box. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 103 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 104 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 105 | // Comments: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 106 | // All positions are measured in PDF "user space". |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 107 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 108 | DLLEXPORT void STDCALL FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, |
| 109 | int index, |
| 110 | double* left, |
| 111 | double* right, |
| 112 | double* bottom, |
| 113 | double* top); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 114 | |
| 115 | // Function: FPDFText_GetCharIndexAtPos |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 116 | // Get the index of a character at or nearby a certain position on the |
| 117 | // page. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 118 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 119 | // text_page - Handle to a text page information structure. |
| 120 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 121 | // x - X position in PDF "user space". |
| 122 | // y - Y position in PDF "user space". |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 123 | // xTolerance - An x-axis tolerance value for character hit |
| 124 | // detection, in point unit. |
| 125 | // yTolerance - A y-axis tolerance value for character hit |
| 126 | // detection, in point unit. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 127 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 128 | // The zero-based index of the character at, or nearby the point (x,y). |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 129 | // If there is no character at or nearby the point, return value will |
| 130 | // be -1. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 131 | // If an error occurs, -3 will be returned. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 132 | // |
| 133 | DLLEXPORT int STDCALL FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 134 | double x, |
| 135 | double y, |
Lei Zhang | 38a5a39 | 2015-08-13 17:52:16 -0700 | [diff] [blame] | 136 | double xTolerance, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 137 | double yTolerance); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 138 | |
| 139 | // Function: FPDFText_GetText |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 140 | // Extract unicode text string from the page. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 141 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 142 | // text_page - Handle to a text page information structure. |
| 143 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 144 | // start_index - Index for the start characters. |
| 145 | // count - Number of characters to be extracted. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 146 | // result - A buffer (allocated by application) receiving the |
| 147 | // extracted unicodes. |
| 148 | // The size of the buffer must be able to hold the |
| 149 | // number of characters plus a terminator. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 150 | // Return Value: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 151 | // Number of characters written into the result buffer, including the |
| 152 | // trailing terminator. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 153 | // Comments: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 154 | // This function ignores characters without unicode information. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 155 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 156 | DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, |
| 157 | int start_index, |
| 158 | int count, |
| 159 | unsigned short* result); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 160 | |
| 161 | // Function: FPDFText_CountRects |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 162 | // Count number of rectangular areas occupied by a segment of texts. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 163 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 164 | // text_page - Handle to a text page information structure. |
| 165 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 166 | // start_index - Index for the start characters. |
| 167 | // count - Number of characters. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 168 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 169 | // Number of rectangles. Zero for error. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 170 | // Comments: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 171 | // This function, along with FPDFText_GetRect can be used by |
| 172 | // applications to detect the position |
| 173 | // on the page for a text segment, so proper areas can be highlighted |
| 174 | // or something. |
| 175 | // FPDFTEXT will automatically merge small character boxes into bigger |
| 176 | // one if those characters |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 177 | // are on the same line and use same font settings. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 178 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 179 | DLLEXPORT int STDCALL FPDFText_CountRects(FPDF_TEXTPAGE text_page, |
| 180 | int start_index, |
| 181 | int count); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 182 | |
| 183 | // Function: FPDFText_GetRect |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 184 | // Get a rectangular area from the result generated by |
| 185 | // FPDFText_CountRects. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 186 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 187 | // text_page - Handle to a text page information structure. |
| 188 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 189 | // rect_index - Zero-based index for the rectangle. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 190 | // left - Pointer to a double value receiving the rectangle |
| 191 | // left boundary. |
| 192 | // top - Pointer to a double value receiving the rectangle |
| 193 | // top boundary. |
| 194 | // right - Pointer to a double value receiving the rectangle |
| 195 | // right boundary. |
| 196 | // bottom - Pointer to a double value receiving the rectangle |
| 197 | // bottom boundary. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 198 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 199 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 200 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 201 | DLLEXPORT void STDCALL FPDFText_GetRect(FPDF_TEXTPAGE text_page, |
| 202 | int rect_index, |
| 203 | double* left, |
| 204 | double* top, |
| 205 | double* right, |
| 206 | double* bottom); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 207 | |
| 208 | // Function: FPDFText_GetBoundedText |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 209 | // Extract unicode text within a rectangular boundary on the page. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 210 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 211 | // text_page - Handle to a text page information structure. |
| 212 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 213 | // left - Left boundary. |
| 214 | // top - Top boundary. |
| 215 | // right - Right boundary. |
| 216 | // bottom - Bottom boundary. |
| 217 | // buffer - A unicode buffer. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 218 | // buflen - Number of characters (not bytes) for the buffer, |
| 219 | // excluding an additional terminator. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 220 | // Return Value: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 221 | // If buffer is NULL or buflen is zero, return number of characters |
| 222 | // (not bytes) of text present within |
| 223 | // the rectangle, excluding a terminating NUL. Generally you should |
| 224 | // pass a buffer at least one larger |
| 225 | // than this if you want a terminating NUL, which will be provided if |
| 226 | // space is available. |
| 227 | // Otherwise, return number of characters copied into the buffer, |
| 228 | // including the terminating NUL |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 229 | // when space for it is available. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 230 | // Comment: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 231 | // If the buffer is too small, as much text as will fit is copied into |
| 232 | // it. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 233 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 234 | DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, |
| 235 | double left, |
| 236 | double top, |
| 237 | double right, |
| 238 | double bottom, |
| 239 | unsigned short* buffer, |
| 240 | int buflen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 241 | |
| 242 | // Flags used by FPDFText_FindStart function. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 243 | #define FPDF_MATCHCASE \ |
| 244 | 0x00000001 // If not set, it will not match case by default. |
| 245 | #define FPDF_MATCHWHOLEWORD \ |
| 246 | 0x00000002 // If not set, it will not match the whole word by default. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 247 | |
| 248 | // Function: FPDFText_FindStart |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 249 | // Start a search. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 250 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 251 | // text_page - Handle to a text page information structure. |
| 252 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 253 | // findwhat - A unicode match pattern. |
| 254 | // flags - Option flags. |
| 255 | // start_index - Start from this character. -1 for end of the page. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 256 | // Return Value: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 257 | // A handle for the search context. FPDFText_FindClose must be called |
| 258 | // to release this handle. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 259 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 260 | DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page, |
| 261 | FPDF_WIDESTRING findwhat, |
| 262 | unsigned long flags, |
| 263 | int start_index); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 264 | |
| 265 | // Function: FPDFText_FindNext |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 266 | // Search in the direction from page start to end. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 267 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 268 | // handle - A search context handle returned by |
| 269 | // FPDFText_FindStart. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 270 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 271 | // Whether a match is found. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 272 | // |
| 273 | DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle); |
| 274 | |
| 275 | // Function: FPDFText_FindPrev |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 276 | // Search in the direction from page end to start. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 277 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 278 | // handle - A search context handle returned by |
| 279 | // FPDFText_FindStart. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 280 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 281 | // Whether a match is found. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 282 | // |
| 283 | DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindPrev(FPDF_SCHHANDLE handle); |
| 284 | |
| 285 | // Function: FPDFText_GetSchResultIndex |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 286 | // Get the starting character index of the search result. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 287 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 288 | // handle - A search context handle returned by |
| 289 | // FPDFText_FindStart. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 290 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 291 | // Index for the starting character. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 292 | // |
| 293 | DLLEXPORT int STDCALL FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle); |
| 294 | |
| 295 | // Function: FPDFText_GetSchCount |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 296 | // Get the number of matched characters in the search result. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 297 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 298 | // handle - A search context handle returned by |
| 299 | // FPDFText_FindStart. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 300 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 301 | // Number of matched characters. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 302 | // |
| 303 | DLLEXPORT int STDCALL FPDFText_GetSchCount(FPDF_SCHHANDLE handle); |
| 304 | |
| 305 | // Function: FPDFText_FindClose |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 306 | // Release a search context. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 307 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 308 | // handle - A search context handle returned by |
| 309 | // FPDFText_FindStart. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 310 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 311 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 312 | // |
| 313 | DLLEXPORT void STDCALL FPDFText_FindClose(FPDF_SCHHANDLE handle); |
| 314 | |
| 315 | // Function: FPDFLink_LoadWebLinks |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 316 | // Prepare information about weblinks in a page. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 317 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 318 | // text_page - Handle to a text page information structure. |
| 319 | // Returned by FPDFText_LoadPage function. |
Tom Sepez | 526f6d5 | 2015-01-28 15:49:13 -0800 | [diff] [blame] | 320 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 321 | // A handle to the page's links information structure. |
| 322 | // NULL if something goes wrong. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 323 | // Comments: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 324 | // Weblinks are those links implicitly embedded in PDF pages. PDF also |
| 325 | // has a type of |
| 326 | // annotation called "link", FPDFTEXT doesn't deal with that kind of |
| 327 | // link. |
| 328 | // FPDFTEXT weblink feature is useful for automatically detecting links |
| 329 | // in the page |
| 330 | // contents. For example, things like "http://www.foxitsoftware.com" |
| 331 | // will be detected, |
| 332 | // so applications can allow user to click on those characters to |
| 333 | // activate the link, |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 334 | // even the PDF doesn't come with link annotations. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 335 | // |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 336 | // FPDFLink_CloseWebLinks must be called to release resources. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 337 | // |
| 338 | DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); |
| 339 | |
| 340 | // Function: FPDFLink_CountWebLinks |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 341 | // Count number of detected web links. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 342 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 343 | // link_page - Handle returned by FPDFLink_LoadWebLinks. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 344 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 345 | // Number of detected web links. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 346 | // |
| 347 | DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page); |
| 348 | |
| 349 | // Function: FPDFLink_GetURL |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 350 | // Fetch the URL information for a detected web link. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 351 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 352 | // link_page - Handle returned by FPDFLink_LoadWebLinks. |
| 353 | // link_index - Zero-based index for the link. |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 354 | // buffer - A unicode buffer for the result. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 355 | // buflen - Number of characters (not bytes) for the buffer, |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 356 | // including an additional terminator. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 357 | // Return Value: |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 358 | // If |buffer| is NULL or |buflen| is zero, return the number of |
| 359 | // characters (not bytes) needed to buffer the result (an additional |
| 360 | // terminator is included in this count). |
| 361 | // Otherwise, copy the result into |buffer|, truncating at |buflen| if |
| 362 | // the result is too large to fit, and return the number of characters |
| 363 | // actually copied into the buffer (the additional terminator is also |
| 364 | // included in this count). |
| 365 | // If |link_index| does not correspond to a valid link, then the result |
| 366 | // is an empty string. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 367 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 368 | DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page, |
| 369 | int link_index, |
| 370 | unsigned short* buffer, |
| 371 | int buflen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 372 | |
| 373 | // Function: FPDFLink_CountRects |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 374 | // Count number of rectangular areas for the link. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 375 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 376 | // link_page - Handle returned by FPDFLink_LoadWebLinks. |
| 377 | // link_index - Zero-based index for the link. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 378 | // Return Value: |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 379 | // Number of rectangular areas for the link. If |link_index| does |
| 380 | // not correspond to a valid link, then 0 is returned. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 381 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 382 | DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, |
| 383 | int link_index); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 384 | |
| 385 | // Function: FPDFLink_GetRect |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 386 | // Fetch the boundaries of a rectangle for a link. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 387 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 388 | // link_page - Handle returned by FPDFLink_LoadWebLinks. |
| 389 | // link_index - Zero-based index for the link. |
| 390 | // rect_index - Zero-based index for a rectangle. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 391 | // left - Pointer to a double value receiving the rectangle |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 392 | // left boundary. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 393 | // top - Pointer to a double value receiving the rectangle |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 394 | // top boundary. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 395 | // right - Pointer to a double value receiving the rectangle |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 396 | // right boundary. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 397 | // bottom - Pointer to a double value receiving the rectangle |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 398 | // bottom boundary. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 399 | // Return Value: |
tsepez | 6914118 | 2016-04-21 10:43:39 -0700 | [diff] [blame] | 400 | // None. If |link_index| does not correspond to a valid link, then |
| 401 | // |left|, |top|, |right|, and |bottom| remain unmodified. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 402 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 403 | DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, |
| 404 | int link_index, |
| 405 | int rect_index, |
| 406 | double* left, |
| 407 | double* top, |
| 408 | double* right, |
| 409 | double* bottom); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 410 | |
| 411 | // Function: FPDFLink_CloseWebLinks |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 412 | // Release resources used by weblink feature. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 413 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 414 | // link_page - Handle returned by FPDFLink_LoadWebLinks. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 415 | // Return Value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 416 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 417 | // |
| 418 | DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page); |
| 419 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 420 | #ifdef __cplusplus |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 421 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 422 | #endif |
| 423 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 424 | #endif // PUBLIC_FPDF_TEXT_H_ |