John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // 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. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | |
| 8 | #ifndef _FPDFVIEW_H_ |
| 9 | #define _FPDFVIEW_H_ |
| 10 | |
| 11 | #if defined(_WIN32) && !defined(__WINDOWS__) |
| 12 | #include <windows.h> |
| 13 | #endif |
| 14 | |
Bo Xu | bb5ef88 | 2014-11-06 16:13:33 -0800 | [diff] [blame] | 15 | // TODO: remove the #define when XFA is officially in pdfium |
| 16 | #define PDF_USE_XFA |
| 17 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 18 | // Data types |
| 19 | typedef void* FPDF_MODULEMGR; |
| 20 | |
| 21 | // PDF types |
| 22 | typedef void* FPDF_DOCUMENT; |
| 23 | typedef void* FPDF_PAGE; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 24 | typedef void* FPDF_WIDGET; |
| 25 | typedef void* FPDF_STRINGHANDLE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 26 | typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc) |
| 27 | typedef void* FPDF_PATH; |
| 28 | typedef void* FPDF_CLIPPATH; |
| 29 | typedef void* FPDF_BITMAP; |
| 30 | typedef void* FPDF_FONT; |
| 31 | |
| 32 | typedef void* FPDF_TEXTPAGE; |
| 33 | typedef void* FPDF_SCHHANDLE; |
| 34 | typedef void* FPDF_PAGELINK; |
| 35 | typedef void* FPDF_HMODULE; |
| 36 | typedef void* FPDF_DOCSCHHANDLE; |
| 37 | |
| 38 | typedef void* FPDF_BOOKMARK; |
| 39 | typedef void* FPDF_DEST; |
| 40 | typedef void* FPDF_ACTION; |
| 41 | typedef void* FPDF_LINK; |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 42 | typedef void* FPDF_PAGERANGE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 43 | |
| 44 | // Basic data types |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 45 | typedef void* FPDF_LPVOID; |
| 46 | typedef void const* FPDF_LPCVOID; |
| 47 | typedef int FPDF_RESULT; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 48 | typedef int FPDF_BOOL; |
| 49 | typedef int FPDF_ERROR; |
| 50 | typedef unsigned long FPDF_DWORD; |
| 51 | |
| 52 | typedef float FS_FLOAT; |
| 53 | |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 54 | // Duplex types |
| 55 | typedef enum _FPDF_DUPLEXTYPE_ { |
| 56 | DuplexUndefined = 0, |
| 57 | Simplex, |
| 58 | DuplexFlipShortEdge, |
| 59 | DuplexFlipLongEdge |
| 60 | } FPDF_DUPLEXTYPE; |
| 61 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 62 | // String types |
| 63 | typedef unsigned short FPDF_WCHAR; |
| 64 | typedef unsigned char const* FPDF_LPCBYTE; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 65 | typedef char const* FPDF_LPCSTR; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 66 | |
| 67 | // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE encoded), and platform dependent string |
| 68 | typedef const char* FPDF_BYTESTRING; |
| 69 | |
| 70 | typedef const unsigned short* FPDF_WIDESTRING; // Foxit PDF SDK always use UTF-16LE encoding wide string, |
| 71 | // each character use 2 bytes (except surrogation), with low byte first. |
| 72 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 73 | #ifndef _FPDF_DEF_STR_ |
| 74 | #define _FPDF_DEF_STR_ |
| 75 | /** @brief Structure for byte string. |
| 76 | * |
| 77 | * @note In SDK, a byte string commonly means a UTF-16LE format string. |
| 78 | */ |
| 79 | typedef struct _FPDF_BSTR |
| 80 | { |
| 81 | /** |
| 82 | * @brief String buffer. |
| 83 | */ |
| 84 | char* str; |
| 85 | /** |
| 86 | * @brief Length of a string, in bytes. |
| 87 | */ |
| 88 | int len; |
| 89 | } FPDF_BSTR; |
| 90 | |
| 91 | #endif |
| 92 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 93 | // For Windows programmers: for most case it's OK to treat FPDF_WIDESTRING as Windows unicode string, |
| 94 | // however, special care needs to be taken if you expect to process Unicode larger than 0xffff. |
| 95 | // For Linux/Unix programmers: most compiler/library environment uses 4 bytes for a Unicode character, |
| 96 | // you have to convert between FPDF_WIDESTRING and system wide string by yourself. |
| 97 | |
| 98 | #ifdef _WIN32_WCE |
| 99 | typedef const unsigned short* FPDF_STRING; |
| 100 | #else |
| 101 | typedef const char* FPDF_STRING; |
| 102 | #endif |
| 103 | |
| 104 | #ifndef _FS_DEF_MATRIX_ |
| 105 | #define _FS_DEF_MATRIX_ |
| 106 | /** @brief Matrix for transformation. */ |
| 107 | typedef struct _FS_MATRIX_ |
| 108 | { |
| 109 | float a; /**< @brief Coefficient a.*/ |
| 110 | float b; /**< @brief Coefficient b.*/ |
| 111 | float c; /**< @brief Coefficient c.*/ |
| 112 | float d; /**< @brief Coefficient d.*/ |
| 113 | float e; /**< @brief Coefficient e.*/ |
| 114 | float f; /**< @brief Coefficient f.*/ |
| 115 | } FS_MATRIX; |
| 116 | #endif |
| 117 | |
| 118 | #ifndef _FS_DEF_RECTF_ |
| 119 | #define _FS_DEF_RECTF_ |
| 120 | /** @brief Rectangle area(float) in device or page coordination system. */ |
| 121 | typedef struct _FS_RECTF_ |
| 122 | { |
| 123 | /**@{*/ |
| 124 | /** @brief The x-coordinate of the left-top corner. */ |
| 125 | float left; |
| 126 | /** @brief The y-coordinate of the left-top corner. */ |
| 127 | float top; |
| 128 | /** @brief The x-coordinate of the right-bottom corner. */ |
| 129 | float right; |
| 130 | /** @brief The y-coordinate of the right-bottom corner. */ |
| 131 | float bottom; |
| 132 | /**@}*/ |
| 133 | }* FS_LPRECTF, FS_RECTF; |
| 134 | /** @brief Const Pointer to ::FS_RECTF structure.*/ |
| 135 | typedef const FS_RECTF* FS_LPCRECTF; |
| 136 | #endif |
| 137 | |
| 138 | #if defined(_WIN32) && defined(FPDFSDK_EXPORTS) |
| 139 | // On Windows system, functions are exported in a DLL |
| 140 | #define DLLEXPORT __declspec( dllexport ) |
| 141 | #define STDCALL __stdcall |
| 142 | #else |
| 143 | #define DLLEXPORT |
| 144 | #define STDCALL |
| 145 | #endif |
| 146 | |
| 147 | extern const char g_ExpireDate[]; |
| 148 | extern const char g_ModuleCodes[]; |
| 149 | |
| 150 | // Exported Functions |
| 151 | #ifdef __cplusplus |
| 152 | extern "C" { |
| 153 | #endif |
| 154 | |
| 155 | // Function: FPDF_InitLibrary |
| 156 | // Initialize the FPDFSDK library |
| 157 | // Parameters: |
John Abd-El-Malek | 207299b | 2014-12-15 12:13:45 -0800 | [diff] [blame] | 158 | // None |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 159 | // Return value: |
| 160 | // None. |
| 161 | // Comments: |
| 162 | // You have to call this function before you can call any PDF processing functions. |
| 163 | |
John Abd-El-Malek | 207299b | 2014-12-15 12:13:45 -0800 | [diff] [blame] | 164 | DLLEXPORT void STDCALL FPDF_InitLibrary(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 165 | |
| 166 | |
| 167 | // Function: FPDF_DestroyLibary |
| 168 | // Release all resources allocated by the FPDFSDK library. |
| 169 | // Parameters: |
| 170 | // None. |
| 171 | // Return value: |
| 172 | // None. |
| 173 | // Comments: |
| 174 | // You can call this function to release all memory blocks allocated by the library. |
| 175 | // After this function called, you should not call any PDF processing functions. |
| 176 | DLLEXPORT void STDCALL FPDF_DestroyLibrary(); |
| 177 | |
| 178 | //Policy for accessing the local machine time. |
| 179 | #define FPDF_POLICY_MACHINETIME_ACCESS 0 |
| 180 | |
| 181 | // Function: FPDF_SetSandBoxPolicy |
| 182 | // Set the policy for the sandbox environment. |
| 183 | // Parameters: |
| 184 | // policy - The specified policy for setting, for example:FPDF_POLICY_MACHINETIME_ACCESS. |
| 185 | // enable - True for enable, False for disable the policy. |
| 186 | // Return value: |
| 187 | // None. |
| 188 | DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); |
| 189 | |
| 190 | /** |
| 191 | * Open and load a PDF document. |
| 192 | * @param[in] file_path - Path to the PDF file (including extension). |
| 193 | * @param[in] password - A string used as the password for PDF file. |
| 194 | * If no password needed, empty or NULL can be used. |
| 195 | * @note Loaded document can be closed by FPDF_CloseDocument. |
| 196 | * If this function fails, you can use FPDF_GetLastError() to retrieve |
| 197 | * the reason why it fails. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 198 | * The application should call ::FPDF_LoadXFA function after PDF document loaded |
| 199 | * to support XFA fields in fpdfformfill.h file. |
| 200 | * |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 201 | * @retval A handle to the loaded document. If failed, NULL is returned. |
| 202 | */ |
| 203 | DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, |
| 204 | FPDF_BYTESTRING password); |
| 205 | |
| 206 | // Function: FPDF_LoadMemDocument |
| 207 | // Open and load a PDF document from memory. |
| 208 | // Parameters: |
| 209 | // data_buf - Pointer to a buffer containing the PDF document. |
| 210 | // size - Number of bytes in the PDF document. |
| 211 | // password - A string used as the password for PDF file. |
| 212 | // If no password needed, empty or NULL can be used. |
| 213 | // Return value: |
| 214 | // A handle to the loaded document. If failed, NULL is returned. |
| 215 | // Comments: |
| 216 | // The memory buffer must remain valid when the document is open. |
| 217 | // Loaded document can be closed by FPDF_CloseDocument. |
| 218 | // If this function fails, you can use FPDF_GetLastError() to retrieve |
| 219 | // the reason why it fails. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 220 | // Notes: |
| 221 | // The application should call ::FPDF_LoadXFA function after PDF document loaded |
| 222 | // to support XFA fields in fpdfformfill.h file. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 223 | // |
| 224 | DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, |
| 225 | int size, FPDF_BYTESTRING password); |
| 226 | |
| 227 | // Structure for custom file access. |
| 228 | typedef struct { |
| 229 | // File length, in bytes. |
| 230 | unsigned long m_FileLen; |
| 231 | |
| 232 | // A function pointer for getting a block of data from specific position. |
| 233 | // Position is specified by byte offset from beginning of the file. |
| 234 | // The position and size will never go out range of file length. |
| 235 | // It may be possible for FPDFSDK to call this function multiple times for same position. |
| 236 | // Return value: should be non-zero if successful, zero for error. |
| 237 | int (*m_GetBlock)(void* param, unsigned long position, unsigned char* pBuf, unsigned long size); |
| 238 | |
| 239 | // A custom pointer for all implementation specific data. |
| 240 | // This pointer will be used as the first parameter to m_GetBlock callback. |
| 241 | void* m_Param; |
| 242 | } FPDF_FILEACCESS; |
| 243 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 244 | /** |
| 245 | * @brief Structure for file reading or writing (I/O). |
| 246 | * |
| 247 | * @note This is a handler and should be implemented by callers. |
| 248 | */ |
| 249 | typedef struct _FPDF_FILEHANDLER |
| 250 | { |
| 251 | /** |
| 252 | * @brief User-defined data. |
| 253 | * @note Callers can use this field to track controls. |
| 254 | */ |
| 255 | FPDF_LPVOID clientData; |
| 256 | /** |
| 257 | * @brief Callback function to release the current file stream object. |
| 258 | * |
| 259 | * @param[in] clientData Pointer to user-defined data. |
| 260 | * |
| 261 | * @return None. |
| 262 | */ |
| 263 | void (*Release)(FPDF_LPVOID clientData); |
| 264 | /** |
| 265 | * @brief Callback function to retrieve the current file stream size. |
| 266 | * |
| 267 | * @param[in] clientData Pointer to user-defined data. |
| 268 | * |
| 269 | * @return Size of file stream. |
| 270 | */ |
| 271 | FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData); |
| 272 | /** |
| 273 | * @brief Callback function to read data from the current file stream. |
| 274 | * |
| 275 | * @param[in] clientData Pointer to user-defined data. |
| 276 | * @param[in] offset Offset position starts from the beginning of file stream. This parameter indicates reading position. |
| 277 | * @param[in] buffer Memory buffer to store data which are read from file stream. This parameter should not be <b>NULL</b>. |
| 278 | * @param[in] size Size of data which should be read from file stream, in bytes. The buffer indicated by the parameter <i>buffer</i> should be enough to store specified data. |
| 279 | * |
| 280 | * @return 0 for success, other value for failure. |
| 281 | */ |
| 282 | FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size); |
| 283 | /** |
| 284 | * @brief Callback function to write data into the current file stream. |
| 285 | * |
| 286 | * @param[in] clientData Pointer to user-defined data. |
| 287 | * @param[in] offset Offset position starts from the beginning of file stream. This parameter indicates writing position. |
| 288 | * @param[in] buffer Memory buffer contains data which is written into file stream. This parameter should not be <b>NULL</b>. |
| 289 | * @param[in] size Size of data which should be written into file stream, in bytes. |
| 290 | * |
| 291 | * @return 0 for success, other value for failure. |
| 292 | */ |
| 293 | FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size); |
| 294 | /** |
| 295 | * @brief Callback function to flush all internal accessing buffers. |
| 296 | * |
| 297 | * @param[in] clientData Pointer to user-defined data. |
| 298 | * |
| 299 | * @return 0 for success, other value for failure. |
| 300 | */ |
| 301 | FPDF_RESULT (*Flush)(FPDF_LPVOID clientData); |
| 302 | /** |
| 303 | * @brief Callback function to change file size. |
| 304 | * |
| 305 | * @details This function is called under writing mode usually. Implementer can determine whether to realize it based on application requests. |
| 306 | * |
| 307 | * @param[in] clientData Pointer to user-defined data. |
| 308 | * @param[in] size New size of file stream, in bytes. |
| 309 | * |
| 310 | * @return 0 for success, other value for failure. |
| 311 | */ |
| 312 | FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size); |
| 313 | |
| 314 | } FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER; |
| 315 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 316 | // Function: FPDF_LoadCustomDocument |
| 317 | // Load PDF document from a custom access descriptor. |
| 318 | // Parameters: |
| 319 | // pFileAccess - A structure for access the file. |
| 320 | // password - Optional password for decrypting the PDF file. |
| 321 | // Return value: |
| 322 | // A handle to the loaded document. If failed, NULL is returned. |
| 323 | // Comments: |
| 324 | // The application should maintain the file resources being valid until the PDF document close. |
| 325 | // Loaded document can be closed by FPDF_CloseDocument. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 326 | // Notes: |
| 327 | // The application should call ::FPDF_LoadXFA function after PDF document loaded |
| 328 | // to support XFA fields in fpdfformfill.h file. |
| 329 | // |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 330 | DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, |
| 331 | FPDF_BYTESTRING password); |
| 332 | |
| 333 | // Function: FPDF_GetFileVersion |
| 334 | // Get the file version of the specific PDF document. |
| 335 | // Parameters: |
| 336 | // doc - Handle to document. |
| 337 | // fileVersion - The PDF file version. File version: 14 for 1.4, 15 for 1.5, ... |
| 338 | // Return value: |
| 339 | // TRUE if this call succeed, If failed, FALSE is returned. |
| 340 | // Comments: |
| 341 | // If the document is created by function ::FPDF_CreateNewDocument, then this function would always fail. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 342 | // |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 343 | DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVersion); |
| 344 | |
| 345 | #define FPDF_ERR_SUCCESS 0 // No error. |
| 346 | #define FPDF_ERR_UNKNOWN 1 // Unknown error. |
| 347 | #define FPDF_ERR_FILE 2 // File not found or could not be opened. |
| 348 | #define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted. |
| 349 | #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password. |
| 350 | #define FPDF_ERR_SECURITY 5 // Unsupported security scheme. |
| 351 | #define FPDF_ERR_PAGE 6 // Page not found or content error. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 352 | #define FPDF_ERR_XFALOAD 7 // Load XFA error. |
| 353 | #define FPDF_ERR_XFALAYOUT 8 // Layout XFA error. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 354 | |
| 355 | // Function: FPDF_GetLastError |
| 356 | // Get last error code when an SDK function failed. |
| 357 | // Parameters: |
| 358 | // None. |
| 359 | // Return value: |
| 360 | // A 32-bit integer indicating error codes (defined above). |
| 361 | // Comments: |
| 362 | // If the previous SDK call succeeded, the return value of this function |
| 363 | // is not defined. |
| 364 | // |
| 365 | DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); |
| 366 | |
| 367 | // Function: FPDF_GetDocPermission |
| 368 | // Get file permission flags of the document. |
| 369 | // Parameters: |
| 370 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 371 | // Return value: |
| 372 | // A 32-bit integer indicating permission flags. Please refer to PDF Reference for |
| 373 | // detailed description. If the document is not protected, 0xffffffff will be returned. |
| 374 | // |
| 375 | DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); |
| 376 | |
Bo Xu | c5cab02 | 2014-09-19 19:16:31 -0700 | [diff] [blame] | 377 | // Function: FPDF_GetSecurityHandlerRevision |
| 378 | // Get the revision for security handler. |
| 379 | // Parameters: |
| 380 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 381 | // Return value: |
| 382 | // The security handler revision number. Please refer to PDF Reference for |
| 383 | // detailed description. If the document is not protected, -1 will be returned. |
| 384 | // |
| 385 | DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); |
| 386 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 387 | // Function: FPDF_GetPageCount |
| 388 | // Get total number of pages in a document. |
| 389 | // Parameters: |
| 390 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 391 | // Return value: |
| 392 | // Total number of pages in the document. |
| 393 | // |
| 394 | DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); |
| 395 | |
| 396 | // Function: FPDF_LoadPage |
| 397 | // Load a page inside a document. |
| 398 | // Parameters: |
| 399 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 400 | // page_index - Index number of the page. 0 for the first page. |
| 401 | // Return value: |
| 402 | // A handle to the loaded page. If failed, NULL is returned. |
| 403 | // Comments: |
| 404 | // Loaded page can be rendered to devices using FPDF_RenderPage function. |
| 405 | // Loaded page can be closed by FPDF_ClosePage. |
| 406 | // |
| 407 | DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index); |
| 408 | |
| 409 | // Function: FPDF_GetPageWidth |
| 410 | // Get page width. |
| 411 | // Parameters: |
| 412 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 413 | // Return value: |
| 414 | // Page width (excluding non-displayable area) measured in points. |
| 415 | // One point is 1/72 inch (around 0.3528 mm). |
| 416 | // |
| 417 | DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); |
| 418 | |
| 419 | // Function: FPDF_GetPageHeight |
| 420 | // Get page height. |
| 421 | // Parameters: |
| 422 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 423 | // Return value: |
| 424 | // Page height (excluding non-displayable area) measured in points. |
| 425 | // One point is 1/72 inch (around 0.3528 mm) |
| 426 | // |
| 427 | DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); |
| 428 | |
| 429 | // Function: FPDF_GetPageSizeByIndex |
| 430 | // Get the size of a page by index. |
| 431 | // Parameters: |
| 432 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 433 | // page_index - Page index, zero for the first page. |
| 434 | // width - Pointer to a double value receiving the page width (in points). |
| 435 | // height - Pointer to a double value receiving the page height (in points). |
| 436 | // Return value: |
| 437 | // Non-zero for success. 0 for error (document or page not found). |
| 438 | // |
| 439 | DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, double* width, double* height); |
| 440 | |
| 441 | |
| 442 | // Page rendering flags. They can be combined with bit OR. |
| 443 | #define FPDF_ANNOT 0x01 // Set if annotations are to be rendered. |
| 444 | #define FPDF_LCD_TEXT 0x02 // Set if using text rendering optimized for LCD display. |
| 445 | #define FPDF_NO_NATIVETEXT 0x04 // Don't use the native text output available on some platforms |
| 446 | #define FPDF_GRAYSCALE 0x08 // Grayscale output. |
| 447 | #define FPDF_DEBUG_INFO 0x80 // Set if you want to get some debug info. |
| 448 | // Please discuss with Foxit first if you need to collect debug info. |
| 449 | #define FPDF_NO_CATCH 0x100 // Set if you don't want to catch exception. |
| 450 | #define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 // Limit image cache size. |
| 451 | #define FPDF_RENDER_FORCEHALFTONE 0x400 // Always use halftone for image stretching. |
| 452 | #define FPDF_PRINTING 0x800 // Render for printing. |
| 453 | #define FPDF_REVERSE_BYTE_ORDER 0x10 //set whether render in a reverse Byte order, this flag only |
| 454 | //enable when render to a bitmap. |
| 455 | #ifdef _WIN32 |
| 456 | // Function: FPDF_RenderPage |
| 457 | // Render contents in a page to a device (screen, bitmap, or printer). |
| 458 | // This function is only supported on Windows system. |
| 459 | // Parameters: |
| 460 | // dc - Handle to device context. |
| 461 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 462 | // start_x - Left pixel position of the display area in the device coordinate. |
| 463 | // start_y - Top pixel position of the display area in the device coordinate. |
| 464 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 465 | // size_y - Vertical size (in pixels) for displaying the page. |
| 466 | // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), |
| 467 | // 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). |
| 468 | // flags - 0 for normal display, or combination of flags defined above. |
| 469 | // Return value: |
| 470 | // None. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 471 | // Notes: |
| 472 | // The method can not support to render the page for the document consists of dynamic XFA fields. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 473 | // |
| 474 | DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, |
| 475 | int rotate, int flags); |
| 476 | #endif |
| 477 | |
| 478 | // Function: FPDF_RenderPageBitmap |
| 479 | // Render contents in a page to a device independent bitmap |
| 480 | // Parameters: |
| 481 | // bitmap - Handle to the device independent bitmap (as the output buffer). |
| 482 | // Bitmap handle can be created by FPDFBitmap_Create function. |
| 483 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 484 | // start_x - Left pixel position of the display area in the bitmap coordinate. |
| 485 | // start_y - Top pixel position of the display area in the bitmap coordinate. |
| 486 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 487 | // size_y - Vertical size (in pixels) for displaying the page. |
| 488 | // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), |
| 489 | // 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). |
| 490 | // flags - 0 for normal display, or combination of flags defined above. |
| 491 | // Return value: |
| 492 | // None. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 493 | // Notes: |
| 494 | // The method can not support to render the page for the document consists of dynamic XFA fields. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 495 | // |
| 496 | DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, |
| 497 | int size_x, int size_y, int rotate, int flags); |
| 498 | |
| 499 | // Function: FPDF_ClosePage |
| 500 | // Close a loaded PDF page. |
| 501 | // Parameters: |
| 502 | // page - Handle to the loaded page. |
| 503 | // Return value: |
| 504 | // None. |
| 505 | // |
| 506 | DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); |
| 507 | |
| 508 | // Function: FPDF_CloseDocument |
| 509 | // Close a loaded PDF document. |
| 510 | // Parameters: |
| 511 | // document - Handle to the loaded document. |
| 512 | // Return value: |
| 513 | // None. |
| 514 | // |
| 515 | DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); |
| 516 | |
| 517 | // Function: FPDF_DeviceToPage |
| 518 | // Convert the screen coordinate of a point to page coordinate. |
| 519 | // Parameters: |
| 520 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 521 | // start_x - Left pixel position of the display area in the device coordinate. |
| 522 | // start_y - Top pixel position of the display area in the device coordinate. |
| 523 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 524 | // size_y - Vertical size (in pixels) for displaying the page. |
| 525 | // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), |
| 526 | // 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). |
| 527 | // device_x - X value in device coordinate, for the point to be converted. |
| 528 | // device_y - Y value in device coordinate, for the point to be converted. |
| 529 | // page_x - A Pointer to a double receiving the converted X value in page coordinate. |
| 530 | // page_y - A Pointer to a double receiving the converted Y value in page coordinate. |
| 531 | // Return value: |
| 532 | // None. |
| 533 | // Comments: |
| 534 | // The page coordinate system has its origin at left-bottom corner of the page, with X axis goes along |
| 535 | // the bottom side to the right, and Y axis goes along the left side upward. NOTE: this coordinate system |
| 536 | // can be altered when you zoom, scroll, or rotate a page, however, a point on the page should always have |
| 537 | // the same coordinate values in the page coordinate system. |
| 538 | // |
| 539 | // The device coordinate system is device dependent. For screen device, its origin is at left-top |
| 540 | // corner of the window. However this origin can be altered by Windows coordinate transformation |
| 541 | // utilities. You must make sure the start_x, start_y, size_x, size_y and rotate parameters have exactly |
| 542 | // same values as you used in FPDF_RenderPage() function call. |
| 543 | // |
| 544 | DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, |
| 545 | int rotate, int device_x, int device_y, double* page_x, double* page_y); |
| 546 | |
| 547 | // Function: FPDF_PageToDevice |
| 548 | // Convert the page coordinate of a point to screen coordinate. |
| 549 | // Parameters: |
| 550 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 551 | // start_x - Left pixel position of the display area in the device coordinate. |
| 552 | // start_y - Top pixel position of the display area in the device coordinate. |
| 553 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 554 | // size_y - Vertical size (in pixels) for displaying the page. |
| 555 | // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), |
| 556 | // 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). |
| 557 | // page_x - X value in page coordinate, for the point to be converted. |
| 558 | // page_y - Y value in page coordinate, for the point to be converted. |
| 559 | // device_x - A pointer to an integer receiving the result X value in device coordinate. |
| 560 | // device_y - A pointer to an integer receiving the result Y value in device coordinate. |
| 561 | // Return value: |
| 562 | // None. |
| 563 | // Comments: |
| 564 | // See comments of FPDF_DeviceToPage() function. |
| 565 | // |
| 566 | DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, |
| 567 | int rotate, double page_x, double page_y, int* device_x, int* device_y); |
| 568 | |
| 569 | // Function: FPDFBitmap_Create |
| 570 | // Create a Foxit Device Independent Bitmap (FXDIB). |
| 571 | // Parameters: |
| 572 | // width - Number of pixels in a horizontal line of the bitmap. Must be greater than 0. |
| 573 | // height - Number of pixels in a vertical line of the bitmap. Must be greater than 0. |
| 574 | // alpha - A flag indicating whether alpha channel is used. Non-zero for using alpha, zero for not using. |
| 575 | // Return value: |
| 576 | // The created bitmap handle, or NULL if parameter error or out of memory. |
| 577 | // Comments: |
| 578 | // An FXDIB always use 4 byte per pixel. The first byte of a pixel is always double word aligned. |
| 579 | // Each pixel contains red (R), green (G), blue (B) and optionally alpha (A) values. |
| 580 | // The byte order is BGRx (the last byte unused if no alpha channel) or BGRA. |
| 581 | // |
| 582 | // The pixels in a horizontal line (also called scan line) are stored side by side, with left most |
| 583 | // pixel stored first (with lower memory address). Each scan line uses width*4 bytes. |
| 584 | // |
| 585 | // Scan lines are stored one after another, with top most scan line stored first. There is no gap |
| 586 | // between adjacent scan lines. |
| 587 | // |
| 588 | // This function allocates enough memory for holding all pixels in the bitmap, but it doesn't |
| 589 | // initialize the buffer. Applications can use FPDFBitmap_FillRect to fill the bitmap using any color. |
| 590 | DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha); |
| 591 | |
| 592 | // More DIB formats |
| 593 | #define FPDFBitmap_Gray 1 // Gray scale bitmap, one byte per pixel. |
| 594 | #define FPDFBitmap_BGR 2 // 3 bytes per pixel, byte order: blue, green, red. |
| 595 | #define FPDFBitmap_BGRx 3 // 4 bytes per pixel, byte order: blue, green, red, unused. |
| 596 | #define FPDFBitmap_BGRA 4 // 4 bytes per pixel, byte order: blue, green, red, alpha. |
| 597 | |
| 598 | // Function: FPDFBitmap_CreateEx |
| 599 | // Create a Foxit Device Independent Bitmap (FXDIB) |
| 600 | // Parameters: |
| 601 | // width - Number of pixels in a horizontal line of the bitmap. Must be greater than 0. |
| 602 | // height - Number of pixels in a vertical line of the bitmap. Must be greater than 0. |
| 603 | // format - A number indicating for bitmap format, as defined above. |
| 604 | // first_scan - A pointer to the first byte of first scan line, for external buffer |
| 605 | // only. If this parameter is NULL, then the SDK will create its own buffer. |
| 606 | // stride - Number of bytes for each scan line, for external buffer only.. |
| 607 | // Return value: |
| 608 | // The created bitmap handle, or NULL if parameter error or out of memory. |
| 609 | // Comments: |
| 610 | // Similar to FPDFBitmap_Create function, with more formats and external buffer supported. |
| 611 | // Bitmap created by this function can be used in any place that a FPDF_BITMAP handle is |
| 612 | // required. |
| 613 | // |
| 614 | // If external scanline buffer is used, then the application should destroy the buffer |
| 615 | // by itself. FPDFBitmap_Destroy function will not destroy the buffer. |
| 616 | // |
| 617 | DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, int height, int format, void* first_scan, int stride); |
| 618 | |
| 619 | // Function: FPDFBitmap_FillRect |
| 620 | // Fill a rectangle area in an FXDIB. |
| 621 | // Parameters: |
| 622 | // bitmap - The handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 623 | // left - The left side position. Starting from 0 at the left-most pixel. |
| 624 | // top - The top side position. Starting from 0 at the top-most scan line. |
| 625 | // width - Number of pixels to be filled in each scan line. |
| 626 | // height - Number of scan lines to be filled. |
Lei Zhang | 532a6a7 | 2014-07-09 11:47:15 -0700 | [diff] [blame] | 627 | // color - A 32-bit value specifing the color, in 8888 ARGB format. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 628 | // Return value: |
| 629 | // None. |
| 630 | // Comments: |
| 631 | // This function set the color and (optionally) alpha value in specified region of the bitmap. |
| 632 | // NOTE: If alpha channel is used, this function does NOT composite the background with the source color, |
| 633 | // instead the background will be replaced by the source color and alpha. |
| 634 | // If alpha channel is not used, the "alpha" parameter is ignored. |
| 635 | // |
Lei Zhang | 532a6a7 | 2014-07-09 11:47:15 -0700 | [diff] [blame] | 636 | DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top, int width, int height, FPDF_DWORD color); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 637 | |
| 638 | // Function: FPDFBitmap_GetBuffer |
| 639 | // Get data buffer of an FXDIB |
| 640 | // Parameters: |
| 641 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 642 | // Return value: |
| 643 | // The pointer to the first byte of the bitmap buffer. |
| 644 | // Comments: |
| 645 | // The stride may be more than width * number of bytes per pixel |
| 646 | // Applications can use this function to get the bitmap buffer pointer, then manipulate any color |
| 647 | // and/or alpha values for any pixels in the bitmap. |
| 648 | DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); |
| 649 | |
| 650 | // Function: FPDFBitmap_GetWidth |
| 651 | // Get width of an FXDIB. |
| 652 | // Parameters: |
| 653 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 654 | // Return value: |
| 655 | // The number of pixels in a horizontal line of the bitmap. |
| 656 | DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); |
| 657 | |
| 658 | // Function: FPDFBitmap_GetHeight |
| 659 | // Get height of an FXDIB. |
| 660 | // Parameters: |
| 661 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 662 | // Return value: |
| 663 | // The number of pixels in a vertical line of the bitmap. |
| 664 | DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); |
| 665 | |
| 666 | // Function: FPDFBitmap_GetStride |
| 667 | // Get number of bytes for each scan line in the bitmap buffer. |
| 668 | // Parameters: |
| 669 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 670 | // Return value: |
| 671 | // The number of bytes for each scan line in the bitmap buffer. |
| 672 | // Comments: |
| 673 | // The stride may be more than width * number of bytes per pixel |
| 674 | DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap); |
| 675 | |
| 676 | // Function: FPDFBitmap_Destroy |
| 677 | // Destroy an FXDIB and release all related buffers. |
| 678 | // Parameters: |
| 679 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 680 | // Return value: |
| 681 | // None. |
| 682 | // Comments: |
| 683 | // This function will not destroy any external buffer. |
| 684 | // |
| 685 | DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); |
| 686 | |
| 687 | // Function: FPDF_VIEWERREF_GetPrintScaling |
| 688 | // Whether the PDF document prefers to be scaled or not. |
| 689 | // Parameters: |
| 690 | // document - Handle to the loaded document. |
| 691 | // Return value: |
| 692 | // None. |
| 693 | // |
| 694 | DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); |
| 695 | |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 696 | // Function: FPDF_VIEWERREF_GetNumCopies |
| 697 | // Returns the number of copies to be printed. |
| 698 | // Parameters: |
| 699 | // document - Handle to the loaded document. |
| 700 | // Return value: |
| 701 | // The number of copies to be printed. |
| 702 | // |
| 703 | DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); |
| 704 | |
| 705 | // Function: FPDF_VIEWERREF_GetPrintPageRange |
| 706 | // Page numbers to initialize print dialog box when file is printed. |
| 707 | // Parameters: |
| 708 | // document - Handle to the loaded document. |
| 709 | // Return value: |
| 710 | // The print page range to be used for printing. |
| 711 | // |
| 712 | DLLEXPORT FPDF_PAGERANGE STDCALL FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); |
| 713 | |
| 714 | // Function: FPDF_VIEWERREF_GetDuplex |
| 715 | // Returns the paper handling option to be used when printing from print dialog. |
| 716 | // Parameters: |
| 717 | // document - Handle to the loaded document. |
| 718 | // Return value: |
| 719 | // The paper handling option to be used when printing. |
| 720 | // |
| 721 | DLLEXPORT FPDF_DUPLEXTYPE STDCALL FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document); |
| 722 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 723 | // Function: FPDF_GetNamedDestByName |
| 724 | // get a special dest handle by the index. |
| 725 | // Parameters: |
| 726 | // document - Handle to the loaded document. |
| 727 | // name - The name of a special named dest. |
| 728 | // Return value: |
| 729 | // The handle of the dest. |
| 730 | // |
| 731 | DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_BYTESTRING name); |
| 732 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 733 | // Function: FPDF_BStr_Init |
| 734 | // Helper function to initialize a byte string. |
| 735 | DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str); |
| 736 | |
| 737 | // Function: FPDF_BStr_Set |
| 738 | // Helper function to set string data. |
| 739 | DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, FPDF_LPCSTR bstr, int length); |
| 740 | |
| 741 | // Function: FPDF_BStr_Clear |
| 742 | // Helper function to clear a byte string. |
| 743 | DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str); |
| 744 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 745 | #ifdef __cplusplus |
| 746 | }; |
| 747 | #endif |
| 748 | |
| 749 | #endif // _FPDFVIEW_H_ |