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. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 1ed8a21 | 2015-05-11 15:25:39 -0700 | [diff] [blame] | 7 | // NOTE: External docs refer to this file as "fpdfview.h", so do not rename |
| 8 | // despite lack of consitency with other public files. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 10 | #ifndef PUBLIC_FPDFVIEW_H_ |
| 11 | #define PUBLIC_FPDFVIEW_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 12 | |
| 13 | #if defined(_WIN32) && !defined(__WINDOWS__) |
| 14 | #include <windows.h> |
| 15 | #endif |
| 16 | |
Bo Xu | bb5ef88 | 2014-11-06 16:13:33 -0800 | [diff] [blame] | 17 | // TODO: remove the #define when XFA is officially in pdfium |
| 18 | #define PDF_USE_XFA |
| 19 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 20 | // Data types |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 21 | typedef void* FPDF_MODULEMGR; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 22 | |
| 23 | // PDF types |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 24 | typedef void* FPDF_DOCUMENT; |
| 25 | typedef void* FPDF_PAGE; |
| 26 | typedef void* FPDF_WIDGET; |
| 27 | typedef void* FPDF_STRINGHANDLE; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 28 | typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc) |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 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; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 43 | |
| 44 | // Basic data types |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 45 | typedef void* FPDF_LPVOID; |
| 46 | typedef void const* FPDF_LPCVOID; |
| 47 | typedef int FPDF_RESULT; |
| 48 | typedef int FPDF_BOOL; |
| 49 | typedef int FPDF_ERROR; |
| 50 | typedef unsigned long FPDF_DWORD; |
| 51 | typedef float FS_FLOAT; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 52 | |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 53 | // Duplex types |
| 54 | typedef enum _FPDF_DUPLEXTYPE_ { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 55 | DuplexUndefined = 0, |
| 56 | Simplex, |
| 57 | DuplexFlipShortEdge, |
| 58 | DuplexFlipLongEdge |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 59 | } FPDF_DUPLEXTYPE; |
| 60 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 61 | // String types |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 62 | typedef unsigned short FPDF_WCHAR; |
| 63 | typedef unsigned char const* FPDF_LPCBYTE; |
| 64 | typedef char const* FPDF_LPCSTR; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 65 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 66 | // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE |
| 67 | // encoded), and platform dependent string |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 68 | typedef const char* FPDF_BYTESTRING; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 69 | |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 70 | // FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2 |
| 71 | // bytes (except surrogation), with the low byte first. |
| 72 | typedef const unsigned short* FPDF_WIDESTRING; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 73 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 74 | #ifndef _FPDF_DEF_STR_ |
| 75 | #define _FPDF_DEF_STR_ |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 76 | // Structure for a byte string. |
| 77 | // Note, a byte string commonly means a UTF-16LE formated string. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 78 | typedef struct _FPDF_BSTR { |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 79 | // String buffer. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 80 | char* str; |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 81 | // Length of the string, in bytes. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 82 | int len; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 83 | } FPDF_BSTR; |
| 84 | |
| 85 | #endif |
| 86 | |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 87 | // 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 |
| 89 | // expect to process Unicode larger than 0xffff. |
| 90 | // |
| 91 | // 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 |
| 93 | // system wide string by yourself. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 94 | |
| 95 | #ifdef _WIN32_WCE |
| 96 | typedef const unsigned short* FPDF_STRING; |
| 97 | #else |
| 98 | typedef const char* FPDF_STRING; |
| 99 | #endif |
| 100 | |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 101 | // Matrix for transformation. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 102 | typedef struct _FS_MATRIX_ { |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 103 | float a; |
| 104 | float b; |
| 105 | float c; |
| 106 | float d; |
| 107 | float e; |
| 108 | float f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 109 | } FS_MATRIX; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 110 | |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 111 | // Rectangle area(float) in device or page coordinate system. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 112 | typedef struct _FS_RECTF_ { |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 113 | // The x-coordinate of the left-top corner. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 114 | float left; |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 115 | // The y-coordinate of the left-top corner. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 116 | float top; |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 117 | // The x-coordinate of the right-bottom corner. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 118 | float right; |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 119 | // The y-coordinate of the right-bottom corner. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 120 | float bottom; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 121 | } * FS_LPRECTF, FS_RECTF; |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 122 | |
| 123 | // Const Pointer to FS_RECTF structure. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 124 | typedef const FS_RECTF* FS_LPCRECTF; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 125 | |
| 126 | #if defined(_WIN32) && defined(FPDFSDK_EXPORTS) |
| 127 | // On Windows system, functions are exported in a DLL |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 128 | #define DLLEXPORT __declspec(dllexport) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 129 | #define STDCALL __stdcall |
| 130 | #else |
| 131 | #define DLLEXPORT |
| 132 | #define STDCALL |
| 133 | #endif |
| 134 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 135 | // Exported Functions |
| 136 | #ifdef __cplusplus |
| 137 | extern "C" { |
| 138 | #endif |
| 139 | |
| 140 | // Function: FPDF_InitLibrary |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 141 | // Initialize the FPDFSDK library |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 142 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 143 | // None |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 144 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 145 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 146 | // Comments: |
Lei Zhang | 6f62d53 | 2015-09-23 15:31:44 -0700 | [diff] [blame] | 147 | // Convenience function to call FPDF_InitLibraryWithConfig() for |
| 148 | // backwards comatibility purposes. |
| 149 | DLLEXPORT void STDCALL FPDF_InitLibrary(); |
| 150 | |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 151 | // Process-wide options for initializing the library. |
Lei Zhang | 6f62d53 | 2015-09-23 15:31:44 -0700 | [diff] [blame] | 152 | typedef struct FPDF_LIBRARY_CONFIG_ { |
Tom Sepez | a72e8e2 | 2015-10-07 10:17:53 -0700 | [diff] [blame] | 153 | // Version number of the interface. Currently must be 2. |
Lei Zhang | 6f62d53 | 2015-09-23 15:31:44 -0700 | [diff] [blame] | 154 | int version; |
| 155 | |
| 156 | // Array of paths to scan in place of the defaults when using built-in |
| 157 | // FXGE font loading code. The array is terminated by a NULL pointer. |
| 158 | // The Array may be NULL itself to use the default paths. May be ignored |
| 159 | // entirely depending upon the platform. |
| 160 | const char** m_pUserFontPaths; |
Tom Sepez | a72e8e2 | 2015-10-07 10:17:53 -0700 | [diff] [blame] | 161 | |
| 162 | // Version 2. |
| 163 | |
| 164 | // pointer to the v8::Isolate to use, or NULL to force PDFium to create one. |
| 165 | void* m_pIsolate; |
| 166 | |
| 167 | // The embedder data slot to use in the v8::Isolate to store PDFium's |
| 168 | // per-isolate data. The value needs to be between 0 and |
| 169 | // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine |
| 170 | // for most embedders. |
| 171 | unsigned int m_v8EmbedderSlot; |
Lei Zhang | 6f62d53 | 2015-09-23 15:31:44 -0700 | [diff] [blame] | 172 | } FPDF_LIBRARY_CONFIG; |
| 173 | |
| 174 | // Function: FPDF_InitLibraryWithConfig |
| 175 | // Initialize the FPDFSDK library |
| 176 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 177 | // config - configuration information as above. |
Lei Zhang | 6f62d53 | 2015-09-23 15:31:44 -0700 | [diff] [blame] | 178 | // Return value: |
| 179 | // None. |
| 180 | // Comments: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 181 | // You have to call this function before you can call any PDF |
| 182 | // processing functions. |
Tom Sepez | 326a2a7 | 2015-11-20 10:47:32 -0800 | [diff] [blame] | 183 | DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( |
| 184 | const FPDF_LIBRARY_CONFIG* config); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 185 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 186 | // Function: FPDF_DestroyLibary |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 187 | // Release all resources allocated by the FPDFSDK library. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 188 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 189 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 190 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 191 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 192 | // Comments: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 193 | // You can call this function to release all memory blocks allocated by |
| 194 | // the library. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 195 | // After this function is called, you should not call any PDF |
| 196 | // processing functions. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 197 | DLLEXPORT void STDCALL FPDF_DestroyLibrary(); |
| 198 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 199 | // Policy for accessing the local machine time. |
| 200 | #define FPDF_POLICY_MACHINETIME_ACCESS 0 |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 201 | |
| 202 | // Function: FPDF_SetSandBoxPolicy |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 203 | // Set the policy for the sandbox environment. |
| 204 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 205 | // policy - The specified policy for setting, for example: |
| 206 | // FPDF_POLICY_MACHINETIME_ACCESS. |
| 207 | // enable - True to enable, false to disable the policy. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 208 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 209 | // None. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 210 | DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, |
| 211 | FPDF_BOOL enable); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 212 | |
Tom Sepez | 3c3201f | 2015-05-20 10:20:35 -0700 | [diff] [blame] | 213 | // Function: FPDF_LoadDocument |
| 214 | // Open and load a PDF document. |
| 215 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 216 | // file_path - Path to the PDF file (including extension). |
| 217 | // password - A string used as the password for the PDF file. |
| 218 | // If no password is needed, empty or NULL can be used. |
Tom Sepez | 3c3201f | 2015-05-20 10:20:35 -0700 | [diff] [blame] | 219 | // Return value: |
| 220 | // A handle to the loaded document, or NULL on failure. |
| 221 | // Comments: |
| 222 | // Loaded document can be closed by FPDF_CloseDocument(). |
| 223 | // If this function fails, you can use FPDF_GetLastError() to retrieve |
| 224 | // the reason why it failed. |
Tom Sepez | 326a2a7 | 2015-11-20 10:47:32 -0800 | [diff] [blame] | 225 | // Notes: |
| 226 | // The application should call FPDF_LoadXFA function after PDF |
| 227 | // document loaded to support XFA fields in fpdfformfill.h file. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 228 | DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 229 | FPDF_BYTESTRING password); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 230 | |
| 231 | // Function: FPDF_LoadMemDocument |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 232 | // Open and load a PDF document from memory. |
| 233 | // Parameters: |
| 234 | // data_buf - Pointer to a buffer containing the PDF document. |
| 235 | // size - Number of bytes in the PDF document. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 236 | // password - A string used as the password for the PDF file. |
| 237 | // If no password is needed, empty or NULL can be used. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 238 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 239 | // A handle to the loaded document, or NULL on failure. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 240 | // Comments: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 241 | // The memory buffer must remain valid when the document is open. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 242 | // The loaded document can be closed by FPDF_CloseDocument. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 243 | // If this function fails, you can use FPDF_GetLastError() to retrieve |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 244 | // the reason why it failed. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 245 | // Notes: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 246 | // The application should call FPDF_LoadXFA function after the |
| 247 | // document is loaded to support form fields. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 248 | DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 249 | int size, |
| 250 | FPDF_BYTESTRING password); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 251 | |
| 252 | // Structure for custom file access. |
| 253 | typedef struct { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 254 | // File length, in bytes. |
| 255 | unsigned long m_FileLen; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 256 | |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 257 | // 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 | // The position and size will never go out of range of the file length. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 260 | // It may be possible for FPDFSDK to call this function multiple times for |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 261 | // the same position. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 262 | // Return value: should be non-zero if successful, zero for error. |
| 263 | int (*m_GetBlock)(void* param, |
| 264 | unsigned long position, |
| 265 | unsigned char* pBuf, |
| 266 | unsigned long size); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 267 | |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 268 | // A custom pointer for all implementation specific data. This pointer will |
| 269 | // be used as the first parameter to the m_GetBlock callback. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 270 | void* m_Param; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 271 | } FPDF_FILEACCESS; |
| 272 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 273 | /** |
| 274 | * @brief Structure for file reading or writing (I/O). |
| 275 | * |
| 276 | * @note This is a handler and should be implemented by callers. |
| 277 | */ |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 278 | typedef struct _FPDF_FILEHANDLER { |
| 279 | /** |
| 280 | * @brief User-defined data. |
| 281 | * @note Callers can use this field to track controls. |
| 282 | */ |
| 283 | FPDF_LPVOID clientData; |
| 284 | /** |
| 285 | * @brief Callback function to release the current file stream object. |
| 286 | * |
| 287 | * @param[in] clientData Pointer to user-defined data. |
| 288 | * |
| 289 | * @return None. |
| 290 | */ |
| 291 | void (*Release)(FPDF_LPVOID clientData); |
| 292 | /** |
| 293 | * @brief Callback function to retrieve the current file stream size. |
| 294 | * |
| 295 | * @param[in] clientData Pointer to user-defined data. |
| 296 | * |
| 297 | * @return Size of file stream. |
| 298 | */ |
| 299 | FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData); |
| 300 | /** |
| 301 | * @brief Callback function to read data from the current file stream. |
| 302 | * |
| 303 | * @param[in] clientData Pointer to user-defined data. |
| 304 | * @param[in] offset Offset position starts from the beginning of file |
| 305 | * stream. This parameter indicates reading position. |
| 306 | * @param[in] buffer Memory buffer to store data which are read from |
| 307 | * file stream. This parameter should not be <b>NULL</b>. |
| 308 | * @param[in] size Size of data which should be read from file |
| 309 | * stream, in bytes. The buffer indicated by the parameter <i>buffer</i> |
| 310 | * should be enough to store specified data. |
| 311 | * |
| 312 | * @return 0 for success, other value for failure. |
| 313 | */ |
| 314 | FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size); |
| 315 | /** |
| 316 | * @brief Callback function to write data into the current file stream. |
| 317 | * |
| 318 | * @param[in] clientData Pointer to user-defined data. |
| 319 | * @param[in] offset Offset position starts from the beginning of file |
| 320 | * stream. This parameter indicates writing position. |
| 321 | * @param[in] buffer Memory buffer contains data which is written into |
| 322 | * file stream. This parameter should not be <b>NULL</b>. |
| 323 | * @param[in] size Size of data which should be written into file |
| 324 | * stream, in bytes. |
| 325 | * |
| 326 | * @return 0 for success, other value for failure. |
| 327 | */ |
| 328 | FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size); |
| 329 | /** |
| 330 | * @brief Callback function to flush all internal accessing buffers. |
| 331 | * |
| 332 | * @param[in] clientData Pointer to user-defined data. |
| 333 | * |
| 334 | * @return 0 for success, other value for failure. |
| 335 | */ |
| 336 | FPDF_RESULT (*Flush)(FPDF_LPVOID clientData); |
| 337 | /** |
| 338 | * @brief Callback function to change file size. |
| 339 | * |
| 340 | * @details This function is called under writing mode usually. Implementer |
| 341 | * can determine whether to realize it based on application requests. |
| 342 | * |
| 343 | * @param[in] clientData Pointer to user-defined data. |
| 344 | * @param[in] size New size of file stream, in bytes. |
| 345 | * |
| 346 | * @return 0 for success, other value for failure. |
| 347 | */ |
| 348 | FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 349 | |
| 350 | } FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER; |
| 351 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 352 | // Function: FPDF_LoadCustomDocument |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 353 | // Load PDF document from a custom access descriptor. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 354 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 355 | // pFileAccess - A structure for accessing the file. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 356 | // password - Optional password for decrypting the PDF file. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 357 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 358 | // A handle to the loaded document, or NULL on failure. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 359 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 360 | // The application must keep the file resources valid until the PDF |
| 361 | // document is closed. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 362 | // |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 363 | // The loaded document can be closed with FPDF_CloseDocument. |
| 364 | // Notes: |
| 365 | // The application should call the FPDF_LoadXFA function after the |
| 366 | // document is loaded to support form fields. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 367 | DLLEXPORT FPDF_DOCUMENT STDCALL |
| 368 | FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 369 | |
| 370 | // Function: FPDF_GetFileVersion |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 371 | // Get the file version of the given PDF document. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 372 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 373 | // doc - Handle to a document. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 374 | // fileVersion - The PDF file version. File version: 14 for 1.4, 15 |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 375 | // for 1.5, ... |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 376 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 377 | // True if succeeds, false otherwise. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 378 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 379 | // If the document was created by FPDF_CreateNewDocument, |
| 380 | // then this function will always fail. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 381 | DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, |
| 382 | int* fileVersion); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 383 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 384 | #define FPDF_ERR_SUCCESS 0 // No error. |
| 385 | #define FPDF_ERR_UNKNOWN 1 // Unknown error. |
| 386 | #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. |
| 388 | #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password. |
| 389 | #define FPDF_ERR_SECURITY 5 // Unsupported security scheme. |
| 390 | #define FPDF_ERR_PAGE 6 // Page not found or content error. |
| 391 | #define FPDF_ERR_XFALOAD 7 // Load XFA error. |
| 392 | #define FPDF_ERR_XFALAYOUT 8 // Layout XFA error. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 393 | |
| 394 | // Function: FPDF_GetLastError |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 395 | // Get last error code when a function fails. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 396 | // Parameters: |
| 397 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 398 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 399 | // A 32-bit integer indicating error code as defined above. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 400 | // Comments: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 401 | // If the previous SDK call succeeded, the return value of this |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 402 | // function is not defined. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 403 | DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 404 | |
| 405 | // Function: FPDF_GetDocPermission |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 406 | // Get file permission flags of the document. |
| 407 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 408 | // document - Handle to a document. Returned by FPDF_LoadDocument. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 409 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 410 | // A 32-bit integer indicating permission flags. Please refer to the |
| 411 | // PDF Reference for detailed descriptions. If the document is not |
| 412 | // protected, 0xffffffff will be returned. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 413 | DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 414 | |
Bo Xu | c5cab02 | 2014-09-19 19:16:31 -0700 | [diff] [blame] | 415 | // Function: FPDF_GetSecurityHandlerRevision |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 416 | // Get the revision for the security handler. |
Bo Xu | c5cab02 | 2014-09-19 19:16:31 -0700 | [diff] [blame] | 417 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 418 | // document - Handle to a document. Returned by FPDF_LoadDocument. |
Bo Xu | c5cab02 | 2014-09-19 19:16:31 -0700 | [diff] [blame] | 419 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 420 | // The security handler revision number. Please refer to the PDF |
| 421 | // Reference for a detailed description. If the document is not |
| 422 | // protected, -1 will be returned. |
Bo Xu | c5cab02 | 2014-09-19 19:16:31 -0700 | [diff] [blame] | 423 | DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); |
| 424 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 425 | // Function: FPDF_GetPageCount |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 426 | // Get total number of pages in the document. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 427 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 428 | // document - Handle to document. Returned by FPDF_LoadDocument. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 429 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 430 | // Total number of pages in the document. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 431 | DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); |
| 432 | |
| 433 | // Function: FPDF_LoadPage |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 434 | // Load a page inside the document. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 435 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 436 | // document - Handle to document. Returned by FPDF_LoadDocument |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 437 | // page_index - Index number of the page. 0 for the first page. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 438 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 439 | // A handle to the loaded page, or NULL if page load fails. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 440 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 441 | // The loaded page can be rendered to devices using FPDF_RenderPage. |
| 442 | // The loaded page can be closed using FPDF_ClosePage. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 443 | DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, |
| 444 | int page_index); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 445 | |
| 446 | // Function: FPDF_GetPageWidth |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 447 | // Get page width. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 448 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 449 | // page - Handle to the page. Returned by FPDF_LoadPage. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 450 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 451 | // Page width (excluding non-displayable area) measured in points. |
| 452 | // One point is 1/72 inch (around 0.3528 mm). |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 453 | DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); |
| 454 | |
| 455 | // Function: FPDF_GetPageHeight |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 456 | // Get page height. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 457 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 458 | // page - Handle to the page. Returned by FPDF_LoadPage. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 459 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 460 | // Page height (excluding non-displayable area) measured in points. |
| 461 | // One point is 1/72 inch (around 0.3528 mm) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 462 | DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); |
| 463 | |
| 464 | // Function: FPDF_GetPageSizeByIndex |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 465 | // Get the size of the page at the given index. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 466 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 467 | // document - Handle to document. Returned by FPDF_LoadDocument. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 468 | // page_index - Page index, zero for the first page. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 469 | // width - Pointer to a double to receive the page width |
| 470 | // (in points). |
| 471 | // height - Pointer to a double to receive the page height |
| 472 | // (in points). |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 473 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 474 | // Non-zero for success. 0 for error (document or page not found). |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 475 | DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, |
| 476 | int page_index, |
| 477 | double* width, |
| 478 | double* height); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 479 | |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 480 | // Page rendering flags. They can be combined with bit-wise OR. |
| 481 | // |
| 482 | // Set if annotations are to be rendered. |
| 483 | #define FPDF_ANNOT 0x01 |
| 484 | // Set if using text rendering optimized for LCD display. |
| 485 | #define FPDF_LCD_TEXT 0x02 |
| 486 | // Don't use the native text output available on some platforms |
| 487 | #define FPDF_NO_NATIVETEXT 0x04 |
| 488 | // Grayscale output. |
| 489 | #define FPDF_GRAYSCALE 0x08 |
| 490 | // Set if you want to get some debug info. |
| 491 | #define FPDF_DEBUG_INFO 0x80 |
| 492 | // Set if you don't want to catch exceptions. |
| 493 | #define FPDF_NO_CATCH 0x100 |
| 494 | // Limit image cache size. |
| 495 | #define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 |
| 496 | // Always use halftone for image stretching. |
| 497 | #define FPDF_RENDER_FORCEHALFTONE 0x400 |
| 498 | // Render for printing. |
| 499 | #define FPDF_PRINTING 0x800 |
| 500 | // Set to disable anti-aliasing on text. |
| 501 | #define FPDF_RENDER_NO_SMOOTHTEXT 0x1000 |
| 502 | // Set to disable anti-aliasing on images. |
| 503 | #define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000 |
| 504 | // Set to disable anti-aliasing on paths. |
| 505 | #define FPDF_RENDER_NO_SMOOTHPATH 0x4000 |
| 506 | // Set whether to render in a reverse Byte order, this flag is only used when |
| 507 | // rendering to a bitmap. |
| 508 | #define FPDF_REVERSE_BYTE_ORDER 0x10 |
| 509 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 510 | #ifdef _WIN32 |
| 511 | // Function: FPDF_RenderPage |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 512 | // Render contents of a page to a device (screen, bitmap, or printer). |
| 513 | // This function is only supported on Windows. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 514 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 515 | // dc - Handle to the device context. |
| 516 | // page - Handle to the page. Returned by FPDF_LoadPage. |
| 517 | // start_x - Left pixel position of the display area in |
| 518 | // device coordinates. |
| 519 | // start_y - Top pixel position of the display area in device |
| 520 | // coordinates. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 521 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 522 | // size_y - Vertical size (in pixels) for displaying the page. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 523 | // rotate - Page orientation: |
| 524 | // 0 (normal) |
| 525 | // 1 (rotated 90 degrees clockwise) |
| 526 | // 2 (rotated 180 degrees) |
| 527 | // 3 (rotated 90 degrees counter-clockwise) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 528 | // flags - 0 for normal display, or combination of flags |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 529 | // defined above. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 530 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 531 | // None. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 532 | DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, |
| 533 | FPDF_PAGE page, |
| 534 | int start_x, |
| 535 | int start_y, |
| 536 | int size_x, |
| 537 | int size_y, |
| 538 | int rotate, |
| 539 | int flags); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 540 | #endif |
| 541 | |
| 542 | // Function: FPDF_RenderPageBitmap |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 543 | // Render contents of a page to a device independent bitmap. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 544 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 545 | // bitmap - Handle to the device independent bitmap (as the |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 546 | // output buffer). The bitmap handle can be created |
| 547 | // by FPDFBitmap_Create. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 548 | // page - Handle to the page. Returned by FPDF_LoadPage |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 549 | // start_x - Left pixel position of the display area in |
| 550 | // bitmap coordinates. |
| 551 | // start_y - Top pixel position of the display area in bitmap |
| 552 | // coordinates. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 553 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 554 | // size_y - Vertical size (in pixels) for displaying the page. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 555 | // rotate - Page orientation: |
| 556 | // 0 (normal) |
| 557 | // 1 (rotated 90 degrees clockwise) |
| 558 | // 2 (rotated 180 degrees) |
| 559 | // 3 (rotated 90 degrees counter-clockwise) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 560 | // flags - 0 for normal display, or combination of flags |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 561 | // defined above. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 562 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 563 | // None. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 564 | DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, |
| 565 | FPDF_PAGE page, |
| 566 | int start_x, |
| 567 | int start_y, |
| 568 | int size_x, |
| 569 | int size_y, |
| 570 | int rotate, |
| 571 | int flags); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 572 | |
| 573 | // Function: FPDF_ClosePage |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 574 | // Close a loaded PDF page. |
| 575 | // Parameters: |
| 576 | // page - Handle to the loaded page. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 577 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 578 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 579 | DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); |
| 580 | |
| 581 | // Function: FPDF_CloseDocument |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 582 | // Close a loaded PDF document. |
| 583 | // Parameters: |
| 584 | // document - Handle to the loaded document. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 585 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 586 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 587 | DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); |
| 588 | |
| 589 | // Function: FPDF_DeviceToPage |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 590 | // Convert the screen coordinates of a point to page coordinates. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 591 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 592 | // page - Handle to the page. Returned by FPDF_LoadPage. |
| 593 | // start_x - Left pixel position of the display area in |
| 594 | // device coordinates. |
| 595 | // start_y - Top pixel position of the display area in device |
| 596 | // coordinates. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 597 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 598 | // size_y - Vertical size (in pixels) for displaying the page. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 599 | // rotate - Page orientation: |
| 600 | // 0 (normal) |
| 601 | // 1 (rotated 90 degrees clockwise) |
| 602 | // 2 (rotated 180 degrees) |
| 603 | // 3 (rotated 90 degrees counter-clockwise) |
| 604 | // device_x - X value in device coordinates to be converted. |
| 605 | // device_y - Y value in device coordinates to be converted. |
| 606 | // page_x - A pointer to a double receiving the converted X |
| 607 | // value in page coordinates. |
| 608 | // page_y - A pointer to a double receiving the converted Y |
| 609 | // value in page coordinates. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 610 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 611 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 612 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 613 | // The page coordinate system has its origin at the left-bottom corner |
| 614 | // of the page, with the X-axis on the bottom going to the right, and |
| 615 | // the Y-axis on the left side going up. |
| 616 | // |
| 617 | // NOTE: this coordinate system can be altered when you zoom, scroll, |
| 618 | // or rotate a page, however, a point on the page should always have |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 619 | // the same coordinate values in the page coordinate system. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 620 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 621 | // The device coordinate system is device dependent. For screen device, |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 622 | // its origin is at the left-top corner of the window. However this |
| 623 | // origin can be altered by the Windows coordinate transformation |
| 624 | // utilities. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 625 | // |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 626 | // You must make sure the start_x, start_y, size_x, size_y |
| 627 | // and rotate parameters have exactly same values as you used in |
| 628 | // the FPDF_RenderPage() function call. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 629 | DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, |
| 630 | int start_x, |
| 631 | int start_y, |
| 632 | int size_x, |
| 633 | int size_y, |
| 634 | int rotate, |
| 635 | int device_x, |
| 636 | int device_y, |
| 637 | double* page_x, |
| 638 | double* page_y); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 639 | |
| 640 | // Function: FPDF_PageToDevice |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 641 | // Convert the page coordinates of a point to screen coordinates. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 642 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 643 | // page - Handle to the page. Returned by FPDF_LoadPage. |
| 644 | // start_x - Left pixel position of the display area in |
| 645 | // device coordinates. |
| 646 | // start_y - Top pixel position of the display area in device |
| 647 | // coordinates. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 648 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 649 | // size_y - Vertical size (in pixels) for displaying the page. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 650 | // rotate - Page orientation: |
| 651 | // 0 (normal) |
| 652 | // 1 (rotated 90 degrees clockwise) |
| 653 | // 2 (rotated 180 degrees) |
| 654 | // 3 (rotated 90 degrees counter-clockwise) |
| 655 | // page_x - X value in page coordinates. |
| 656 | // page_y - Y value in page coordinate. |
| 657 | // device_x - A pointer to an integer receiving the result X |
| 658 | // value in device coordinates. |
| 659 | // device_y - A pointer to an integer receiving the result Y |
| 660 | // value in device coordinates. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 661 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 662 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 663 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 664 | // See comments for FPDF_DeviceToPage(). |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 665 | DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, |
| 666 | int start_x, |
| 667 | int start_y, |
| 668 | int size_x, |
| 669 | int size_y, |
| 670 | int rotate, |
| 671 | double page_x, |
| 672 | double page_y, |
| 673 | int* device_x, |
| 674 | int* device_y); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 675 | |
| 676 | // Function: FPDFBitmap_Create |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 677 | // Create a device independent bitmap (FXDIB). |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 678 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 679 | // width - The number of pixels in width for the bitmap. |
| 680 | // Must be greater than 0. |
| 681 | // height - The number of pixels in height for the bitmap. |
| 682 | // Must be greater than 0. |
| 683 | // alpha - A flag indicating whether the alpha channel is used. |
| 684 | // Non-zero for using alpha, zero for not using. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 685 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 686 | // The created bitmap handle, or NULL if a parameter error or out of |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 687 | // memory. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 688 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 689 | // The bitmap always uses 4 bytes per pixel. The first byte is always |
| 690 | // double word aligned. |
| 691 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 692 | // The byte order is BGRx (the last byte unused if no alpha channel) or |
| 693 | // BGRA. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 694 | // |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 695 | // The pixels in a horizontal line are stored side by side, with the |
| 696 | // left most pixel stored first (with lower memory address). |
| 697 | // Each line uses width * 4 bytes. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 698 | // |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 699 | // Lines are stored one after another, with the top most line stored |
| 700 | // first. There is no gap between adjacent lines. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 701 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 702 | // This function allocates enough memory for holding all pixels in the |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 703 | // bitmap, but it doesn't initialize the buffer. Applications can use |
| 704 | // FPDFBitmap_FillRect to fill the bitmap using any color. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 705 | DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, |
| 706 | int height, |
| 707 | int alpha); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 708 | |
| 709 | // More DIB formats |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 710 | // Gray scale bitmap, one byte per pixel. |
| 711 | #define FPDFBitmap_Gray 1 |
| 712 | // 3 bytes per pixel, byte order: blue, green, red. |
| 713 | #define FPDFBitmap_BGR 2 |
| 714 | // 4 bytes per pixel, byte order: blue, green, red, unused. |
| 715 | #define FPDFBitmap_BGRx 3 |
| 716 | // 4 bytes per pixel, byte order: blue, green, red, alpha. |
| 717 | #define FPDFBitmap_BGRA 4 |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 718 | |
| 719 | // Function: FPDFBitmap_CreateEx |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 720 | // Create a device independent bitmap (FXDIB) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 721 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 722 | // width - The number of pixels in width for the bitmap. |
| 723 | // Must be greater than 0. |
| 724 | // height - The number of pixels in height for the bitmap. |
| 725 | // Must be greater than 0. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 726 | // format - A number indicating for bitmap format, as defined |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 727 | // above. |
| 728 | // first_scan - A pointer to the first byte of the first line if |
| 729 | // using an external buffer. If this parameter is NULL, |
| 730 | // then the a new buffer will be created. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 731 | // stride - Number of bytes for each scan line, for external |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 732 | // buffer only. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 733 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 734 | // The bitmap handle, or NULL if parameter error or out of memory. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 735 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 736 | // Similar to FPDFBitmap_Create function, but allows for more formats |
| 737 | // and an external buffer is supported. The bitmap created by this |
| 738 | // function can be used in any place that a FPDF_BITMAP handle is |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 739 | // required. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 740 | // |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 741 | // If an external buffer is used, then the application should destroy |
| 742 | // the buffer by itself. FPDFBitmap_Destroy function will not destroy |
| 743 | // the buffer. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 744 | DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, |
| 745 | int height, |
| 746 | int format, |
| 747 | void* first_scan, |
| 748 | int stride); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 749 | |
| 750 | // Function: FPDFBitmap_FillRect |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 751 | // Fill a rectangle in a bitmap. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 752 | // Parameters: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 753 | // bitmap - The handle to the bitmap. Returned by |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 754 | // FPDFBitmap_Create. |
| 755 | // left - The left position. Starting from 0 at the |
| 756 | // left-most pixel. |
| 757 | // top - The top position. Starting from 0 at the |
| 758 | // top-most line. |
| 759 | // width - Width in pixels to be filled. |
| 760 | // height - Height in pixels to be filled. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 761 | // color - A 32-bit value specifing the color, in 8888 ARGB |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 762 | // format. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 763 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 764 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 765 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 766 | // This function sets the color and (optionally) alpha value in the |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 767 | // specified region of the bitmap. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 768 | // |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 769 | // NOTE: If the alpha channel is used, this function does NOT |
| 770 | // composite the background with the source color, instead the |
| 771 | // background will be replaced by the source color and the alpha. |
| 772 | // |
| 773 | // If the alpha channel is not used, the alpha parameter is ignored. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 774 | DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, |
| 775 | int left, |
| 776 | int top, |
| 777 | int width, |
| 778 | int height, |
| 779 | FPDF_DWORD color); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 780 | |
| 781 | // Function: FPDFBitmap_GetBuffer |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 782 | // Get data buffer of a bitmap. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 783 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 784 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 785 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 786 | // The pointer to the first byte of the bitmap buffer. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 787 | // Comments: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 788 | // The stride may be more than width * number of bytes per pixel |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 789 | // |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 790 | // Applications can use this function to get the bitmap buffer pointer, |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 791 | // then manipulate any color and/or alpha values for any pixels in the |
| 792 | // bitmap. |
| 793 | // |
| 794 | // The data is in BGRA format. Where the A maybe unused if alpha was |
| 795 | // not specified. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 796 | DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); |
| 797 | |
| 798 | // Function: FPDFBitmap_GetWidth |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 799 | // Get width of a bitmap. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 800 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 801 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 802 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 803 | // The width of the bitmap in pixels. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 804 | DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); |
| 805 | |
| 806 | // Function: FPDFBitmap_GetHeight |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 807 | // Get height of a bitmap. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 808 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 809 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 810 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 811 | // The height of the bitmap in pixels. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 812 | DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); |
| 813 | |
| 814 | // Function: FPDFBitmap_GetStride |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 815 | // Get number of bytes for each line in the bitmap buffer. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 816 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 817 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 818 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 819 | // The number of bytes for each line in the bitmap buffer. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 820 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 821 | // The stride may be more than width * number of bytes per pixel. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 822 | DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap); |
| 823 | |
| 824 | // Function: FPDFBitmap_Destroy |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 825 | // Destroy a bitmap and release all related buffers. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 826 | // Parameters: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 827 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 828 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 829 | // None. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 830 | // Comments: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 831 | // This function will not destroy any external buffers provided when |
| 832 | // the bitmap was created. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 833 | DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); |
| 834 | |
| 835 | // Function: FPDF_VIEWERREF_GetPrintScaling |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 836 | // Whether the PDF document prefers to be scaled or not. |
| 837 | // Parameters: |
| 838 | // document - Handle to the loaded document. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 839 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 840 | // None. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 841 | DLLEXPORT FPDF_BOOL STDCALL |
| 842 | FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 843 | |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 844 | // Function: FPDF_VIEWERREF_GetNumCopies |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 845 | // Returns the number of copies to be printed. |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 846 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 847 | // document - Handle to the loaded document. |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 848 | // Return value: |
| 849 | // The number of copies to be printed. |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 850 | DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); |
| 851 | |
| 852 | // Function: FPDF_VIEWERREF_GetPrintPageRange |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 853 | // Page numbers to initialize print dialog box when file is printed. |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 854 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 855 | // document - Handle to the loaded document. |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 856 | // Return value: |
| 857 | // The print page range to be used for printing. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 858 | DLLEXPORT FPDF_PAGERANGE STDCALL |
| 859 | FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 860 | |
| 861 | // Function: FPDF_VIEWERREF_GetDuplex |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 862 | // Returns the paper handling option to be used when printing from |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 863 | // the print dialog. |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 864 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 865 | // document - Handle to the loaded document. |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 866 | // Return value: |
| 867 | // The paper handling option to be used when printing. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 868 | DLLEXPORT FPDF_DUPLEXTYPE STDCALL |
| 869 | FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document); |
Bo Xu | 9114e83 | 2014-07-14 13:22:47 -0700 | [diff] [blame] | 870 | |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 871 | // Function: FPDF_CountNamedDests |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 872 | // Get the count of named destinations in the PDF document. |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 873 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 874 | // document - Handle to a document |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 875 | // Return value: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 876 | // The count of named destinations. |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 877 | DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document); |
| 878 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 879 | // Function: FPDF_GetNamedDestByName |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 880 | // Get a the destination handle for the given name. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 881 | // Parameters: |
| 882 | // document - Handle to the loaded document. |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 883 | // name - The name of a destination. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 884 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 885 | // The handle to the destination. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 886 | DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, |
| 887 | FPDF_BYTESTRING name); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 888 | |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 889 | // Function: FPDF_GetNamedDest |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 890 | // Get the named destination by index. |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 891 | // Parameters: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 892 | // document - Handle to a document |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 893 | // index - The index of a named destination. |
| 894 | // buffer - The buffer to store the destination name, |
| 895 | // used as wchar_t*. |
| 896 | // buflen [in/out] - Size of the buffer in bytes on input, |
| 897 | // length of the result in bytes on output |
| 898 | // or -1 if the buffer is too small. |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 899 | // Return value: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 900 | // The destination handle for a given index, or NULL if there is no |
| 901 | // named destination corresponding to |index|. |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 902 | // Comments: |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 903 | // Call this function twice to get the name of the named destination: |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 904 | // 1) First time pass in |buffer| as NULL and get buflen. |
| 905 | // 2) Second time pass in allocated |buffer| and buflen to retrieve |
| 906 | // |buffer|, which should be used as wchar_t*. |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 907 | // |
Dan Sinclair | 49f88b7 | 2015-10-20 15:18:51 -0400 | [diff] [blame] | 908 | // If buflen is not sufficiently large, it will be set to -1 upon |
| 909 | // return. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 910 | DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, |
| 911 | int index, |
| 912 | void* buffer, |
| 913 | long* buflen); |
Bo Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 914 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 915 | // Function: FPDF_BStr_Init |
| 916 | // Helper function to initialize a byte string. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 917 | DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str); |
| 918 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 919 | // Function: FPDF_BStr_Set |
| 920 | // Helper function to set string data. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 921 | DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, |
| 922 | FPDF_LPCSTR bstr, |
| 923 | int length); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 924 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 925 | // Function: FPDF_BStr_Clear |
| 926 | // Helper function to clear a byte string. |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 927 | DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str); |
| 928 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 929 | #ifdef __cplusplus |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 930 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 931 | #endif |
| 932 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 933 | #endif // PUBLIC_FPDFVIEW_H_ |