blob: 043dc169c99f70d56c0dfffadd29fa2b0018e614 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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 Sepez9857e202015-05-13 17:09:26 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez9857e202015-05-13 17:09:26 -07007#ifndef PUBLIC_FPDF_TEXT_H_
8#define PUBLIC_FPDF_TEXT_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Dan Sinclair85c8e7f2016-11-21 13:50:32 -050010// NOLINTNEXTLINE(build/include)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070011#include "fpdfview.h"
12
13// Exported Functions
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18// Function: FPDFText_LoadPage
Tom Sepez9857e202015-05-13 17:09:26 -070019// Prepare information about all characters in a page.
Tom Sepez526f6d52015-01-28 15:49:13 -080020// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070021// page - Handle to the page. Returned by FPDF_LoadPage function
22// (in FPDFVIEW module).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070023// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -070024// A handle to the text page information structure.
25// NULL if something goes wrong.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070026// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070027// Application must call FPDFText_ClosePage to release the text page
28// information.
Tom Sepez526f6d52015-01-28 15:49:13 -080029//
Dan Sinclair00d2ad12017-08-10 14:13:02 -040030FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070031
32// Function: FPDFText_ClosePage
Nico Weber9d8ec5a2015-08-04 13:00:21 -070033// Release all resources allocated for a text page information
34// structure.
Tom Sepez526f6d52015-01-28 15:49:13 -080035// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070036// text_page - Handle to a text page information structure.
37// Returned by FPDFText_LoadPage function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070038// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -070039// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070040//
Dan Sinclair00d2ad12017-08-10 14:13:02 -040041FPDF_EXPORT void FPDF_CALLCONV FPDFText_ClosePage(FPDF_TEXTPAGE text_page);
Tom Sepez526f6d52015-01-28 15:49:13 -080042
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070043// Function: FPDFText_CountChars
Tom Sepez9857e202015-05-13 17:09:26 -070044// Get number of characters in a page.
Tom Sepez526f6d52015-01-28 15:49:13 -080045// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070046// text_page - Handle to a text page information structure.
47// Returned by FPDFText_LoadPage function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070048// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -070049// Number of characters in the page. Return -1 for error.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070050// Generated characters, like additional space characters, new line
51// characters, are also counted.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070052// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070053// 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 Sepez9857e202015-05-13 17:09:26 -070057// has an index value of zero.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070058//
Dan Sinclair00d2ad12017-08-10 14:13:02 -040059FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountChars(FPDF_TEXTPAGE text_page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070060
61// Function: FPDFText_GetUnicode
Tom Sepez9857e202015-05-13 17:09:26 -070062// Get Unicode of a character in a page.
Tom Sepez526f6d52015-01-28 15:49:13 -080063// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070064// text_page - Handle to a text page information structure.
65// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -070066// index - Zero-based index of the character.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070067// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -070068// The Unicode of the particular character.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070069// If a character is not encoded in Unicode and Foxit engine can't
70// convert to Unicode,
Tom Sepez9857e202015-05-13 17:09:26 -070071// the return value will be zero.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070072//
Dan Sinclair00d2ad12017-08-10 14:13:02 -040073FPDF_EXPORT unsigned int FPDF_CALLCONV
74FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070075
76// Function: FPDFText_GetFontSize
Tom Sepez9857e202015-05-13 17:09:26 -070077// Get the font size of a particular character.
Tom Sepez526f6d52015-01-28 15:49:13 -080078// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070079// text_page - Handle to a text page information structure.
80// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -070081// index - Zero-based index of the character.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070082// Return value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070083// The font size of the particular character, measured in points (about
84// 1/72 inch).
Tom Sepez9857e202015-05-13 17:09:26 -070085// This is the typographic size of the font (so called "em size").
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070086//
Dan Sinclair00d2ad12017-08-10 14:13:02 -040087FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
88 int index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070089
90// Function: FPDFText_GetCharBox
Tom Sepez9857e202015-05-13 17:09:26 -070091// Get bounding box of a particular character.
Tom Sepez526f6d52015-01-28 15:49:13 -080092// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -070093// text_page - Handle to a text page information structure.
94// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -070095// index - Zero-based index of the character.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070096// 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-Malek3f3b45c2014-05-23 17:28:10 -0700104// Return Value:
Lei Zhang241752f2018-01-11 14:34:06 +0000105// On success, return TRUE and fill in |left|, |right|, |bottom|, and
106// |top|. If |text_page| is invalid, or if |index| is out of bounds,
107// then return FALSE, and the out parameters remain unmodified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700108// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700109// All positions are measured in PDF "user space".
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700110//
Lei Zhang241752f2018-01-11 14:34:06 +0000111FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page,
112 int index,
113 double* left,
114 double* right,
115 double* bottom,
116 double* top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700117
Andrew Weintraubd3002342017-08-11 11:36:51 -0400118// Function: FPDFText_GetCharOrigin
119// Get origin of a particular character.
120// Parameters:
121// text_page - Handle to a text page information structure.
122// Returned by FPDFText_LoadPage function.
123// index - Zero-based index of the character.
124// x - Pointer to a double number receiving x coordinate of
125// the character origin.
126// y - Pointer to a double number receiving y coordinate of
127// the character origin.
128// Return Value:
129// Whether the call succeeded. If false, x and y are unchanged.
130// Comments:
131// All positions are measured in PDF "user space".
132//
133FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
134FPDFText_GetCharOrigin(FPDF_TEXTPAGE text_page,
135 int index,
136 double* x,
137 double* y);
138
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700139// Function: FPDFText_GetCharIndexAtPos
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700140// Get the index of a character at or nearby a certain position on the
141// page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700142// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700143// text_page - Handle to a text page information structure.
144// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -0700145// x - X position in PDF "user space".
146// y - Y position in PDF "user space".
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700147// xTolerance - An x-axis tolerance value for character hit
148// detection, in point unit.
149// yTolerance - A y-axis tolerance value for character hit
150// detection, in point unit.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700151// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700152// The zero-based index of the character at, or nearby the point (x,y).
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700153// If there is no character at or nearby the point, return value will
154// be -1.
Tom Sepez9857e202015-05-13 17:09:26 -0700155// If an error occurs, -3 will be returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700156//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400157FPDF_EXPORT int FPDF_CALLCONV
158FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page,
159 double x,
160 double y,
161 double xTolerance,
162 double yTolerance);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700163
164// Function: FPDFText_GetText
Tom Sepez9857e202015-05-13 17:09:26 -0700165// Extract unicode text string from the page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700166// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700167// text_page - Handle to a text page information structure.
168// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -0700169// start_index - Index for the start characters.
170// count - Number of characters to be extracted.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700171// result - A buffer (allocated by application) receiving the
172// extracted unicodes.
173// The size of the buffer must be able to hold the
174// number of characters plus a terminator.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700175// Return Value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700176// Number of characters written into the result buffer, including the
177// trailing terminator.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700178// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700179// This function ignores characters without unicode information.
Tom Sepez526f6d52015-01-28 15:49:13 -0800180//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400181FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page,
182 int start_index,
183 int count,
184 unsigned short* result);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700185
186// Function: FPDFText_CountRects
Tom Sepez9857e202015-05-13 17:09:26 -0700187// Count number of rectangular areas occupied by a segment of texts.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700188// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700189// text_page - Handle to a text page information structure.
190// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -0700191// start_index - Index for the start characters.
192// count - Number of characters.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700193// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700194// Number of rectangles. Zero for error.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700195// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700196// This function, along with FPDFText_GetRect can be used by
197// applications to detect the position
198// on the page for a text segment, so proper areas can be highlighted
199// or something.
200// FPDFTEXT will automatically merge small character boxes into bigger
201// one if those characters
Tom Sepez9857e202015-05-13 17:09:26 -0700202// are on the same line and use same font settings.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700203//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400204FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountRects(FPDF_TEXTPAGE text_page,
205 int start_index,
206 int count);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700207
208// Function: FPDFText_GetRect
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700209// Get a rectangular area from the result generated by
210// FPDFText_CountRects.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700211// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700212// text_page - Handle to a text page information structure.
213// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -0700214// rect_index - Zero-based index for the rectangle.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215// left - Pointer to a double value receiving the rectangle
216// left boundary.
217// top - Pointer to a double value receiving the rectangle
218// top boundary.
219// right - Pointer to a double value receiving the rectangle
220// right boundary.
221// bottom - Pointer to a double value receiving the rectangle
222// bottom boundary.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700223// Return Value:
Lei Zhang76250212018-01-11 14:28:01 +0000224// On success, return TRUE and fill in |left|, |top|, |right|, and
225// |bottom|. If |link_page| is invalid then return FALSE, and the out
226// parameters remain unmodified. If |link_page| is valid but
227// |link_index| is out of bounds, then return FALSE and set the out
228// parameters to 0.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700229//
Lei Zhang76250212018-01-11 14:28:01 +0000230FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetRect(FPDF_TEXTPAGE text_page,
231 int rect_index,
232 double* left,
233 double* top,
234 double* right,
235 double* bottom);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700236
237// Function: FPDFText_GetBoundedText
Tom Sepez9857e202015-05-13 17:09:26 -0700238// Extract unicode text within a rectangular boundary on the page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700239// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700240// text_page - Handle to a text page information structure.
241// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -0700242// left - Left boundary.
243// top - Top boundary.
244// right - Right boundary.
245// bottom - Bottom boundary.
246// buffer - A unicode buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700247// buflen - Number of characters (not bytes) for the buffer,
248// excluding an additional terminator.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700249// Return Value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700250// If buffer is NULL or buflen is zero, return number of characters
251// (not bytes) of text present within
252// the rectangle, excluding a terminating NUL. Generally you should
253// pass a buffer at least one larger
254// than this if you want a terminating NUL, which will be provided if
255// space is available.
256// Otherwise, return number of characters copied into the buffer,
257// including the terminating NUL
Tom Sepez9857e202015-05-13 17:09:26 -0700258// when space for it is available.
Tom Sepez526f6d52015-01-28 15:49:13 -0800259// Comment:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700260// If the buffer is too small, as much text as will fit is copied into
261// it.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700262//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400263FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page,
264 double left,
265 double top,
266 double right,
267 double bottom,
268 unsigned short* buffer,
269 int buflen);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700270
271// Flags used by FPDFText_FindStart function.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700272#define FPDF_MATCHCASE \
273 0x00000001 // If not set, it will not match case by default.
274#define FPDF_MATCHWHOLEWORD \
275 0x00000002 // If not set, it will not match the whole word by default.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700276
277// Function: FPDFText_FindStart
Tom Sepez9857e202015-05-13 17:09:26 -0700278// Start a search.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700279// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700280// text_page - Handle to a text page information structure.
281// Returned by FPDFText_LoadPage function.
Tom Sepez9857e202015-05-13 17:09:26 -0700282// findwhat - A unicode match pattern.
283// flags - Option flags.
284// start_index - Start from this character. -1 for end of the page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700285// Return Value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700286// A handle for the search context. FPDFText_FindClose must be called
287// to release this handle.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700288//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400289FPDF_EXPORT FPDF_SCHHANDLE FPDF_CALLCONV
290FPDFText_FindStart(FPDF_TEXTPAGE text_page,
291 FPDF_WIDESTRING findwhat,
292 unsigned long flags,
293 int start_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700294
295// Function: FPDFText_FindNext
Tom Sepez9857e202015-05-13 17:09:26 -0700296// Search in the direction from page start to end.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700297// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700298// handle - A search context handle returned by
299// FPDFText_FindStart.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700300// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700301// Whether a match is found.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700302//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400303FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindNext(FPDF_SCHHANDLE handle);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700304
305// Function: FPDFText_FindPrev
Tom Sepez9857e202015-05-13 17:09:26 -0700306// Search in the direction from page end to start.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700307// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700308// handle - A search context handle returned by
309// FPDFText_FindStart.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700310// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700311// Whether a match is found.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700312//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400313FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindPrev(FPDF_SCHHANDLE handle);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700314
315// Function: FPDFText_GetSchResultIndex
Tom Sepez9857e202015-05-13 17:09:26 -0700316// Get the starting character index of the search result.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700317// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700318// handle - A search context handle returned by
319// FPDFText_FindStart.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700320// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700321// Index for the starting character.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700322//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400323FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700324
325// Function: FPDFText_GetSchCount
Tom Sepez9857e202015-05-13 17:09:26 -0700326// Get the number of matched characters in the search result.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700327// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700328// handle - A search context handle returned by
329// FPDFText_FindStart.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700330// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700331// Number of matched characters.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700332//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400333FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchCount(FPDF_SCHHANDLE handle);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700334
335// Function: FPDFText_FindClose
Tom Sepez9857e202015-05-13 17:09:26 -0700336// Release a search context.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700337// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700338// handle - A search context handle returned by
339// FPDFText_FindStart.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700340// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700341// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700342//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400343FPDF_EXPORT void FPDF_CALLCONV FPDFText_FindClose(FPDF_SCHHANDLE handle);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700344
345// Function: FPDFLink_LoadWebLinks
Tom Sepez9857e202015-05-13 17:09:26 -0700346// Prepare information about weblinks in a page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700347// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700348// text_page - Handle to a text page information structure.
349// Returned by FPDFText_LoadPage function.
Tom Sepez526f6d52015-01-28 15:49:13 -0800350// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700351// A handle to the page's links information structure.
352// NULL if something goes wrong.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700353// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700354// Weblinks are those links implicitly embedded in PDF pages. PDF also
355// has a type of
356// annotation called "link", FPDFTEXT doesn't deal with that kind of
357// link.
358// FPDFTEXT weblink feature is useful for automatically detecting links
359// in the page
360// contents. For example, things like "http://www.foxitsoftware.com"
361// will be detected,
362// so applications can allow user to click on those characters to
363// activate the link,
Tom Sepez9857e202015-05-13 17:09:26 -0700364// even the PDF doesn't come with link annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700365//
Tom Sepez9857e202015-05-13 17:09:26 -0700366// FPDFLink_CloseWebLinks must be called to release resources.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700367//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400368FPDF_EXPORT FPDF_PAGELINK FPDF_CALLCONV
369FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700370
371// Function: FPDFLink_CountWebLinks
Tom Sepez9857e202015-05-13 17:09:26 -0700372// Count number of detected web links.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700373// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700374// link_page - Handle returned by FPDFLink_LoadWebLinks.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700375// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700376// Number of detected web links.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700377//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400378FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountWebLinks(FPDF_PAGELINK link_page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700379
380// Function: FPDFLink_GetURL
Tom Sepez9857e202015-05-13 17:09:26 -0700381// Fetch the URL information for a detected web link.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700382// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700383// link_page - Handle returned by FPDFLink_LoadWebLinks.
384// link_index - Zero-based index for the link.
tsepez69141182016-04-21 10:43:39 -0700385// buffer - A unicode buffer for the result.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700386// buflen - Number of characters (not bytes) for the buffer,
tsepez69141182016-04-21 10:43:39 -0700387// including an additional terminator.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700388// Return Value:
tsepez69141182016-04-21 10:43:39 -0700389// If |buffer| is NULL or |buflen| is zero, return the number of
390// characters (not bytes) needed to buffer the result (an additional
391// terminator is included in this count).
392// Otherwise, copy the result into |buffer|, truncating at |buflen| if
393// the result is too large to fit, and return the number of characters
394// actually copied into the buffer (the additional terminator is also
395// included in this count).
396// If |link_index| does not correspond to a valid link, then the result
397// is an empty string.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700398//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400399FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetURL(FPDF_PAGELINK link_page,
400 int link_index,
401 unsigned short* buffer,
402 int buflen);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700403
404// Function: FPDFLink_CountRects
Tom Sepez9857e202015-05-13 17:09:26 -0700405// Count number of rectangular areas for the link.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700406// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700407// link_page - Handle returned by FPDFLink_LoadWebLinks.
408// link_index - Zero-based index for the link.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700409// Return Value:
tsepez69141182016-04-21 10:43:39 -0700410// Number of rectangular areas for the link. If |link_index| does
411// not correspond to a valid link, then 0 is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700412//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400413FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountRects(FPDF_PAGELINK link_page,
414 int link_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700415
416// Function: FPDFLink_GetRect
Tom Sepez9857e202015-05-13 17:09:26 -0700417// Fetch the boundaries of a rectangle for a link.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700418// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700419// link_page - Handle returned by FPDFLink_LoadWebLinks.
420// link_index - Zero-based index for the link.
421// rect_index - Zero-based index for a rectangle.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700422// left - Pointer to a double value receiving the rectangle
tsepez69141182016-04-21 10:43:39 -0700423// left boundary.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700424// top - Pointer to a double value receiving the rectangle
tsepez69141182016-04-21 10:43:39 -0700425// top boundary.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700426// right - Pointer to a double value receiving the rectangle
tsepez69141182016-04-21 10:43:39 -0700427// right boundary.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700428// bottom - Pointer to a double value receiving the rectangle
tsepez69141182016-04-21 10:43:39 -0700429// bottom boundary.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700430// Return Value:
Lei Zhang50bd8fa2018-01-10 17:33:06 +0000431// On success, return TRUE and fill in |left|, |top|, |right|, and
Lei Zhang76250212018-01-11 14:28:01 +0000432// |bottom|. If |link_page| is invalid or if |link_index| does not
433// correspond to a valid link, then return FALSE, and the out
434// parameters remain unmodified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700435//
Lei Zhang50bd8fa2018-01-10 17:33:06 +0000436FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetRect(FPDF_PAGELINK link_page,
437 int link_index,
438 int rect_index,
439 double* left,
440 double* top,
441 double* right,
442 double* bottom);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700443
444// Function: FPDFLink_CloseWebLinks
Tom Sepez9857e202015-05-13 17:09:26 -0700445// Release resources used by weblink feature.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700446// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700447// link_page - Handle returned by FPDFLink_LoadWebLinks.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700448// Return Value:
Tom Sepez9857e202015-05-13 17:09:26 -0700449// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700450//
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400451FPDF_EXPORT void FPDF_CALLCONV FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700452
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700453#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -0700454}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700455#endif
456
Tom Sepez9857e202015-05-13 17:09:26 -0700457#endif // PUBLIC_FPDF_TEXT_H_