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