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

Side by Side Diff: public/fpdfview.h

Issue 1480403002: Allow building non-XFA (master) on the XFA branch. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: warning Created 5 years 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 | « public/fpdf_formfill.h ('k') | samples/pdfium_test.cc » ('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 // NOTE: External docs refer to this file as "fpdfview.h", so do not rename 7 // NOTE: External docs refer to this file as "fpdfview.h", so do not rename
8 // despite lack of consitency with other public files. 8 // despite lack of consitency with other public files.
9 9
10 #ifndef PUBLIC_FPDFVIEW_H_ 10 #ifndef PUBLIC_FPDFVIEW_H_
11 #define PUBLIC_FPDFVIEW_H_ 11 #define PUBLIC_FPDFVIEW_H_
12 12
13 #if defined(_WIN32) && !defined(__WINDOWS__) 13 #if defined(_WIN32) && !defined(__WINDOWS__)
14 #include <windows.h> 14 #include <windows.h>
15 #endif 15 #endif
16 16
17 #ifdef PDF_ENABLE_XFA
17 // TODO: remove the #define when XFA is officially in pdfium 18 // TODO: remove the #define when XFA is officially in pdfium
18 #define PDF_USE_XFA 19 #define PDF_USE_XFA
19 20 #endif // PDF_ENABLE_XFA
20 // Data types
21 typedef void* FPDF_MODULEMGR;
22 21
23 // PDF types 22 // PDF types
23 typedef void* FPDF_ACTION;
24 typedef void* FPDF_BITMAP;
25 typedef void* FPDF_BOOKMARK;
26 typedef void* FPDF_CLIPPATH;
27 typedef void* FPDF_DEST;
28 typedef void* FPDF_DOCSCHHANDLE;
24 typedef void* FPDF_DOCUMENT; 29 typedef void* FPDF_DOCUMENT;
30 typedef void* FPDF_FONT;
31 typedef void* FPDF_HMODULE;
32 typedef void* FPDF_LINK;
33 typedef void* FPDF_MODULEMGR;
25 typedef void* FPDF_PAGE; 34 typedef void* FPDF_PAGE;
35 typedef void* FPDF_PAGELINK;
36 typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
37 typedef void* FPDF_PAGERANGE;
38 typedef void* FPDF_PATH;
39 typedef void* FPDF_SCHHANDLE;
40 typedef void* FPDF_TEXTPAGE;
41
42 #ifdef PDF_ENABLE_XFA
43 typedef void* FPDF_STRINGHANDLE;
26 typedef void* FPDF_WIDGET; 44 typedef void* FPDF_WIDGET;
27 typedef void* FPDF_STRINGHANDLE; 45 #endif // PDF_ENABLE_XFA
28 typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
29 typedef void* FPDF_PATH;
30 typedef void* FPDF_CLIPPATH;
31 typedef void* FPDF_BITMAP;
32 typedef void* FPDF_FONT;
33 typedef void* FPDF_TEXTPAGE;
34 typedef void* FPDF_SCHHANDLE;
35 typedef void* FPDF_PAGELINK;
36 typedef void* FPDF_HMODULE;
37 typedef void* FPDF_DOCSCHHANDLE;
38 typedef void* FPDF_BOOKMARK;
39 typedef void* FPDF_DEST;
40 typedef void* FPDF_ACTION;
41 typedef void* FPDF_LINK;
42 typedef void* FPDF_PAGERANGE;
43 46
44 // Basic data types 47 // Basic data types
45 typedef void* FPDF_LPVOID;
46 typedef void const* FPDF_LPCVOID;
47 typedef int FPDF_RESULT;
48 typedef int FPDF_BOOL; 48 typedef int FPDF_BOOL;
49 typedef int FPDF_ERROR; 49 typedef int FPDF_ERROR;
50 typedef unsigned long FPDF_DWORD; 50 typedef unsigned long FPDF_DWORD;
51 typedef float FS_FLOAT; 51 typedef float FS_FLOAT;
52 52
53 #ifdef PDF_ENABLE_XFA
54 typedef void* FPDF_LPVOID;
55 typedef void const* FPDF_LPCVOID;
56 typedef char const* FPDF_LPCSTR;
57 typedef int FPDF_RESULT;
58 #endif
59
53 // Duplex types 60 // Duplex types
54 typedef enum _FPDF_DUPLEXTYPE_ { 61 typedef enum _FPDF_DUPLEXTYPE_ {
55 DuplexUndefined = 0, 62 DuplexUndefined = 0,
56 Simplex, 63 Simplex,
57 DuplexFlipShortEdge, 64 DuplexFlipShortEdge,
58 DuplexFlipLongEdge 65 DuplexFlipLongEdge
59 } FPDF_DUPLEXTYPE; 66 } FPDF_DUPLEXTYPE;
60 67
61 // String types 68 // String types
62 typedef unsigned short FPDF_WCHAR; 69 typedef unsigned short FPDF_WCHAR;
63 typedef unsigned char const* FPDF_LPCBYTE; 70 typedef unsigned char const* FPDF_LPCBYTE;
64 typedef char const* FPDF_LPCSTR;
65 71
66 // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE 72 // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
67 // encoded), and platform dependent string 73 // encoded), and platform dependent string
68 typedef const char* FPDF_BYTESTRING; 74 typedef const char* FPDF_BYTESTRING;
69 75
70 // FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2 76 // FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
71 // bytes (except surrogation), with the low byte first. 77 // bytes (except surrogation), with the low byte first.
72 typedef const unsigned short* FPDF_WIDESTRING; 78 typedef const unsigned short* FPDF_WIDESTRING;
73 79
74 #ifndef _FPDF_DEF_STR_ 80 #ifdef PDF_ENABLE_XFA
75 #define _FPDF_DEF_STR_
76 // Structure for a byte string. 81 // Structure for a byte string.
77 // Note, a byte string commonly means a UTF-16LE formated string. 82 // Note, a byte string commonly means a UTF-16LE formated string.
78 typedef struct _FPDF_BSTR { 83 typedef struct _FPDF_BSTR {
79 // String buffer. 84 // String buffer.
80 char* str; 85 char* str;
81 // Length of the string, in bytes. 86 // Length of the string, in bytes.
82 int len; 87 int len;
83 } FPDF_BSTR; 88 } FPDF_BSTR;
84 89 #endif // PDF_ENABLE_XFA
85 #endif
86 90
87 // For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a 91 // For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
88 // Windows unicode string, however, special care needs to be taken if you 92 // Windows unicode string, however, special care needs to be taken if you
89 // expect to process Unicode larger than 0xffff. 93 // expect to process Unicode larger than 0xffff.
90 // 94 //
91 // For Linux/Unix programmers: most compiler/library environments use 4 bytes 95 // For Linux/Unix programmers: most compiler/library environments use 4 bytes
92 // for a Unicode character, and you have to convert between FPDF_WIDESTRING and 96 // for a Unicode character, and you have to convert between FPDF_WIDESTRING and
93 // system wide string by yourself. 97 // system wide string by yourself.
94
95 #ifdef _WIN32_WCE 98 #ifdef _WIN32_WCE
96 typedef const unsigned short* FPDF_STRING; 99 typedef const unsigned short* FPDF_STRING;
97 #else 100 #else
98 typedef const char* FPDF_STRING; 101 typedef const char* FPDF_STRING;
99 #endif 102 #endif
100 103
101 // Matrix for transformation. 104 // Matrix for transformation.
102 typedef struct _FS_MATRIX_ { 105 typedef struct _FS_MATRIX_ {
103 float a; 106 float a;
104 float b; 107 float b;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // Parameters: 218 // Parameters:
216 // file_path - Path to the PDF file (including extension). 219 // file_path - Path to the PDF file (including extension).
217 // password - A string used as the password for the PDF file. 220 // password - A string used as the password for the PDF file.
218 // If no password is needed, empty or NULL can be used. 221 // If no password is needed, empty or NULL can be used.
219 // Return value: 222 // Return value:
220 // A handle to the loaded document, or NULL on failure. 223 // A handle to the loaded document, or NULL on failure.
221 // Comments: 224 // Comments:
222 // Loaded document can be closed by FPDF_CloseDocument(). 225 // Loaded document can be closed by FPDF_CloseDocument().
223 // If this function fails, you can use FPDF_GetLastError() to retrieve 226 // If this function fails, you can use FPDF_GetLastError() to retrieve
224 // the reason why it failed. 227 // the reason why it failed.
225 // Notes:
226 // The application should call FPDF_LoadXFA function after PDF
227 // document loaded to support XFA fields in fpdfformfill.h file.
228 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, 228 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
229 FPDF_BYTESTRING password); 229 FPDF_BYTESTRING password);
230 230
231 // Function: FPDF_LoadMemDocument 231 // Function: FPDF_LoadMemDocument
232 // Open and load a PDF document from memory. 232 // Open and load a PDF document from memory.
233 // Parameters: 233 // Parameters:
234 // data_buf - Pointer to a buffer containing the PDF document. 234 // data_buf - Pointer to a buffer containing the PDF document.
235 // size - Number of bytes in the PDF document. 235 // size - Number of bytes in the PDF document.
236 // password - A string used as the password for the PDF file. 236 // password - A string used as the password for the PDF file.
237 // If no password is needed, empty or NULL can be used. 237 // If no password is needed, empty or NULL can be used.
238 // Return value: 238 // Return value:
239 // A handle to the loaded document, or NULL on failure. 239 // A handle to the loaded document, or NULL on failure.
240 // Comments: 240 // Comments:
241 // The memory buffer must remain valid when the document is open. 241 // The memory buffer must remain valid when the document is open.
242 // The loaded document can be closed by FPDF_CloseDocument. 242 // The loaded document can be closed by FPDF_CloseDocument.
243 // If this function fails, you can use FPDF_GetLastError() to retrieve 243 // If this function fails, you can use FPDF_GetLastError() to retrieve
244 // the reason why it failed. 244 // the reason why it failed.
245 // Notes: 245 // Notes:
246 // The application should call FPDF_LoadXFA function after the 246 // If PDFium is built with the XFA module, the application should call
247 // document is loaded to support form fields. 247 // FPDF_LoadXFA() function after the PDF document loaded to support XFA
248 // fields defined in the fpdfformfill.h file.
248 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, 249 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
249 int size, 250 int size,
250 FPDF_BYTESTRING password); 251 FPDF_BYTESTRING password);
251 252
252 // Structure for custom file access. 253 // Structure for custom file access.
253 typedef struct { 254 typedef struct {
254 // File length, in bytes. 255 // File length, in bytes.
255 unsigned long m_FileLen; 256 unsigned long m_FileLen;
256 257
257 // A function pointer for getting a block of data from a specific position. 258 // A function pointer for getting a block of data from a specific position.
258 // Position is specified by byte offset from the beginning of the file. 259 // Position is specified by byte offset from the beginning of the file.
259 // The position and size will never go out of range of the file length. 260 // The position and size will never go out of range of the file length.
260 // It may be possible for FPDFSDK to call this function multiple times for 261 // It may be possible for FPDFSDK to call this function multiple times for
261 // the same position. 262 // the same position.
262 // Return value: should be non-zero if successful, zero for error. 263 // Return value: should be non-zero if successful, zero for error.
263 int (*m_GetBlock)(void* param, 264 int (*m_GetBlock)(void* param,
264 unsigned long position, 265 unsigned long position,
265 unsigned char* pBuf, 266 unsigned char* pBuf,
266 unsigned long size); 267 unsigned long size);
267 268
268 // A custom pointer for all implementation specific data. This pointer will 269 // A custom pointer for all implementation specific data. This pointer will
269 // be used as the first parameter to the m_GetBlock callback. 270 // be used as the first parameter to the m_GetBlock callback.
270 void* m_Param; 271 void* m_Param;
271 } FPDF_FILEACCESS; 272 } FPDF_FILEACCESS;
272 273
274 #ifdef PDF_ENABLE_XFA
273 /** 275 /**
274 * @brief Structure for file reading or writing (I/O). 276 * @brief Structure for file reading or writing (I/O).
275 * 277 *
276 * @note This is a handler and should be implemented by callers. 278 * @note This is a handler and should be implemented by callers.
277 */ 279 */
278 typedef struct _FPDF_FILEHANDLER { 280 typedef struct _FPDF_FILEHANDLER {
279 /** 281 /**
280 * @brief User-defined data. 282 * @brief User-defined data.
281 * @note Callers can use this field to track controls. 283 * @note Callers can use this field to track controls.
282 */ 284 */
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 * 344 *
343 * @param[in] clientData Pointer to user-defined data. 345 * @param[in] clientData Pointer to user-defined data.
344 * @param[in] size New size of file stream, in bytes. 346 * @param[in] size New size of file stream, in bytes.
345 * 347 *
346 * @return 0 for success, other value for failure. 348 * @return 0 for success, other value for failure.
347 */ 349 */
348 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size); 350 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
349 351
350 } FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER; 352 } FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
351 353
354 #endif
352 // Function: FPDF_LoadCustomDocument 355 // Function: FPDF_LoadCustomDocument
353 // Load PDF document from a custom access descriptor. 356 // Load PDF document from a custom access descriptor.
354 // Parameters: 357 // Parameters:
355 // pFileAccess - A structure for accessing the file. 358 // pFileAccess - A structure for accessing the file.
356 // password - Optional password for decrypting the PDF file. 359 // password - Optional password for decrypting the PDF file.
357 // Return value: 360 // Return value:
358 // A handle to the loaded document, or NULL on failure. 361 // A handle to the loaded document, or NULL on failure.
359 // Comments: 362 // Comments:
360 // The application must keep the file resources valid until the PDF 363 // The application must keep the file resources valid until the PDF
361 // document is closed. 364 // document is closed.
362 // 365 //
363 // The loaded document can be closed with FPDF_CloseDocument. 366 // The loaded document can be closed with FPDF_CloseDocument.
364 // Notes: 367 // Notes:
365 // The application should call the FPDF_LoadXFA function after the 368 // If PDFium is built with the XFA module, the application should call
366 // document is loaded to support form fields. 369 // FPDF_LoadXFA() function after the PDF document loaded to support XFA
370 // fields defined in the fpdfformfill.h file.
367 DLLEXPORT FPDF_DOCUMENT STDCALL 371 DLLEXPORT FPDF_DOCUMENT STDCALL
368 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); 372 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
369 373
370 // Function: FPDF_GetFileVersion 374 // Function: FPDF_GetFileVersion
371 // Get the file version of the given PDF document. 375 // Get the file version of the given PDF document.
372 // Parameters: 376 // Parameters:
373 // doc - Handle to a document. 377 // doc - Handle to a document.
374 // fileVersion - The PDF file version. File version: 14 for 1.4, 15 378 // fileVersion - The PDF file version. File version: 14 for 1.4, 15
375 // for 1.5, ... 379 // for 1.5, ...
376 // Return value: 380 // Return value:
377 // True if succeeds, false otherwise. 381 // True if succeeds, false otherwise.
378 // Comments: 382 // Comments:
379 // If the document was created by FPDF_CreateNewDocument, 383 // If the document was created by FPDF_CreateNewDocument,
380 // then this function will always fail. 384 // then this function will always fail.
381 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, 385 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
382 int* fileVersion); 386 int* fileVersion);
383 387
384 #define FPDF_ERR_SUCCESS 0 // No error. 388 #define FPDF_ERR_SUCCESS 0 // No error.
385 #define FPDF_ERR_UNKNOWN 1 // Unknown error. 389 #define FPDF_ERR_UNKNOWN 1 // Unknown error.
386 #define FPDF_ERR_FILE 2 // File not found or could not be opened. 390 #define FPDF_ERR_FILE 2 // File not found or could not be opened.
387 #define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted. 391 #define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
388 #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password. 392 #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
389 #define FPDF_ERR_SECURITY 5 // Unsupported security scheme. 393 #define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
390 #define FPDF_ERR_PAGE 6 // Page not found or content error. 394 #define FPDF_ERR_PAGE 6 // Page not found or content error.
395 #ifdef PDF_ENABLE_XFA
391 #define FPDF_ERR_XFALOAD 7 // Load XFA error. 396 #define FPDF_ERR_XFALOAD 7 // Load XFA error.
392 #define FPDF_ERR_XFALAYOUT 8 // Layout XFA error. 397 #define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
398 #endif // PDF_ENABLE_XFA
393 399
394 // Function: FPDF_GetLastError 400 // Function: FPDF_GetLastError
395 // Get last error code when a function fails. 401 // Get last error code when a function fails.
396 // Parameters: 402 // Parameters:
397 // None. 403 // None.
398 // Return value: 404 // Return value:
399 // A 32-bit integer indicating error code as defined above. 405 // A 32-bit integer indicating error code as defined above.
400 // Comments: 406 // Comments:
401 // If the previous SDK call succeeded, the return value of this 407 // If the previous SDK call succeeded, the return value of this
402 // function is not defined. 408 // function is not defined.
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 // 2) Second time pass in allocated |buffer| and buflen to retrieve 911 // 2) Second time pass in allocated |buffer| and buflen to retrieve
906 // |buffer|, which should be used as wchar_t*. 912 // |buffer|, which should be used as wchar_t*.
907 // 913 //
908 // If buflen is not sufficiently large, it will be set to -1 upon 914 // If buflen is not sufficiently large, it will be set to -1 upon
909 // return. 915 // return.
910 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, 916 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
911 int index, 917 int index,
912 void* buffer, 918 void* buffer,
913 long* buflen); 919 long* buflen);
914 920
921 #ifdef PDF_ENABLE_XFA
915 // Function: FPDF_BStr_Init 922 // Function: FPDF_BStr_Init
916 // Helper function to initialize a byte string. 923 // Helper function to initialize a byte string.
917 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str); 924 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
918 925
919 // Function: FPDF_BStr_Set 926 // Function: FPDF_BStr_Set
920 // Helper function to set string data. 927 // Helper function to set string data.
921 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, 928 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
922 FPDF_LPCSTR bstr, 929 FPDF_LPCSTR bstr,
923 int length); 930 int length);
924 931
925 // Function: FPDF_BStr_Clear 932 // Function: FPDF_BStr_Clear
926 // Helper function to clear a byte string. 933 // Helper function to clear a byte string.
927 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str); 934 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
935 #endif // PDF_ENABLE_XFA
928 936
929 #ifdef __cplusplus 937 #ifdef __cplusplus
930 } 938 }
931 #endif 939 #endif
932 940
933 #endif // PUBLIC_FPDFVIEW_H_ 941 #endif // PUBLIC_FPDFVIEW_H_
OLDNEW
« no previous file with comments | « public/fpdf_formfill.h ('k') | samples/pdfium_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698