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