1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef PUBLIC_FPDF_DATAAVAIL_H_
#define PUBLIC_FPDF_DATAAVAIL_H_
#include <stddef.h> // For size_t.
#include "fpdfview.h"
#define PDF_LINEARIZATION_UNKNOWN -1
#define PDF_NOT_LINEARIZED 0
#define PDF_LINEARIZED 1
#define PDF_DATA_ERROR -1
#define PDF_DATA_NOTAVAIL 0
#define PDF_DATA_AVAIL 1
#define PDF_FORM_ERROR -1
#define PDF_FORM_NOTAVAIL 0
#define PDF_FORM_AVAIL 1
#define PDF_FORM_NOTEXIST 2
#ifdef __cplusplus
extern "C" {
#endif
/**
* Interface: FX_FILEAVAIL
* Interface for checking whether the section of the file is available.
*/
typedef struct _FX_FILEAVAIL {
/**
* Version number of the interface. Currently must be 1.
*/
int version;
/**
* Method: IsDataAvail
* Report whether the specified data section is available. A section is
* available only if all bytes in the section is available.
* Interface Version:
* 1
* Implementation Required:
* Yes
* Parameters:
* pThis - Pointer to the interface structure itself.
* offset - The offset of the data section in the file.
* size - The size of the data section
* Return Value:
* true means the specified data section is available.
* Comments:
* Called by Foxit SDK to check whether the data section is ready.
*/
FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size);
} FX_FILEAVAIL;
typedef void* FPDF_AVAIL;
/**
* Function: FPDFAvail_Create
* Create a document availability provider.
*
* Parameters:
* file_avail - Pointer to file availability interface to check
* availability of file data.
* file - Pointer to a file access interface for reading data
* from file.
* Return value:
* A handle to the document availability provider. NULL for error.
* Comments:
* Application must call FPDFAvail_Destroy when done with the
* availability provider.
*/
DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail,
FPDF_FILEACCESS* file);
/**
* Function: FPDFAvail_Destroy
* Destroy a document availibity provider.
*
* Parameters:
* avail - Handle to document availability provider returned by
* FPDFAvail_Create
* Return Value:
* None.
*/
DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail);
/**
* Interface: FX_DOWNLOADHINTS
* Download hints interface. Used to receive hints for further
* downloading.
*/
typedef struct _FX_DOWNLOADHINTS {
/**
* Version number of the interface. Currently must be 1.
*/
int version;
/**
* Method: AddSegment
* Add a section to be downloaded.
* Interface Version:
* 1
* Implementation Required:
* Yes
* Parameters:
* pThis - Pointer to the interface structure itself.
* offset - The offset of the hint reported to be downloaded.
* size - The size of the hint reported to be downloaded.
* Return Value:
* None.
* Comments:
* Called by Foxit SDK to report some downloading hints for download
* manager.
* The position and size of section may be not accurate, part of the
* section might be already available.
* The download manager must deal with that to maximize download
* efficiency.
*/
void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis,
size_t offset,
size_t size);
} FX_DOWNLOADHINTS;
/**
* Function: FPDFAvail_IsDocAvail
* Check whether the document is ready for loading, if not, get
* download hints.
*
* Parameters:
* avail - Handle to document availability provider returned by
* FPDFAvail_Create
* hints - Pointer to a download hints interface, receiving
* generated hints
* Return value:
* PDF_DATA_ERROR: A common error is returned. It can't tell
* whehter data are availabe or not.
* PDF_DATA_NOTAVAIL: Data are not yet available.
* PDF_DATA_AVAIL: Data are available.
* Comments:
* Applications should call this function whenever new data arrived,
* and process all the generated download hints if any, until the
* function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then
* applications can call FPDFAvail_GetDocument() to get a document
* handle.
*/
DLLEXPORT int STDCALL
FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints);
/**
* Function: FPDFAvail_GetDocument
* Get document from the availability provider.
*
* Parameters:
* avail - Handle to document availability provider returned by
* FPDFAvail_Create
* password - Optional password for decrypting the PDF file.
* Return value:
* Handle to the document.
* Comments:
* After FPDFAvail_IsDocAvail() returns TRUE, the application should
* call this function to
* get the document handle. To close the document, use
* FPDF_CloseDocument function.
*/
DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail,
FPDF_BYTESTRING password);
/**
* Function: FPDFAvail_GetFirstPageNum
* Get page number for the first available page in a linearized PDF
*
* Parameters:
* doc - A document handle returned by FPDFAvail_GetDocument
* Return Value:
* Zero-based index for the first available page.
* Comments:
* For most linearized PDFs, the first available page would be just the
* first page, however,
* some PDFs might make other page to be the first available page.
* For non-linearized PDF, this function will always return zero.
*/
DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc);
/**
* Function: FPDFAvail_IsPageAvail
* Check whether a page is ready for loading, if not, get download
* hints.
*
* Parameters:
* avail - Handle to document availability provider returned by
* FPDFAvail_Create
* page_index - Index number of the page. 0 for the first page.
* hints - Pointer to a download hints interface, receiving
* generated hints
* Return value:
* PDF_DATA_ERROR: A common error is returned. It can't tell
* whehter data are availabe or not.
* PDF_DATA_NOTAVAIL: Data are not yet available.
* PDF_DATA_AVAIL: Data are available.
* Comments:
* This function can be called only after FPDFAvail_GetDocument is
* called. Applications should call this function whenever new data
* arrived and process all the generated download hints if any, until
* this function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then
* applications can perform page loading.
*/
DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail,
int page_index,
FX_DOWNLOADHINTS* hints);
/**
* Function: FPDFAvail_ISFormAvail
* Check whether Form data is ready for init, if not, get download
* hints.
*
* Parameters:
* avail - Handle to document availability provider returned by
* FPDFAvail_Create
* hints - Pointer to a download hints interface, receiving
* generated hints
* Return value:
* PDF_FORM_ERROR - A common eror, in general incorrect parameters,
* like 'hints' is nullptr.
* PDF_FORM_NOTAVAIL - data not available
* PDF_FORM_AVAIL - data available
* PDF_FORM_NOTEXIST - no form data
* Comments:
* This function can be called only after FPDFAvail_GetDocument is
* called.
* The application should call this function whenever new data arrived,
* and process all the
* generated download hints if any, until the function returns non-zero
* value. Then the
* application can perform page loading. Recommend to call
* FPDFDOC_InitFormFillEnvironment
* after the function returns non-zero value.
*/
DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail,
FX_DOWNLOADHINTS* hints);
/**
* Function: FPDFAvail_IsLinearized
* To check whether a document is Linearized PDF file.
*
* Parameters:
* avail - Handle to document availability provider returned by
* FPDFAvail_Create
* Return value:
* PDF_LINEARIZED is a linearize file.
* PDF_NOT_LINEARIZED is not a linearize file.
* PDF_LINEARIZATION_UNKNOWN doesn't know whether the file is a
*linearize file.
*
* Comments:
* It return PDF_LINEARIZED or PDF_NOT_LINEARIZED as soon as
* we have first 1K data. If the file's size less than 1K, it returns
* PDF_LINEARIZATION_UNKNOWN because there is not enough information to
* tell whether a PDF file is a linearized file or not.
*
*/
DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail);
#ifdef __cplusplus
}
#endif
#endif // PUBLIC_FPDF_DATAAVAIL_H_
|