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