OLD | NEW |
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 _FPDF_DATAAVAIL_H_ | 7 #ifndef PUBLIC_FPDF_DATAAVAIL_H_ |
8 #define _FPDF_DATAAVAIL_H_ | 8 #define PUBLIC_FPDF_DATAAVAIL_H_ |
9 | 9 |
10 #include <stddef.h> // For size_t. | 10 #include <stddef.h> // For size_t. |
11 | 11 |
12 #include "fpdfview.h" | 12 #include "fpdfview.h" |
13 | 13 |
14 /** The result of the process which check linearized PDF. */ | 14 /** The result of the process which check linearized PDF. */ |
15 #define FSDK_IS_LINEARIZED» » » 1 | 15 #define FSDK_IS_LINEARIZED 1 |
16 #define FSDK_NOT_LINEARIZED» » » 0 | 16 #define FSDK_NOT_LINEARIZED 0 |
17 #define FSDK_UNKNOW_LINEARIZED» » -1 | 17 #define FSDK_UNKNOW_LINEARIZED -1 |
18 | 18 |
19 | 19 |
20 #ifdef __cplusplus | 20 #ifdef __cplusplus |
21 extern "C" { | 21 extern "C" { |
22 #endif | 22 #endif |
23 | 23 |
24 /** | 24 /** |
25 * Interface: FX_FILEAVAIL | 25 * Interface: FX_FILEAVAIL |
26 *» » » Interface for checking whether the section of the file i
s available. | 26 * Interface for checking whether the section of the file is available. |
27 */ | 27 */ |
28 typedef struct _FX_FILEAVAIL { | 28 typedef struct _FX_FILEAVAIL { |
29 » /** | 29 /** |
30 » * Version number of the interface. Currently must be 1. | 30 * Version number of the interface. Currently must be 1. |
31 » */ | 31 */ |
32 » int version; | 32 int version; |
33 | 33 |
34 » /** | 34 /** |
35 » * Method: IsDataAvail | 35 * Method: IsDataAvail |
36 » *» » Report whether the specified data section is available.
A section is available only if all bytes in the section is available. | 36 * Report whether the specified data section is available. A section is
available only if all bytes in the section is available. |
37 » * Interface Version: | 37 * Interface Version: |
38 » *» » 1 | 38 * 1 |
39 » * Implementation Required: | 39 * Implementation Required: |
40 » *» » Yes | 40 * Yes |
41 » * Parameters: | 41 * Parameters: |
42 » *» » pThis» » -» Pointer to the interface structu
re itself. | 42 * pThis - Pointer to the interface structure itself. |
43 » *» » offset» » -» The offset of the data section i
n the file. | 43 * offset - The offset of the data section in the file. |
44 » *» » size» » -» The size of the data section | 44 * size - The size of the data section |
45 » * Return Value: | 45 * Return Value: |
46 » *» » true means the specified data section is available. | 46 * true means the specified data section is available. |
47 » * Comments: | 47 * Comments: |
48 » *» » Called by Foxit SDK to check whether the data section is
ready. | 48 * Called by Foxit SDK to check whether the data section is ready. |
49 » */ | 49 */ |
50 » FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, siz
e_t size); | 50 FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t
size); |
51 } FX_FILEAVAIL; | 51 } FX_FILEAVAIL; |
52 | 52 |
53 typedef void* FPDF_AVAIL; | 53 typedef void* FPDF_AVAIL; |
54 | 54 |
55 /** | 55 /** |
56 * Function: FPDFAvail_Create | 56 * Function: FPDFAvail_Create |
57 *» » » Create a document availability provider. | 57 * Create a document availability provider. |
58 * | 58 * |
59 * Parameters: | 59 * Parameters: |
60 *» » » file_avail» -» Pointer to file availability int
erface to check availability of file data. | 60 * file_avail - Pointer to file availability interface to check avai
lability of file data. |
61 *» » » file» » -» Pointer to a file access interfa
ce for reading data from file. | 61 * file - Pointer to a file access interface for reading data
from file. |
62 * Return value: | 62 * Return value: |
63 *» » » A handle to the document availability provider. NULL for
error. | 63 * A handle to the document availability provider. NULL for error. |
64 * Comments: | 64 * Comments: |
65 *» » » Application must call FPDFAvail_Destroy when done with t
he availability provider. | 65 * Application must call FPDFAvail_Destroy when done with the availabil
ity provider. |
66 * Notes: | 66 * Notes: |
67 *» » » The method can not support to load a document which cons
ists of dynamic XFA fields now. | 67 * The method can not support to load a document which consists of dyna
mic XFA fields now. |
68 */ | 68 */ |
69 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FIL
EACCESS* file); | 69 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FIL
EACCESS* file); |
70 | 70 |
71 /** | 71 /** |
72 * Function: FPDFAvail_Destroy | 72 * Function: FPDFAvail_Destroy |
73 *» » » Destroy a document availibity provider. | 73 * Destroy a document availibity provider. |
74 * | 74 * |
75 * Parameters: | 75 * Parameters: |
76 *» » » avail» » -» Handle to document availability
provider returned by FPDFAvail_Create | 76 * avail - Handle to document availability provider returned by
FPDFAvail_Create |
77 * Return Value: | 77 * Return Value: |
78 *» » » None. | 78 * None. |
79 */ | 79 */ |
80 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); | 80 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); |
81 | 81 |
82 /** | 82 /** |
83 * Interface: FX_DOWNLOADHINTS | 83 * Interface: FX_DOWNLOADHINTS |
84 *» » » Download hints interface. Used to receive hints for furt
her downloading. | 84 * Download hints interface. Used to receive hints for further download
ing. |
85 */ | 85 */ |
86 typedef struct _FX_DOWNLOADHINTS { | 86 typedef struct _FX_DOWNLOADHINTS { |
87 » /** | 87 /** |
88 » * Version number of the interface. Currently must be 1. | 88 * Version number of the interface. Currently must be 1. |
89 » */ | 89 */ |
90 » int version; | 90 int version; |
91 | 91 |
92 » /** | 92 /** |
93 » * Method: AddSegment | 93 * Method: AddSegment |
94 » *» » Add a section to be downloaded. | 94 * Add a section to be downloaded. |
95 » * Interface Version: | 95 * Interface Version: |
96 » *» » 1 | 96 * 1 |
97 » * Implementation Required: | 97 * Implementation Required: |
98 » *» » Yes | 98 * Yes |
99 » * Parameters: | 99 * Parameters: |
100 » *» » pThis» » -» Pointer to the interface structu
re itself. | 100 * pThis - Pointer to the interface structure itself. |
101 » *» » offset» » -» The offset of the hint reported
to be downloaded. | 101 * offset - The offset of the hint reported to be downloaded. |
102 » *» » size» » -» The size of the hint reported to
be downloaded. | 102 * size - The size of the hint reported to be downloaded. |
103 » * Return Value: | 103 * Return Value: |
104 » *» » None. | 104 * None. |
105 » * Comments: | 105 * Comments: |
106 » *» » Called by Foxit SDK to report some downloading hints for
download manager. | 106 * Called by Foxit SDK to report some downloading hints for download ma
nager. |
107 » *» » The position and size of section may be not accurate, pa
rt of the section might be already available. | 107 * The position and size of section may be not accurate, part of the se
ction might be already available. |
108 » *» » The download manager must deal with that to maximize dow
nload efficiency. | 108 * The download manager must deal with that to maximize download effici
ency. |
109 » */ | 109 */ |
110 » void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_
t size); | 110 void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t si
ze); |
111 } FX_DOWNLOADHINTS; | 111 } FX_DOWNLOADHINTS; |
112 | 112 |
113 /** | 113 /** |
114 * Function: FPDFAvail_IsDocAvail | 114 * Function: FPDFAvail_IsDocAvail |
115 *» » » Check whether the document is ready for loading, if not,
get download hints. | 115 * Check whether the document is ready for loading, if not, get downloa
d hints. |
116 * | 116 * |
117 * Parameters: | 117 * Parameters: |
118 *» » » avail» » -» Handle to document availability
provider returned by FPDFAvail_Create | 118 * avail - Handle to document availability provider returned by
FPDFAvail_Create |
119 *» » » hints» » -» Pointer to a download hints inte
rface, receiving generated hints | 119 * hints - Pointer to a download hints interface, receiving gen
erated hints |
120 * Return value: | 120 * Return value: |
121 *» » » Non-zero for page is fully available, 0 for page not yet
available. | 121 * Non-zero for page is fully available, 0 for page not yet available. |
122 * Comments: | 122 * Comments: |
123 *» » » The application should call this function whenever new d
ata arrived, and process all the | 123 * The application should call this function whenever new data arrived,
and process all the |
124 *» » » generated download hints if any, until the function retu
rns non-zero value. Then the | 124 * generated download hints if any, until the function returns non-zero
value. Then the |
125 *» » » application can call FPDFAvail_GetDocument() to get a do
cument handle. | 125 * application can call FPDFAvail_GetDocument() to get a document handl
e. |
126 */ | 126 */ |
127 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* h
ints); | 127 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* h
ints); |
128 | 128 |
129 /** | 129 /** |
130 * Function: FPDFAvail_GetDocument | 130 * Function: FPDFAvail_GetDocument |
131 *» » » Get document from the availability provider. | 131 * Get document from the availability provider. |
132 * | 132 * |
133 * Parameters: | 133 * Parameters: |
134 *» » » avail» » -» Handle to document availability
provider returned by FPDFAvail_Create | 134 * avail - Handle to document availability provider returned by
FPDFAvail_Create |
135 * password» -» Optional password for decrypting the PDF file. | 135 * password - Optional password for decrypting the PDF file. |
136 * Return value: | 136 * Return value: |
137 *» » » Handle to the document. | 137 * Handle to the document. |
138 * Comments: | 138 * Comments: |
139 *» » » After FPDFAvail_IsDocAvail() returns TRUE, the applicati
on should call this function to | 139 * After FPDFAvail_IsDocAvail() returns TRUE, the application should ca
ll this function to |
140 *» » » get the document handle. To close the document, use FPDF
_CloseDocument function. | 140 * get the document handle. To close the document, use FPDF_CloseDocume
nt function. |
141 */ | 141 */ |
142 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, | 142 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, |
143 FPDF_BYTESTRING password); | 143 FPDF_BYTESTRING password); |
144 | 144 |
145 /** | 145 /** |
146 * Function: FPDFAvail_GetFirstPageNum | 146 * Function: FPDFAvail_GetFirstPageNum |
147 *» » » Get page number for the first available page in a linear
ized PDF | 147 * Get page number for the first available page in a linearized PDF |
148 * | 148 * |
149 * Parameters: | 149 * Parameters: |
150 *» » » doc» » » -» A document handle return
ed by FPDFAvail_GetDocument | 150 * doc - A document handle returned by FPDFAvail_GetDocument |
151 * Return Value: | 151 * Return Value: |
152 *» » » Zero-based index for the first available page. | 152 * Zero-based index for the first available page. |
153 * Comments: | 153 * Comments: |
154 *» » » For most linearized PDFs, the first available page would
be just the first page, however, | 154 * For most linearized PDFs, the first available page would be just the
first page, however, |
155 *» » » some PDFs might make other page to be the first availabl
e page. | 155 * some PDFs might make other page to be the first available page. |
156 *» » » For non-linearized PDF, this function will always return
zero. | 156 * For non-linearized PDF, this function will always return zero. |
157 */ | 157 */ |
158 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); | 158 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); |
159 | 159 |
160 /** | 160 /** |
161 * Function: FPDFAvail_IsPageAvail | 161 * Function: FPDFAvail_IsPageAvail |
162 *» » » Check whether a page is ready for loading, if not, get d
ownload hints. | 162 * Check whether a page is ready for loading, if not, get download hint
s. |
163 * | 163 * |
164 * Parameters: | 164 * Parameters: |
165 *» » » avail» » -» Handle to document availability
provider returned by FPDFAvail_Create | 165 * avail - Handle to document availability provider returned by
FPDFAvail_Create |
166 *» » » page_index» -» Index number of the page. 0 for
the first page. | 166 * page_index - Index number of the page. 0 for the first page. |
167 *» » » hints» » -» Pointer to a download hints inte
rface, receiving generated hints | 167 * hints - Pointer to a download hints interface, receiving gen
erated hints |
168 * Return value: | 168 * Return value: |
169 *» » » Non-zero for page is fully available, 0 for page not yet
available. | 169 * Non-zero for page is fully available, 0 for page not yet available. |
170 * Comments: | 170 * Comments: |
171 *» » » This function call be called only after FPDFAvail_GetDoc
ument if called. | 171 * This function call be called only after FPDFAvail_GetDocument if cal
led. |
172 *» » » The application should call this function whenever new d
ata arrived, and process all the | 172 * The application should call this function whenever new data arrived,
and process all the |
173 *» » » generated download hints if any, until the function retu
rns non-zero value. Then the | 173 * generated download hints if any, until the function returns non-zero
value. Then the |
174 *» » » application can perform page loading. | 174 * application can perform page loading. |
175 */ | 175 */ |
176 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, int page_index, FX
_DOWNLOADHINTS* hints); | 176 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, int page_index, FX
_DOWNLOADHINTS* hints); |
177 | 177 |
178 /** | 178 /** |
179 * Function: FPDFAvail_ISFormAvail | 179 * Function: FPDFAvail_ISFormAvail |
180 *» » » Check whether Form data is ready for init, if not, get d
ownload hints. | 180 * Check whether Form data is ready for init, if not, get download hint
s. |
181 * | 181 * |
182 * Parameters: | 182 * Parameters: |
183 *» » » avail» » -» Handle to document availability
provider returned by FPDFAvail_Create | 183 * avail - Handle to document availability provider returned by
FPDFAvail_Create |
184 *» » » hints» » -» Pointer to a download hints inte
rface, receiving generated hints | 184 * hints - Pointer to a download hints interface, receiving gen
erated hints |
185 * Return value: | 185 * Return value: |
186 *» » » Non-zero for Form data is fully available, 0 for Form da
ta not yet available. | 186 * Non-zero for Form data is fully available, 0 for Form data not yet a
vailable. |
187 *» » » Details: -1 - error, the input parameter not correct, su
ch as hints is null. | 187 * Details: -1 - error, the input parameter not correct, such as hints
is null. |
188 *» » » » » 0 - data not available | 188 * 0 - data not available |
189 *» » » » » 1 - data available | 189 * 1 - data available |
190 *» » » » » 2 - no form data.» » »
» | 190 * 2 - no form data. |
191 * Comments: | 191 * Comments: |
192 *» » » This function call be called only after FPDFAvail_GetDoc
ument if called. | 192 * This function call be called only after FPDFAvail_GetDocument if cal
led. |
193 *» » » The application should call this function whenever new d
ata arrived, and process all the | 193 * The application should call this function whenever new data arrived,
and process all the |
194 *» » » generated download hints if any, until the function retu
rns non-zero value. Then the | 194 * generated download hints if any, until the function returns non-zero
value. Then the |
195 *» » » application can perform page loading. Recommend to call
FPDFDOC_InitFormFillEnvironment | 195 * application can perform page loading. Recommend to call FPDFDOC_Init
FormFillEnvironment |
196 *» » » after the function returns non-zero value. | 196 * after the function returns non-zero value. |
197 */ | 197 */ |
198 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS*
hints); | 198 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS*
hints); |
199 | 199 |
200 /** | 200 /** |
201 * Function: FPDFAvail_IsLinearized | 201 * Function: FPDFAvail_IsLinearized |
202 *» » » To check whether a document is Linearized PDF file. | 202 * To check whether a document is Linearized PDF file. |
203 * | 203 * |
204 * Parameters: | 204 * Parameters: |
205 *» » » avail» » -» Handle to document availability
provider returned by FPDFAvail_Create | 205 * avail - Handle to document availability provider returned by
FPDFAvail_Create |
206 * Return value: | 206 * Return value: |
207 *» » » return TRUE means the document is linearized PDF else no
t. | 207 * return TRUE means the document is linearized PDF else not. |
208 *» » » FSDK_IS_LINEARIZED is a linearize file. | 208 * FSDK_IS_LINEARIZED is a linearize file. |
209 *» » » FSDK_NOT_LINEARIZED is not a linearize file. | 209 * FSDK_NOT_LINEARIZED is not a linearize file. |
210 *» » » FSDK_UNKNOW_LINEARIZED don't know whether the file is a
linearize file. | 210 * FSDK_UNKNOW_LINEARIZED don't know whether the file is a linearize fi
le. |
211 * Comments: | 211 * Comments: |
212 *» » » It return TRUE/FALSE as soon as we have first 1K data. »
If the file's size less than | 212 * It return TRUE/FALSE as soon as we have first 1K data. If the file'
s size less than |
213 *» » » 1K,we don't known whether the PDF is a linearized file. | 213 * 1K,we don't known whether the PDF is a linearized file. |
214 * | 214 * |
215 */ | 215 */ |
216 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); | 216 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); |
217 | 217 |
218 #ifdef __cplusplus | 218 #ifdef __cplusplus |
219 }; | 219 } |
220 #endif | 220 #endif |
221 | 221 |
222 #endif | 222 #endif // PUBLIC_FPDF_DATAAVAIL_H_ |
223 | |
OLD | NEW |