Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: fpdfsdk/include/fpdftext.h

Issue 878333003: Cover fpdftext.h API with embeddertests. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Non-zero initial paramenters in another place. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | fpdfsdk/src/fpdftext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef _FPDFTEXT_H_ 7 #ifndef _FPDFTEXT_H_
8 #define _FPDFTEXT_H_ 8 #define _FPDFTEXT_H_
9 9
10 #include "fpdfview.h" 10 #include "fpdfview.h"
11 11
12 // Exported Functions 12 // Exported Functions
13 #ifdef __cplusplus 13 #ifdef __cplusplus
14 extern "C" { 14 extern "C" {
15 #endif 15 #endif
16 16
17 // Function: FPDFText_LoadPage 17 // Function: FPDFText_LoadPage
18 // Prepare information about all characters in a page. 18 // Prepare information about all characters in a page.
19 // Parameters: 19 // Parameters:
20 //» » » page» -» Handle to the page. Returned by FPDF_Loa dPage function (in FPDFVIEW module).» 20 //» » » page» -» Handle to the page. Returned by FPDF_Loa dPage function (in FPDFVIEW module).
21 // Return value: 21 // Return value:
22 // A handle to the text page information structure. 22 // A handle to the text page information structure.
23 // NULL if something goes wrong. 23 // NULL if something goes wrong.
24 // Comments: 24 // Comments:
25 // Application must call FPDFText_ClosePage to release the text page information. 25 // Application must call FPDFText_ClosePage to release the text page information.
26 // If you don't purchase Text Module , this function will r eturn NULL.
27 // Notes: 26 // Notes:
28 // The method can not support to load out FPDF_TEXTPAGE for the document consists of dynamic fields. 27 // The method can not support to load out FPDF_TEXTPAGE for the document consists of dynamic fields.
29 //» 28 //
30 DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page); 29 DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page);
31 30
32 // Function: FPDFText_ClosePage 31 // Function: FPDFText_ClosePage
33 // Release all resources allocated for a text page informat ion structure. 32 // Release all resources allocated for a text page informat ion structure.
34 // Parameters: 33 // Parameters:
35 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 34 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
36 // Return Value: 35 // Return Value:
37 // None. 36 // None.
38 // 37 //
39 DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page); 38 DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page);
40 » 39
41 // Function: FPDFText_CountChars 40 // Function: FPDFText_CountChars
42 // Get number of characters in a page. 41 // Get number of characters in a page.
43 // Parameters: 42 // Parameters:
44 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 43 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
45 // Return value: 44 // Return value:
46 //» » » Number of characters in the page. Return -1 for error. 45 //» » » Number of characters in the page. Return -1 for error.
47 // Generated characters, like additional space characters, new line characters, are also counted. 46 // Generated characters, like additional space characters, new line characters, are also counted.
48 // Comments: 47 // Comments:
49 // Characters in a page form a "stream", inside the stream, each character has an index. 48 // Characters in a page form a "stream", inside the stream, each character has an index.
50 // We will use the index parameters in many of FPDFTEXT fun ctions. The first character in the page 49 // We will use the index parameters in many of FPDFTEXT fun ctions. The first character in the page
51 // has an index value of zero. 50 // has an index value of zero.
52 // 51 //
53 DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); 52 DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page);
54 53
55 // Function: FPDFText_GetUnicode 54 // Function: FPDFText_GetUnicode
56 // Get Unicode of a character in a page. 55 // Get Unicode of a character in a page.
57 // Parameters: 56 // Parameters:
58 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 57 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
59 // index - Zero-based index of the characte r. 58 // index - Zero-based index of the characte r.
60 // Return value: 59 // Return value:
61 // The Unicode of the particular character. 60 // The Unicode of the particular character.
62 // If a character is not encoded in Unicode and Foxit engin e can't convert to Unicode, 61 // If a character is not encoded in Unicode and Foxit engin e can't convert to Unicode,
63 // the return value will be zero. 62 // the return value will be zero.
64 // 63 //
65 DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index); 64 DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index);
66 65
67 // Function: FPDFText_GetFontSize 66 // Function: FPDFText_GetFontSize
68 // Get the font size of a particular character. 67 // Get the font size of a particular character.
69 // Parameters: 68 // Parameters:
70 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 69 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
71 // index - Zero-based index of the characte r. 70 // index - Zero-based index of the characte r.
72 // Return value: 71 // Return value:
73 // The font size of the particular character, measured in p oints (about 1/72 inch). 72 // The font size of the particular character, measured in p oints (about 1/72 inch).
74 // This is the typographic size of the font (so called "em size"). 73 // This is the typographic size of the font (so called "em size").
75 // 74 //
76 DLLEXPORT double STDCALL FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, int index ); 75 DLLEXPORT double STDCALL FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, int index );
77 76
78 // Function: FPDFText_GetCharBox 77 // Function: FPDFText_GetCharBox
79 // Get bounding box of a particular character. 78 // Get bounding box of a particular character.
80 // Parameters: 79 // Parameters:
81 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 80 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
82 // index - Zero-based index of the characte r. 81 // index - Zero-based index of the characte r.
83 // left - Pointer to a double number recei ving left position of the character box. 82 // left - Pointer to a double number recei ving left position of the character box.
84 // right - Pointer to a double number recei ving right position of the character box. 83 // right - Pointer to a double number recei ving right position of the character box.
85 // bottom - Pointer to a double number recei ving bottom position of the character box. 84 // bottom - Pointer to a double number recei ving bottom position of the character box.
86 // top - Pointer to a double numb er receiving top position of the character box. 85 // top - Pointer to a double numb er receiving top position of the character box.
87 // Return Value: 86 // Return Value:
88 // None. 87 // None.
89 // Comments: 88 // Comments:
90 // All positions are measured in PDF "user space". 89 // All positions are measured in PDF "user space".
(...skipping 22 matching lines...) Expand all
113 // Parameters: 112 // Parameters:
114 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 113 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
115 // start_index - Index for the start characters. 114 // start_index - Index for the start characters.
116 // count - Number of characters to be extra cted. 115 // count - Number of characters to be extra cted.
117 // result - A buffer (allocated by applicati on) receiving the extracted unicodes. 116 // result - A buffer (allocated by applicati on) receiving the extracted unicodes.
118 // The size of the buffer m ust be able to hold the number of characters plus a terminator. 117 // The size of the buffer m ust be able to hold the number of characters plus a terminator.
119 // Return Value: 118 // Return Value:
120 // Number of characters written into the result buffer, inc luding the trailing terminator. 119 // Number of characters written into the result buffer, inc luding the trailing terminator.
121 // Comments: 120 // Comments:
122 // This function ignores characters without unicode informa tion. 121 // This function ignores characters without unicode informa tion.
123 //» » » 122 //
124 DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, int start_index, int count, unsigned short* result); 123 DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, int start_index, int count, unsigned short* result);
125 124
126 // Function: FPDFText_CountRects 125 // Function: FPDFText_CountRects
127 // Count number of rectangular areas occupied by a segment of texts. 126 // Count number of rectangular areas occupied by a segment of texts.
128 // Parameters: 127 // Parameters:
129 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 128 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
130 // start_index - Index for the start characters. 129 // start_index - Index for the start characters.
131 // count - Number of characters. 130 // count - Number of characters.
132 // Return value: 131 // Return value:
133 // Number of rectangles. Zero for error. 132 // Number of rectangles. Zero for error.
(...skipping 24 matching lines...) Expand all
158 // Extract unicode text within a rectangular boundary on th e page. 157 // Extract unicode text within a rectangular boundary on th e page.
159 // Parameters: 158 // Parameters:
160 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 159 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
161 // left - Left boundary. 160 // left - Left boundary.
162 // top - Top boundary. 161 // top - Top boundary.
163 // right - Right boundary. 162 // right - Right boundary.
164 // bottom - Bottom boundary. 163 // bottom - Bottom boundary.
165 // buffer - A unicode buffer. 164 // buffer - A unicode buffer.
166 // buflen - Number of characters (not bytes) for the buffer, excluding an additional terminator. 165 // buflen - Number of characters (not bytes) for the buffer, excluding an additional terminator.
167 // Return Value: 166 // Return Value:
168 //» » » If buffer is NULL or buflen is zero, return number of ch aracters (not bytes) needed, 167 //» » » If buffer is NULL or buflen is zero, return number of ch aracters (not bytes) of text present within
169 //» » » otherwise, return number of characters copied into the b uffer. 168 //» » » the rectangle, excluding a terminating NUL. Generally y ou should pass a buffer at least one larger
169 //» » » than this if you want a terminating NUL, which will be p rovided if space is available.
170 //» » » Otherwise, return number of characters copied into the b uffer, including the terminating NUL
171 //» » » when space for it is available.
172 // Comment:
173 //» » » If the buffer is too small, as much text as will fit is copied into it.
170 // 174 //
171 DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page,double lef t, double top, 175 DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page,double lef t, double top,
172 double right, double bottom,unsigned short* buffer,int buflen); 176 double right, double bottom,unsigned short* buffer,int buflen);
173 177
174 178
175 // Flags used by FPDFText_FindStart function. 179 // Flags used by FPDFText_FindStart function.
176 #define FPDF_MATCHCASE 0x00000001 //If not set, it will not match case by default. 180 #define FPDF_MATCHCASE 0x00000001 //If not set, it will not match case by default.
177 #define FPDF_MATCHWHOLEWORD 0x00000002 //If not set, it will not match the whole word by default. 181 #define FPDF_MATCHWHOLEWORD 0x00000002 //If not set, it will not match the whole word by default.
178 182
179 // Function: FPDFText_FindStart 183 // Function: FPDFText_FindStart
180 // Start a search. 184 // Start a search.
181 // Parameters: 185 // Parameters:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // handle - A search context handle returned by FPDFText_FindStart. 235 // handle - A search context handle returned by FPDFText_FindStart.
232 // Return Value: 236 // Return Value:
233 // None. 237 // None.
234 // 238 //
235 DLLEXPORT void STDCALL FPDFText_FindClose(FPDF_SCHHANDLE handle); 239 DLLEXPORT void STDCALL FPDFText_FindClose(FPDF_SCHHANDLE handle);
236 240
237 // Function: FPDFLink_LoadWebLinks 241 // Function: FPDFLink_LoadWebLinks
238 // Prepare information about weblinks in a page. 242 // Prepare information about weblinks in a page.
239 // Parameters: 243 // Parameters:
240 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function. 244 // text_page - Handle to a text page informatio n structure. Returned by FPDFText_LoadPage function.
241 // Return Value:» 245 // Return Value:
242 // A handle to the page's links information structure. 246 // A handle to the page's links information structure.
243 // NULL if something goes wrong. 247 // NULL if something goes wrong.
244 // Comments: 248 // Comments:
245 // Weblinks are those links implicitly embedded in PDF page s. PDF also has a type of 249 // Weblinks are those links implicitly embedded in PDF page s. PDF also has a type of
246 // annotation called "link", FPDFTEXT doesn't deal with tha t kind of link. 250 // annotation called "link", FPDFTEXT doesn't deal with tha t kind of link.
247 // FPDFTEXT weblink feature is useful for automatically det ecting links in the page 251 // FPDFTEXT weblink feature is useful for automatically det ecting links in the page
248 // contents. For example, things like "http://www.foxitsoft ware.com" will be detected, 252 // contents. For example, things like "http://www.foxitsoft ware.com" will be detected,
249 // so applications can allow user to click on those charact ers to activate the link, 253 // so applications can allow user to click on those charact ers to activate the link,
250 // even the PDF doesn't come with link annotations. 254 // even the PDF doesn't come with link annotations.
251 // 255 //
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // link_page - Handle returned by FPDFLink_Load WebLinks. 295 // link_page - Handle returned by FPDFLink_Load WebLinks.
292 // link_index - Zero-based index for the link. 296 // link_index - Zero-based index for the link.
293 // rect_index - Zero-based index for a rectangle . 297 // rect_index - Zero-based index for a rectangle .
294 // left - Pointer to a double value receiv ing the rectangle left boundary. 298 // left - Pointer to a double value receiv ing the rectangle left boundary.
295 // top - Pointer to a double valu e receiving the rectangle top boundary. 299 // top - Pointer to a double valu e receiving the rectangle top boundary.
296 // right - Pointer to a double value receiv ing the rectangle right boundary. 300 // right - Pointer to a double value receiv ing the rectangle right boundary.
297 // bottom - Pointer to a double value receiv ing the rectangle bottom boundary. 301 // bottom - Pointer to a double value receiv ing the rectangle bottom boundary.
298 // Return Value: 302 // Return Value:
299 // None. 303 // None.
300 // 304 //
301 DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, int link_index, int rect_index, 305 DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, int link_index, int rect_index,
302 double* left, double* top,double* right, double* bottom); 306 double* left, double* top,double* right, double* bottom);
303 307
304 // Function: FPDFLink_CloseWebLinks 308 // Function: FPDFLink_CloseWebLinks
305 // Release resources used by weblink feature. 309 // Release resources used by weblink feature.
306 // Parameters: 310 // Parameters:
307 // link_page - Handle returned by FPDFLink_Load WebLinks. 311 // link_page - Handle returned by FPDFLink_Load WebLinks.
308 // Return Value: 312 // Return Value:
309 // None. 313 // None.
310 // 314 //
311 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page); 315 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page);
312 316
313 317
314 #ifdef __cplusplus 318 #ifdef __cplusplus
315 }; 319 };
316 #endif 320 #endif
317 321
318 #endif//_FPDFTEXT_H_ 322 #endif//_FPDFTEXT_H_
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/src/fpdftext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698