xref: /aosp_15_r20/external/pdfium/public/fpdf_text.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2014 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef PUBLIC_FPDF_TEXT_H_
8 #define PUBLIC_FPDF_TEXT_H_
9 
10 // clang-format off
11 // NOLINTNEXTLINE(build/include)
12 #include "fpdfview.h"
13 
14 // Exported Functions
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 // Function: FPDFText_LoadPage
20 //          Prepare information about all characters in a page.
21 // Parameters:
22 //          page    -   Handle to the page. Returned by FPDF_LoadPage function
23 //                      (in FPDFVIEW module).
24 // Return value:
25 //          A handle to the text page information structure.
26 //          NULL if something goes wrong.
27 // Comments:
28 //          Application must call FPDFText_ClosePage to release the text page
29 //          information.
30 //
31 FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page);
32 
33 // Function: FPDFText_ClosePage
34 //          Release all resources allocated for a text page information
35 //          structure.
36 // Parameters:
37 //          text_page   -   Handle to a text page information structure.
38 //                          Returned by FPDFText_LoadPage function.
39 // Return Value:
40 //          None.
41 //
42 FPDF_EXPORT void FPDF_CALLCONV FPDFText_ClosePage(FPDF_TEXTPAGE text_page);
43 
44 // Function: FPDFText_CountChars
45 //          Get number of characters in a page.
46 // Parameters:
47 //          text_page   -   Handle to a text page information structure.
48 //                          Returned by FPDFText_LoadPage function.
49 // Return value:
50 //          Number of characters in the page. Return -1 for error.
51 //          Generated characters, like additional space characters, new line
52 //          characters, are also counted.
53 // Comments:
54 //          Characters in a page form a "stream", inside the stream, each
55 //          character has an index.
56 //          We will use the index parameters in many of FPDFTEXT functions. The
57 //          first character in the page
58 //          has an index value of zero.
59 //
60 FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountChars(FPDF_TEXTPAGE text_page);
61 
62 // Function: FPDFText_GetUnicode
63 //          Get Unicode of a character in a page.
64 // Parameters:
65 //          text_page   -   Handle to a text page information structure.
66 //                          Returned by FPDFText_LoadPage function.
67 //          index       -   Zero-based index of the character.
68 // Return value:
69 //          The Unicode of the particular character.
70 //          If a character is not encoded in Unicode and Foxit engine can't
71 //          convert to Unicode,
72 //          the return value will be zero.
73 //
74 FPDF_EXPORT unsigned int FPDF_CALLCONV
75 FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index);
76 
77 // Experimental API.
78 // Function: FPDFText_IsGenerated
79 //          Get if a character in a page is generated by PDFium.
80 // Parameters:
81 //          text_page   -   Handle to a text page information structure.
82 //                          Returned by FPDFText_LoadPage function.
83 //          index       -   Zero-based index of the character.
84 // Return value:
85 //          1 if the character is generated by PDFium.
86 //          0 if the character is not generated by PDFium.
87 //          -1 if there was an error.
88 //
89 FPDF_EXPORT int FPDF_CALLCONV
90 FPDFText_IsGenerated(FPDF_TEXTPAGE text_page, int index);
91 
92 // Experimental API.
93 // Function: FPDFText_HasUnicodeMapError
94 //          Get if a character in a page has an invalid unicode mapping.
95 // Parameters:
96 //          text_page   -   Handle to a text page information structure.
97 //                          Returned by FPDFText_LoadPage function.
98 //          index       -   Zero-based index of the character.
99 // Return value:
100 //          1 if the character has an invalid unicode mapping.
101 //          0 if the character has no known unicode mapping issues.
102 //          -1 if there was an error.
103 //
104 FPDF_EXPORT int FPDF_CALLCONV
105 FPDFText_HasUnicodeMapError(FPDF_TEXTPAGE text_page, int index);
106 
107 // Function: FPDFText_GetFontSize
108 //          Get the font size of a particular character.
109 // Parameters:
110 //          text_page   -   Handle to a text page information structure.
111 //                          Returned by FPDFText_LoadPage function.
112 //          index       -   Zero-based index of the character.
113 // Return value:
114 //          The font size of the particular character, measured in points (about
115 //          1/72 inch). This is the typographic size of the font (so called
116 //          "em size").
117 //
118 FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
119                                                       int index);
120 
121 // Experimental API.
122 // Function: FPDFText_GetFontInfo
123 //          Get the font name and flags of a particular character.
124 // Parameters:
125 //          text_page - Handle to a text page information structure.
126 //                      Returned by FPDFText_LoadPage function.
127 //          index     - Zero-based index of the character.
128 //          buffer    - A buffer receiving the font name.
129 //          buflen    - The length of |buffer| in bytes.
130 //          flags     - Optional pointer to an int receiving the font flags.
131 //                      These flags should be interpreted per PDF spec 1.7
132 //                      Section 5.7.1 Font Descriptor Flags.
133 // Return value:
134 //          On success, return the length of the font name, including the
135 //          trailing NUL character, in bytes. If this length is less than or
136 //          equal to |length|, |buffer| is set to the font name, |flags| is
137 //          set to the font flags. |buffer| is in UTF-8 encoding. Return 0 on
138 //          failure.
139 //
140 FPDF_EXPORT unsigned long FPDF_CALLCONV
141 FPDFText_GetFontInfo(FPDF_TEXTPAGE text_page,
142                      int index,
143                      void* buffer,
144                      unsigned long buflen,
145                      int* flags);
146 
147 // Experimental API.
148 // Function: FPDFText_GetFontWeight
149 //          Get the font weight of a particular character.
150 // Parameters:
151 //          text_page   -   Handle to a text page information structure.
152 //                          Returned by FPDFText_LoadPage function.
153 //          index       -   Zero-based index of the character.
154 // Return value:
155 //          On success, return the font weight of the particular character. If
156 //          |text_page| is invalid, if |index| is out of bounds, or if the
157 //          character's text object is undefined, return -1.
158 //
159 FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetFontWeight(FPDF_TEXTPAGE text_page,
160                                                      int index);
161 
162 // Experimental API.
163 // Function: FPDFText_GetTextRenderMode
164 //          Get text rendering mode of character.
165 // Parameters:
166 //          text_page   -   Handle to a text page information structure.
167 //                          Returned by FPDFText_LoadPage function.
168 //          index       -   Zero-based index of the character.
169 // Return Value:
170 //          On success, return the render mode value. A valid value is of type
171 //          FPDF_TEXT_RENDERMODE. If |text_page| is invalid, if |index| is out
172 //          of bounds, or if the text object is undefined, then return
173 //          FPDF_TEXTRENDERMODE_UNKNOWN.
174 //
175 FPDF_EXPORT FPDF_TEXT_RENDERMODE FPDF_CALLCONV
176 FPDFText_GetTextRenderMode(FPDF_TEXTPAGE text_page, int index);
177 
178 // Experimental API.
179 // Function: FPDFText_GetFillColor
180 //          Get the fill color of a particular character.
181 // Parameters:
182 //          text_page      -   Handle to a text page information structure.
183 //                             Returned by FPDFText_LoadPage function.
184 //          index          -   Zero-based index of the character.
185 //          R              -   Pointer to an unsigned int number receiving the
186 //                             red value of the fill color.
187 //          G              -   Pointer to an unsigned int number receiving the
188 //                             green value of the fill color.
189 //          B              -   Pointer to an unsigned int number receiving the
190 //                             blue value of the fill color.
191 //          A              -   Pointer to an unsigned int number receiving the
192 //                             alpha value of the fill color.
193 // Return value:
194 //          Whether the call succeeded. If false, |R|, |G|, |B| and |A| are
195 //          unchanged.
196 //
197 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
198 FPDFText_GetFillColor(FPDF_TEXTPAGE text_page,
199                       int index,
200                       unsigned int* R,
201                       unsigned int* G,
202                       unsigned int* B,
203                       unsigned int* A);
204 
205 // Experimental API.
206 // Function: FPDFText_GetStrokeColor
207 //          Get the stroke color of a particular character.
208 // Parameters:
209 //          text_page      -   Handle to a text page information structure.
210 //                             Returned by FPDFText_LoadPage function.
211 //          index          -   Zero-based index of the character.
212 //          R              -   Pointer to an unsigned int number receiving the
213 //                             red value of the stroke color.
214 //          G              -   Pointer to an unsigned int number receiving the
215 //                             green value of the stroke color.
216 //          B              -   Pointer to an unsigned int number receiving the
217 //                             blue value of the stroke color.
218 //          A              -   Pointer to an unsigned int number receiving the
219 //                             alpha value of the stroke color.
220 // Return value:
221 //          Whether the call succeeded. If false, |R|, |G|, |B| and |A| are
222 //          unchanged.
223 //
224 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
225 FPDFText_GetStrokeColor(FPDF_TEXTPAGE text_page,
226                         int index,
227                         unsigned int* R,
228                         unsigned int* G,
229                         unsigned int* B,
230                         unsigned int* A);
231 
232 // Experimental API.
233 // Function: FPDFText_GetCharAngle
234 //          Get character rotation angle.
235 // Parameters:
236 //          text_page   -   Handle to a text page information structure.
237 //                          Returned by FPDFText_LoadPage function.
238 //          index       -   Zero-based index of the character.
239 // Return Value:
240 //          On success, return the angle value in radian. Value will always be
241 //          greater or equal to 0. If |text_page| is invalid, or if |index| is
242 //          out of bounds, then return -1.
243 //
244 FPDF_EXPORT float FPDF_CALLCONV FPDFText_GetCharAngle(FPDF_TEXTPAGE text_page,
245                                                       int index);
246 
247 // Function: FPDFText_GetCharBox
248 //          Get bounding box of a particular character.
249 // Parameters:
250 //          text_page   -   Handle to a text page information structure.
251 //                          Returned by FPDFText_LoadPage function.
252 //          index       -   Zero-based index of the character.
253 //          left        -   Pointer to a double number receiving left position
254 //                          of the character box.
255 //          right       -   Pointer to a double number receiving right position
256 //                          of the character box.
257 //          bottom      -   Pointer to a double number receiving bottom position
258 //                          of the character box.
259 //          top         -   Pointer to a double number receiving top position of
260 //                          the character box.
261 // Return Value:
262 //          On success, return TRUE and fill in |left|, |right|, |bottom|, and
263 //          |top|. If |text_page| is invalid, or if |index| is out of bounds,
264 //          then return FALSE, and the out parameters remain unmodified.
265 // Comments:
266 //          All positions are measured in PDF "user space".
267 //
268 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page,
269                                                         int index,
270                                                         double* left,
271                                                         double* right,
272                                                         double* bottom,
273                                                         double* top);
274 
275 // Experimental API.
276 // Function: FPDFText_GetLooseCharBox
277 //          Get a "loose" bounding box of a particular character, i.e., covering
278 //          the entire glyph bounds, without taking the actual glyph shape into
279 //          account.
280 // Parameters:
281 //          text_page   -   Handle to a text page information structure.
282 //                          Returned by FPDFText_LoadPage function.
283 //          index       -   Zero-based index of the character.
284 //          rect        -   Pointer to a FS_RECTF receiving the character box.
285 // Return Value:
286 //          On success, return TRUE and fill in |rect|. If |text_page| is
287 //          invalid, or if |index| is out of bounds, then return FALSE, and the
288 //          |rect| out parameter remains unmodified.
289 // Comments:
290 //          All positions are measured in PDF "user space".
291 //
292 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
293 FPDFText_GetLooseCharBox(FPDF_TEXTPAGE text_page, int index, FS_RECTF* rect);
294 
295 // Experimental API.
296 // Function: FPDFText_GetMatrix
297 //          Get the effective transformation matrix for a particular character.
298 // Parameters:
299 //          text_page   -   Handle to a text page information structure.
300 //                          Returned by FPDFText_LoadPage().
301 //          index       -   Zero-based index of the character.
302 //          matrix      -   Pointer to a FS_MATRIX receiving the transformation
303 //                          matrix.
304 // Return Value:
305 //          On success, return TRUE and fill in |matrix|. If |text_page| is
306 //          invalid, or if |index| is out of bounds, or if |matrix| is NULL,
307 //          then return FALSE, and |matrix| remains unmodified.
308 //
309 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_TEXTPAGE text_page,
310                                                        int index,
311                                                        FS_MATRIX* matrix);
312 
313 // Function: FPDFText_GetCharOrigin
314 //          Get origin of a particular character.
315 // Parameters:
316 //          text_page   -   Handle to a text page information structure.
317 //                          Returned by FPDFText_LoadPage function.
318 //          index       -   Zero-based index of the character.
319 //          x           -   Pointer to a double number receiving x coordinate of
320 //                          the character origin.
321 //          y           -   Pointer to a double number receiving y coordinate of
322 //                          the character origin.
323 // Return Value:
324 //          Whether the call succeeded. If false, x and y are unchanged.
325 // Comments:
326 //          All positions are measured in PDF "user space".
327 //
328 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
329 FPDFText_GetCharOrigin(FPDF_TEXTPAGE text_page,
330                        int index,
331                        double* x,
332                        double* y);
333 
334 // Function: FPDFText_GetCharIndexAtPos
335 //          Get the index of a character at or nearby a certain position on the
336 //          page.
337 // Parameters:
338 //          text_page   -   Handle to a text page information structure.
339 //                          Returned by FPDFText_LoadPage function.
340 //          x           -   X position in PDF "user space".
341 //          y           -   Y position in PDF "user space".
342 //          xTolerance  -   An x-axis tolerance value for character hit
343 //                          detection, in point units.
344 //          yTolerance  -   A y-axis tolerance value for character hit
345 //                          detection, in point units.
346 // Return Value:
347 //          The zero-based index of the character at, or nearby the point (x,y).
348 //          If there is no character at or nearby the point, return value will
349 //          be -1. If an error occurs, -3 will be returned.
350 //
351 FPDF_EXPORT int FPDF_CALLCONV
352 FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page,
353                            double x,
354                            double y,
355                            double xTolerance,
356                            double yTolerance);
357 
358 // Function: FPDFText_GetText
359 //          Extract unicode text string from the page.
360 // Parameters:
361 //          text_page   -   Handle to a text page information structure.
362 //                          Returned by FPDFText_LoadPage function.
363 //          start_index -   Index for the start characters.
364 //          count       -   Number of characters to be extracted.
365 //          result      -   A buffer (allocated by application) receiving the
366 //                          extracted unicodes. The size of the buffer must be
367 //                          able to hold the number of characters plus a
368 //                          terminator.
369 // Return Value:
370 //          Number of characters written into the result buffer, including the
371 //          trailing terminator.
372 // Comments:
373 //          This function ignores characters without unicode information.
374 //          It returns all characters on the page, even those that are not
375 //          visible when the page has a cropbox. To filter out the characters
376 //          outside of the cropbox, use FPDF_GetPageBoundingBox() and
377 //          FPDFText_GetCharBox().
378 //
379 FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page,
380                                                int start_index,
381                                                int count,
382                                                unsigned short* result);
383 
384 // Function: FPDFText_CountRects
385 //          Counts number of rectangular areas occupied by a segment of text,
386 //          and caches the result for subsequent FPDFText_GetRect() calls.
387 // Parameters:
388 //          text_page   -   Handle to a text page information structure.
389 //                          Returned by FPDFText_LoadPage function.
390 //          start_index -   Index for the start character.
391 //          count       -   Number of characters, or -1 for all remaining.
392 // Return value:
393 //          Number of rectangles, 0 if text_page is null, or -1 on bad
394 //          start_index.
395 // Comments:
396 //          This function, along with FPDFText_GetRect can be used by
397 //          applications to detect the position on the page for a text segment,
398 //          so proper areas can be highlighted. The FPDFText_* functions will
399 //          automatically merge small character boxes into bigger one if those
400 //          characters are on the same line and use same font settings.
401 //
402 FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountRects(FPDF_TEXTPAGE text_page,
403                                                   int start_index,
404                                                   int count);
405 
406 // Function: FPDFText_GetRect
407 //          Get a rectangular area from the result generated by
408 //          FPDFText_CountRects.
409 // Parameters:
410 //          text_page   -   Handle to a text page information structure.
411 //                          Returned by FPDFText_LoadPage function.
412 //          rect_index  -   Zero-based index for the rectangle.
413 //          left        -   Pointer to a double value receiving the rectangle
414 //                          left boundary.
415 //          top         -   Pointer to a double value receiving the rectangle
416 //                          top boundary.
417 //          right       -   Pointer to a double value receiving the rectangle
418 //                          right boundary.
419 //          bottom      -   Pointer to a double value receiving the rectangle
420 //                          bottom boundary.
421 // Return Value:
422 //          On success, return TRUE and fill in |left|, |top|, |right|, and
423 //          |bottom|. If |text_page| is invalid then return FALSE, and the out
424 //          parameters remain unmodified. If |text_page| is valid but
425 //          |rect_index| is out of bounds, then return FALSE and set the out
426 //          parameters to 0.
427 //
428 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetRect(FPDF_TEXTPAGE text_page,
429                                                      int rect_index,
430                                                      double* left,
431                                                      double* top,
432                                                      double* right,
433                                                      double* bottom);
434 
435 // Function: FPDFText_GetBoundedText
436 //          Extract unicode text within a rectangular boundary on the page.
437 // Parameters:
438 //          text_page   -   Handle to a text page information structure.
439 //                          Returned by FPDFText_LoadPage function.
440 //          left        -   Left boundary.
441 //          top         -   Top boundary.
442 //          right       -   Right boundary.
443 //          bottom      -   Bottom boundary.
444 //          buffer      -   A unicode buffer.
445 //          buflen      -   Number of characters (not bytes) for the buffer,
446 //                          excluding an additional terminator.
447 // Return Value:
448 //          If buffer is NULL or buflen is zero, return number of characters
449 //          (not bytes) of text present within the rectangle, excluding a
450 //          terminating NUL. Generally you should pass a buffer at least one
451 //          larger than this if you want a terminating NUL, which will be
452 //          provided if space is available. Otherwise, return number of
453 //          characters copied into the buffer, including the terminating NUL
454 //          when space for it is available.
455 // Comment:
456 //          If the buffer is too small, as much text as will fit is copied into
457 //          it.
458 //
459 FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page,
460                                                       double left,
461                                                       double top,
462                                                       double right,
463                                                       double bottom,
464                                                       unsigned short* buffer,
465                                                       int buflen);
466 
467 // Flags used by FPDFText_FindStart function.
468 //
469 // If not set, it will not match case by default.
470 #define FPDF_MATCHCASE 0x00000001
471 // If not set, it will not match the whole word by default.
472 #define FPDF_MATCHWHOLEWORD 0x00000002
473 // If not set, it will skip past the current match to look for the next match.
474 #define FPDF_CONSECUTIVE 0x00000004
475 
476 // Function: FPDFText_FindStart
477 //          Start a search.
478 // Parameters:
479 //          text_page   -   Handle to a text page information structure.
480 //                          Returned by FPDFText_LoadPage function.
481 //          findwhat    -   A unicode match pattern.
482 //          flags       -   Option flags.
483 //          start_index -   Start from this character. -1 for end of the page.
484 // Return Value:
485 //          A handle for the search context. FPDFText_FindClose must be called
486 //          to release this handle.
487 //
488 FPDF_EXPORT FPDF_SCHHANDLE FPDF_CALLCONV
489 FPDFText_FindStart(FPDF_TEXTPAGE text_page,
490                    FPDF_WIDESTRING findwhat,
491                    unsigned long flags,
492                    int start_index);
493 
494 // Function: FPDFText_FindNext
495 //          Search in the direction from page start to end.
496 // Parameters:
497 //          handle      -   A search context handle returned by
498 //                          FPDFText_FindStart.
499 // Return Value:
500 //          Whether a match is found.
501 //
502 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindNext(FPDF_SCHHANDLE handle);
503 
504 // Function: FPDFText_FindPrev
505 //          Search in the direction from page end to start.
506 // Parameters:
507 //          handle      -   A search context handle returned by
508 //                          FPDFText_FindStart.
509 // Return Value:
510 //          Whether a match is found.
511 //
512 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindPrev(FPDF_SCHHANDLE handle);
513 
514 // Function: FPDFText_GetSchResultIndex
515 //          Get the starting character index of the search result.
516 // Parameters:
517 //          handle      -   A search context handle returned by
518 //                          FPDFText_FindStart.
519 // Return Value:
520 //          Index for the starting character.
521 //
522 FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle);
523 
524 // Function: FPDFText_GetSchCount
525 //          Get the number of matched characters in the search result.
526 // Parameters:
527 //          handle      -   A search context handle returned by
528 //                          FPDFText_FindStart.
529 // Return Value:
530 //          Number of matched characters.
531 //
532 FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchCount(FPDF_SCHHANDLE handle);
533 
534 // Function: FPDFText_FindClose
535 //          Release a search context.
536 // Parameters:
537 //          handle      -   A search context handle returned by
538 //                          FPDFText_FindStart.
539 // Return Value:
540 //          None.
541 //
542 FPDF_EXPORT void FPDF_CALLCONV FPDFText_FindClose(FPDF_SCHHANDLE handle);
543 
544 // Function: FPDFLink_LoadWebLinks
545 //          Prepare information about weblinks in a page.
546 // Parameters:
547 //          text_page   -   Handle to a text page information structure.
548 //                          Returned by FPDFText_LoadPage function.
549 // Return Value:
550 //          A handle to the page's links information structure, or
551 //          NULL if something goes wrong.
552 // Comments:
553 //          Weblinks are those links implicitly embedded in PDF pages. PDF also
554 //          has a type of annotation called "link" (FPDFTEXT doesn't deal with
555 //          that kind of link). FPDFTEXT weblink feature is useful for
556 //          automatically detecting links in the page contents. For example,
557 //          things like "https://www.example.com" will be detected, so
558 //          applications can allow user to click on those characters to activate
559 //          the link, even the PDF doesn't come with link annotations.
560 //
561 //          FPDFLink_CloseWebLinks must be called to release resources.
562 //
563 FPDF_EXPORT FPDF_PAGELINK FPDF_CALLCONV
564 FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page);
565 
566 // Function: FPDFLink_CountWebLinks
567 //          Count number of detected web links.
568 // Parameters:
569 //          link_page   -   Handle returned by FPDFLink_LoadWebLinks.
570 // Return Value:
571 //          Number of detected web links.
572 //
573 FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountWebLinks(FPDF_PAGELINK link_page);
574 
575 // Function: FPDFLink_GetURL
576 //          Fetch the URL information for a detected web link.
577 // Parameters:
578 //          link_page   -   Handle returned by FPDFLink_LoadWebLinks.
579 //          link_index  -   Zero-based index for the link.
580 //          buffer      -   A unicode buffer for the result.
581 //          buflen      -   Number of 16-bit code units (not bytes) for the
582 //                          buffer, including an additional terminator.
583 // Return Value:
584 //          If |buffer| is NULL or |buflen| is zero, return the number of 16-bit
585 //          code units (not bytes) needed to buffer the result (an additional
586 //          terminator is included in this count).
587 //          Otherwise, copy the result into |buffer|, truncating at |buflen| if
588 //          the result is too large to fit, and return the number of 16-bit code
589 //          units actually copied into the buffer (the additional terminator is
590 //          also included in this count).
591 //          If |link_index| does not correspond to a valid link, then the result
592 //          is an empty string.
593 //
594 FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetURL(FPDF_PAGELINK link_page,
595                                               int link_index,
596                                               unsigned short* buffer,
597                                               int buflen);
598 
599 // Function: FPDFLink_CountRects
600 //          Count number of rectangular areas for the link.
601 // Parameters:
602 //          link_page   -   Handle returned by FPDFLink_LoadWebLinks.
603 //          link_index  -   Zero-based index for the link.
604 // Return Value:
605 //          Number of rectangular areas for the link.  If |link_index| does
606 //          not correspond to a valid link, then 0 is returned.
607 //
608 FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountRects(FPDF_PAGELINK link_page,
609                                                   int link_index);
610 
611 // Function: FPDFLink_GetRect
612 //          Fetch the boundaries of a rectangle for a link.
613 // Parameters:
614 //          link_page   -   Handle returned by FPDFLink_LoadWebLinks.
615 //          link_index  -   Zero-based index for the link.
616 //          rect_index  -   Zero-based index for a rectangle.
617 //          left        -   Pointer to a double value receiving the rectangle
618 //                          left boundary.
619 //          top         -   Pointer to a double value receiving the rectangle
620 //                          top boundary.
621 //          right       -   Pointer to a double value receiving the rectangle
622 //                          right boundary.
623 //          bottom      -   Pointer to a double value receiving the rectangle
624 //                          bottom boundary.
625 // Return Value:
626 //          On success, return TRUE and fill in |left|, |top|, |right|, and
627 //          |bottom|. If |link_page| is invalid or if |link_index| does not
628 //          correspond to a valid link, then return FALSE, and the out
629 //          parameters remain unmodified.
630 //
631 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetRect(FPDF_PAGELINK link_page,
632                                                      int link_index,
633                                                      int rect_index,
634                                                      double* left,
635                                                      double* top,
636                                                      double* right,
637                                                      double* bottom);
638 
639 // Experimental API.
640 // Function: FPDFLink_GetTextRange
641 //          Fetch the start char index and char count for a link.
642 // Parameters:
643 //          link_page         -   Handle returned by FPDFLink_LoadWebLinks.
644 //          link_index        -   Zero-based index for the link.
645 //          start_char_index  -   pointer to int receiving the start char index
646 //          char_count        -   pointer to int receiving the char count
647 // Return Value:
648 //          On success, return TRUE and fill in |start_char_index| and
649 //          |char_count|. if |link_page| is invalid or if |link_index| does
650 //          not correspond to a valid link, then return FALSE and the out
651 //          parameters remain unmodified.
652 //
653 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
654 FPDFLink_GetTextRange(FPDF_PAGELINK link_page,
655                       int link_index,
656                       int* start_char_index,
657                       int* char_count);
658 
659 // Function: FPDFLink_CloseWebLinks
660 //          Release resources used by weblink feature.
661 // Parameters:
662 //          link_page   -   Handle returned by FPDFLink_LoadWebLinks.
663 // Return Value:
664 //          None.
665 //
666 FPDF_EXPORT void FPDF_CALLCONV FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page);
667 
668 #ifdef __cplusplus
669 }
670 #endif
671 
672 #endif  // PUBLIC_FPDF_TEXT_H_
673