blob: dad6299da5e6d6da896134e602770728bb38112b [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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 Sepez9857e202015-05-13 17:09:26 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez1ed8a212015-05-11 15:25:39 -07007// NOTE: External docs refer to this file as "fpdfview.h", so do not rename
Dan Sinclair50cce602016-02-24 09:51:16 -05008// despite lack of consistency with other public files.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Tom Sepez9857e202015-05-13 17:09:26 -070010#ifndef PUBLIC_FPDFVIEW_H_
11#define PUBLIC_FPDFVIEW_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070012
13#if defined(_WIN32) && !defined(__WINDOWS__)
14#include <windows.h>
15#endif
16
Tom Sepezc46d0002015-11-30 15:46:36 -080017#ifdef PDF_ENABLE_XFA
Dan Sinclair3ebd1212016-03-09 09:59:23 -050018// 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 Xubb5ef882014-11-06 16:13:33 -080020#define PDF_USE_XFA
Tom Sepezc46d0002015-11-30 15:46:36 -080021#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022
23// PDF types
Tom Sepez9857e202015-05-13 17:09:26 -070024typedef void* FPDF_ACTION;
Tom Sepezc46d0002015-11-30 15:46:36 -080025typedef void* FPDF_BITMAP;
26typedef void* FPDF_BOOKMARK;
27typedef void* FPDF_CLIPPATH;
28typedef void* FPDF_DEST;
29typedef void* FPDF_DOCSCHHANDLE;
30typedef void* FPDF_DOCUMENT;
31typedef void* FPDF_FONT;
32typedef void* FPDF_HMODULE;
Tom Sepez9857e202015-05-13 17:09:26 -070033typedef void* FPDF_LINK;
Tom Sepezc46d0002015-11-30 15:46:36 -080034typedef void* FPDF_MODULEMGR;
35typedef void* FPDF_PAGE;
36typedef void* FPDF_PAGELINK;
37typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
Tom Sepez9857e202015-05-13 17:09:26 -070038typedef void* FPDF_PAGERANGE;
Tom Sepezc46d0002015-11-30 15:46:36 -080039typedef void* FPDF_PATH;
Cary Clark399be5b2016-03-14 16:51:29 -040040typedef void* FPDF_RECORDER;
Tom Sepezc46d0002015-11-30 15:46:36 -080041typedef void* FPDF_SCHHANDLE;
42typedef void* FPDF_TEXTPAGE;
43
44#ifdef PDF_ENABLE_XFA
45typedef void* FPDF_STRINGHANDLE;
46typedef void* FPDF_WIDGET;
47#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070048
49// Basic data types
Tom Sepez9857e202015-05-13 17:09:26 -070050typedef int FPDF_BOOL;
51typedef int FPDF_ERROR;
52typedef unsigned long FPDF_DWORD;
53typedef float FS_FLOAT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070054
Tom Sepezc46d0002015-11-30 15:46:36 -080055#ifdef PDF_ENABLE_XFA
56typedef void* FPDF_LPVOID;
57typedef void const* FPDF_LPCVOID;
58typedef char const* FPDF_LPCSTR;
59typedef int FPDF_RESULT;
60#endif
61
Bo Xu9114e832014-07-14 13:22:47 -070062// Duplex types
63typedef enum _FPDF_DUPLEXTYPE_ {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070064 DuplexUndefined = 0,
65 Simplex,
66 DuplexFlipShortEdge,
67 DuplexFlipLongEdge
Bo Xu9114e832014-07-14 13:22:47 -070068} FPDF_DUPLEXTYPE;
69
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070070// String types
Tom Sepez9857e202015-05-13 17:09:26 -070071typedef unsigned short FPDF_WCHAR;
72typedef unsigned char const* FPDF_LPCBYTE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070073
Nico Weber9d8ec5a2015-08-04 13:00:21 -070074// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
75// encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070076typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070077
Dan Sinclair49f88b72015-10-20 15:18:51 -040078// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
79// bytes (except surrogation), with the low byte first.
80typedef const unsigned short* FPDF_WIDESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070081
Tom Sepezc46d0002015-11-30 15:46:36 -080082#ifdef PDF_ENABLE_XFA
Dan Sinclair49f88b72015-10-20 15:18:51 -040083// Structure for a byte string.
84// Note, a byte string commonly means a UTF-16LE formated string.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070085typedef struct _FPDF_BSTR {
Dan Sinclair49f88b72015-10-20 15:18:51 -040086 // String buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070087 char* str;
Dan Sinclair49f88b72015-10-20 15:18:51 -040088 // Length of the string, in bytes.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070089 int len;
Bo Xufdc00a72014-10-28 23:03:33 -070090} FPDF_BSTR;
Tom Sepezc46d0002015-11-30 15:46:36 -080091#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -070092
Dan Sinclair49f88b72015-10-20 15:18:51 -040093// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
94// Windows unicode string, however, special care needs to be taken if you
95// expect to process Unicode larger than 0xffff.
96//
97// For Linux/Unix programmers: most compiler/library environments use 4 bytes
98// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
99// system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700100#ifdef _WIN32_WCE
101typedef const unsigned short* FPDF_STRING;
102#else
103typedef const char* FPDF_STRING;
104#endif
105
Dan Sinclair49f88b72015-10-20 15:18:51 -0400106// Matrix for transformation.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700107typedef struct _FS_MATRIX_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400108 float a;
109 float b;
110 float c;
111 float d;
112 float e;
113 float f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700114} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700115
Dan Sinclair49f88b72015-10-20 15:18:51 -0400116// Rectangle area(float) in device or page coordinate system.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700117typedef struct _FS_RECTF_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400118 // The x-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700119 float left;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400120 // The y-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121 float top;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400122 // The x-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700123 float right;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400124 // The y-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700125 float bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700126} * FS_LPRECTF, FS_RECTF;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400127
128// Const Pointer to FS_RECTF structure.
Tom Sepez9857e202015-05-13 17:09:26 -0700129typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700130
131#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
132// On Windows system, functions are exported in a DLL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700133#define DLLEXPORT __declspec(dllexport)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700134#define STDCALL __stdcall
135#else
136#define DLLEXPORT
137#define STDCALL
138#endif
139
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700140// Exported Functions
141#ifdef __cplusplus
142extern "C" {
143#endif
144
145// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700146// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700147// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700148// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700149// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700150// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700151// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700152// Convenience function to call FPDF_InitLibraryWithConfig() for
153// backwards comatibility purposes.
154DLLEXPORT void STDCALL FPDF_InitLibrary();
155
Dan Sinclair49f88b72015-10-20 15:18:51 -0400156// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700157typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700158 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700159 int version;
160
161 // Array of paths to scan in place of the defaults when using built-in
162 // FXGE font loading code. The array is terminated by a NULL pointer.
163 // The Array may be NULL itself to use the default paths. May be ignored
164 // entirely depending upon the platform.
165 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700166
167 // Version 2.
168
169 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
170 void* m_pIsolate;
171
172 // The embedder data slot to use in the v8::Isolate to store PDFium's
173 // per-isolate data. The value needs to be between 0 and
174 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
175 // for most embedders.
176 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700177} FPDF_LIBRARY_CONFIG;
178
179// Function: FPDF_InitLibraryWithConfig
180// Initialize the FPDFSDK library
181// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400182// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700183// Return value:
184// None.
185// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700186// You have to call this function before you can call any PDF
187// processing functions.
Tom Sepez326a2a72015-11-20 10:47:32 -0800188DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
189 const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700190
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700191// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700192// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700193// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700194// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700195// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700196// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700197// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700198// You can call this function to release all memory blocks allocated by
199// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400200// After this function is called, you should not call any PDF
201// processing functions.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700202DLLEXPORT void STDCALL FPDF_DestroyLibrary();
203
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700204// Policy for accessing the local machine time.
205#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700206
207// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700208// Set the policy for the sandbox environment.
209// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400210// policy - The specified policy for setting, for example:
211// FPDF_POLICY_MACHINETIME_ACCESS.
212// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700213// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700214// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
216 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700217
Tom Sepez3c3201f2015-05-20 10:20:35 -0700218// Function: FPDF_LoadDocument
219// Open and load a PDF document.
220// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400221// file_path - Path to the PDF file (including extension).
222// password - A string used as the password for the PDF file.
223// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700224// Return value:
225// A handle to the loaded document, or NULL on failure.
226// Comments:
227// Loaded document can be closed by FPDF_CloseDocument().
228// If this function fails, you can use FPDF_GetLastError() to retrieve
229// the reason why it failed.
Tom Sepez9857e202015-05-13 17:09:26 -0700230DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700231 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700232
233// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700234// Open and load a PDF document from memory.
235// Parameters:
236// data_buf - Pointer to a buffer containing the PDF document.
237// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400238// password - A string used as the password for the PDF file.
239// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700240// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400241// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700242// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700243// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400244// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700245// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400246// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700247// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800248// If PDFium is built with the XFA module, the application should call
249// FPDF_LoadXFA() function after the PDF document loaded to support XFA
250// fields defined in the fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700251DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700252 int size,
253 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700254
255// Structure for custom file access.
256typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700257 // File length, in bytes.
258 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700259
Dan Sinclair49f88b72015-10-20 15:18:51 -0400260 // A function pointer for getting a block of data from a specific position.
261 // Position is specified by byte offset from the beginning of the file.
262 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700263 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400264 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700265 // Return value: should be non-zero if successful, zero for error.
266 int (*m_GetBlock)(void* param,
267 unsigned long position,
268 unsigned char* pBuf,
269 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700270
Dan Sinclair49f88b72015-10-20 15:18:51 -0400271 // A custom pointer for all implementation specific data. This pointer will
272 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700273 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700274} FPDF_FILEACCESS;
275
Tom Sepezc46d0002015-11-30 15:46:36 -0800276#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700277/**
278 * @brief Structure for file reading or writing (I/O).
279 *
280 * @note This is a handler and should be implemented by callers.
281 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700282typedef struct _FPDF_FILEHANDLER {
283 /**
284 * @brief User-defined data.
285 * @note Callers can use this field to track controls.
286 */
287 FPDF_LPVOID clientData;
288 /**
289 * @brief Callback function to release the current file stream object.
290 *
291 * @param[in] clientData Pointer to user-defined data.
292 *
293 * @return None.
294 */
295 void (*Release)(FPDF_LPVOID clientData);
296 /**
297 * @brief Callback function to retrieve the current file stream size.
298 *
299 * @param[in] clientData Pointer to user-defined data.
300 *
301 * @return Size of file stream.
302 */
303 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
304 /**
305 * @brief Callback function to read data from the current file stream.
306 *
307 * @param[in] clientData Pointer to user-defined data.
308 * @param[in] offset Offset position starts from the beginning of file
309 * stream. This parameter indicates reading position.
310 * @param[in] buffer Memory buffer to store data which are read from
311 * file stream. This parameter should not be <b>NULL</b>.
312 * @param[in] size Size of data which should be read from file
313 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
314 * should be enough to store specified data.
315 *
316 * @return 0 for success, other value for failure.
317 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500318 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
319 FPDF_DWORD offset,
320 FPDF_LPVOID buffer,
321 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700322 /**
323 * @brief Callback function to write data into the current file stream.
324 *
325 * @param[in] clientData Pointer to user-defined data.
326 * @param[in] offset Offset position starts from the beginning of file
327 * stream. This parameter indicates writing position.
328 * @param[in] buffer Memory buffer contains data which is written into
329 * file stream. This parameter should not be <b>NULL</b>.
330 * @param[in] size Size of data which should be written into file
331 * stream, in bytes.
332 *
333 * @return 0 for success, other value for failure.
334 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500335 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
336 FPDF_DWORD offset,
337 FPDF_LPCVOID buffer,
338 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700339 /**
340 * @brief Callback function to flush all internal accessing buffers.
341 *
342 * @param[in] clientData Pointer to user-defined data.
343 *
344 * @return 0 for success, other value for failure.
345 */
346 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
347 /**
348 * @brief Callback function to change file size.
349 *
350 * @details This function is called under writing mode usually. Implementer
351 * can determine whether to realize it based on application requests.
352 *
353 * @param[in] clientData Pointer to user-defined data.
354 * @param[in] size New size of file stream, in bytes.
355 *
356 * @return 0 for success, other value for failure.
357 */
358 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700359} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
360
Tom Sepezc46d0002015-11-30 15:46:36 -0800361#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700362// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700363// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700364// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400365// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700366// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700367// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400368// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700369// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400370// The application must keep the file resources valid until the PDF
371// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700372//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400373// The loaded document can be closed with FPDF_CloseDocument.
374// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800375// If PDFium is built with the XFA module, the application should call
376// FPDF_LoadXFA() function after the PDF document loaded to support XFA
377// fields defined in the fpdfformfill.h file.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700378DLLEXPORT FPDF_DOCUMENT STDCALL
379FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700380
381// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400382// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700383// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400384// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700385// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400386// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700387// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400388// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700389// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400390// If the document was created by FPDF_CreateNewDocument,
391// then this function will always fail.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700392DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
393 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700394
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700395#define FPDF_ERR_SUCCESS 0 // No error.
396#define FPDF_ERR_UNKNOWN 1 // Unknown error.
397#define FPDF_ERR_FILE 2 // File not found or could not be opened.
398#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
399#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
400#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
401#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800402#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700403#define FPDF_ERR_XFALOAD 7 // Load XFA error.
404#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800405#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700406
407// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400408// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700409// Parameters:
410// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700411// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400412// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700413// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700414// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400415// function is not defined.
Tom Sepez9857e202015-05-13 17:09:26 -0700416DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700417
418// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700419// Get file permission flags of the document.
420// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400421// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700422// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400423// A 32-bit integer indicating permission flags. Please refer to the
424// PDF Reference for detailed descriptions. If the document is not
425// protected, 0xffffffff will be returned.
Tom Sepez9857e202015-05-13 17:09:26 -0700426DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700427
Bo Xuc5cab022014-09-19 19:16:31 -0700428// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400429// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700430// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400431// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700432// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400433// The security handler revision number. Please refer to the PDF
434// Reference for a detailed description. If the document is not
435// protected, -1 will be returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700436DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
437
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700438// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400439// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700440// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400441// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700442// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700443// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700444DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
445
446// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400447// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700448// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700449// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700450// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700451// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400452// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700453// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400454// The loaded page can be rendered to devices using FPDF_RenderPage.
455// The loaded page can be closed using FPDF_ClosePage.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700456DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
457 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700458
459// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700460// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700461// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400462// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700463// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700464// Page width (excluding non-displayable area) measured in points.
465// One point is 1/72 inch (around 0.3528 mm).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700466DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
467
468// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700469// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700470// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400471// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700472// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700473// Page height (excluding non-displayable area) measured in points.
474// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700475DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
476
477// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400478// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700479// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400480// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700481// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400482// width - Pointer to a double to receive the page width
483// (in points).
484// height - Pointer to a double to receive the page height
485// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700486// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700487// Non-zero for success. 0 for error (document or page not found).
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700488DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
489 int page_index,
490 double* width,
491 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700492
Dan Sinclair49f88b72015-10-20 15:18:51 -0400493// Page rendering flags. They can be combined with bit-wise OR.
494//
495// Set if annotations are to be rendered.
496#define FPDF_ANNOT 0x01
497// Set if using text rendering optimized for LCD display.
498#define FPDF_LCD_TEXT 0x02
499// Don't use the native text output available on some platforms
500#define FPDF_NO_NATIVETEXT 0x04
501// Grayscale output.
502#define FPDF_GRAYSCALE 0x08
503// Set if you want to get some debug info.
504#define FPDF_DEBUG_INFO 0x80
505// Set if you don't want to catch exceptions.
506#define FPDF_NO_CATCH 0x100
507// Limit image cache size.
508#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
509// Always use halftone for image stretching.
510#define FPDF_RENDER_FORCEHALFTONE 0x400
511// Render for printing.
512#define FPDF_PRINTING 0x800
513// Set to disable anti-aliasing on text.
514#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
515// Set to disable anti-aliasing on images.
516#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
517// Set to disable anti-aliasing on paths.
518#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
519// Set whether to render in a reverse Byte order, this flag is only used when
520// rendering to a bitmap.
521#define FPDF_REVERSE_BYTE_ORDER 0x10
522
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700523#ifdef _WIN32
524// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400525// Render contents of a page to a device (screen, bitmap, or printer).
526// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700527// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400528// dc - Handle to the device context.
529// page - Handle to the page. Returned by FPDF_LoadPage.
530// start_x - Left pixel position of the display area in
531// device coordinates.
532// start_y - Top pixel position of the display area in device
533// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700534// size_x - Horizontal size (in pixels) for displaying the page.
535// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400536// rotate - Page orientation:
537// 0 (normal)
538// 1 (rotated 90 degrees clockwise)
539// 2 (rotated 180 degrees)
540// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700541// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400542// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700543// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700544// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700545DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
546 FPDF_PAGE page,
547 int start_x,
548 int start_y,
549 int size_x,
550 int size_y,
551 int rotate,
552 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700553#endif
554
555// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400556// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700557// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700558// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400559// output buffer). The bitmap handle can be created
560// by FPDFBitmap_Create.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700561// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400562// start_x - Left pixel position of the display area in
563// bitmap coordinates.
564// start_y - Top pixel position of the display area in bitmap
565// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700566// size_x - Horizontal size (in pixels) for displaying the page.
567// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400568// rotate - Page orientation:
569// 0 (normal)
570// 1 (rotated 90 degrees clockwise)
571// 2 (rotated 180 degrees)
572// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700573// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400574// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700575// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700576// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700577DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
578 FPDF_PAGE page,
579 int start_x,
580 int start_y,
581 int size_x,
582 int size_y,
583 int rotate,
584 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700585
Cary Clark399be5b2016-03-14 16:51:29 -0400586#ifdef _SKIA_SUPPORT_
587DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
588 int size_x,
589 int size_y);
590#endif
591
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700592// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700593// Close a loaded PDF page.
594// Parameters:
595// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700596// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700597// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700598DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
599
600// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700601// Close a loaded PDF document.
602// Parameters:
603// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700604// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700605// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700606DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
607
608// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400609// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700610// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400611// page - Handle to the page. Returned by FPDF_LoadPage.
612// start_x - Left pixel position of the display area in
613// device coordinates.
614// start_y - Top pixel position of the display area in device
615// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700616// size_x - Horizontal size (in pixels) for displaying the page.
617// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400618// rotate - Page orientation:
619// 0 (normal)
620// 1 (rotated 90 degrees clockwise)
621// 2 (rotated 180 degrees)
622// 3 (rotated 90 degrees counter-clockwise)
623// device_x - X value in device coordinates to be converted.
624// device_y - Y value in device coordinates to be converted.
625// page_x - A pointer to a double receiving the converted X
626// value in page coordinates.
627// page_y - A pointer to a double receiving the converted Y
628// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700629// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700630// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700631// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400632// The page coordinate system has its origin at the left-bottom corner
633// of the page, with the X-axis on the bottom going to the right, and
634// the Y-axis on the left side going up.
635//
636// NOTE: this coordinate system can be altered when you zoom, scroll,
637// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700638// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700639//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700640// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400641// its origin is at the left-top corner of the window. However this
642// origin can be altered by the Windows coordinate transformation
643// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700644//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400645// You must make sure the start_x, start_y, size_x, size_y
646// and rotate parameters have exactly same values as you used in
647// the FPDF_RenderPage() function call.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700648DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
649 int start_x,
650 int start_y,
651 int size_x,
652 int size_y,
653 int rotate,
654 int device_x,
655 int device_y,
656 double* page_x,
657 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700658
659// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400660// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700661// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400662// page - Handle to the page. Returned by FPDF_LoadPage.
663// start_x - Left pixel position of the display area in
664// device coordinates.
665// start_y - Top pixel position of the display area in device
666// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700667// size_x - Horizontal size (in pixels) for displaying the page.
668// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400669// rotate - Page orientation:
670// 0 (normal)
671// 1 (rotated 90 degrees clockwise)
672// 2 (rotated 180 degrees)
673// 3 (rotated 90 degrees counter-clockwise)
674// page_x - X value in page coordinates.
675// page_y - Y value in page coordinate.
676// device_x - A pointer to an integer receiving the result X
677// value in device coordinates.
678// device_y - A pointer to an integer receiving the result Y
679// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700680// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700681// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700682// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400683// See comments for FPDF_DeviceToPage().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700684DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
685 int start_x,
686 int start_y,
687 int size_x,
688 int size_y,
689 int rotate,
690 double page_x,
691 double page_y,
692 int* device_x,
693 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700694
695// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400696// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700697// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400698// width - The number of pixels in width for the bitmap.
699// Must be greater than 0.
700// height - The number of pixels in height for the bitmap.
701// Must be greater than 0.
702// alpha - A flag indicating whether the alpha channel is used.
703// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700704// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400705// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700706// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700707// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400708// The bitmap always uses 4 bytes per pixel. The first byte is always
709// double word aligned.
710//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700711// The byte order is BGRx (the last byte unused if no alpha channel) or
712// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700713//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400714// The pixels in a horizontal line are stored side by side, with the
715// left most pixel stored first (with lower memory address).
716// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700717//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400718// Lines are stored one after another, with the top most line stored
719// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700720//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700721// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400722// bitmap, but it doesn't initialize the buffer. Applications can use
723// FPDFBitmap_FillRect to fill the bitmap using any color.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700724DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
725 int height,
726 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700727
728// More DIB formats
Dan Sinclair49f88b72015-10-20 15:18:51 -0400729// Gray scale bitmap, one byte per pixel.
730#define FPDFBitmap_Gray 1
731// 3 bytes per pixel, byte order: blue, green, red.
732#define FPDFBitmap_BGR 2
733// 4 bytes per pixel, byte order: blue, green, red, unused.
734#define FPDFBitmap_BGRx 3
735// 4 bytes per pixel, byte order: blue, green, red, alpha.
736#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700737
738// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400739// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700740// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400741// width - The number of pixels in width for the bitmap.
742// Must be greater than 0.
743// height - The number of pixels in height for the bitmap.
744// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700745// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400746// above.
747// first_scan - A pointer to the first byte of the first line if
748// using an external buffer. If this parameter is NULL,
749// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700750// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400751// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700752// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400753// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700754// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400755// Similar to FPDFBitmap_Create function, but allows for more formats
756// and an external buffer is supported. The bitmap created by this
757// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700758// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700759//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400760// If an external buffer is used, then the application should destroy
761// the buffer by itself. FPDFBitmap_Destroy function will not destroy
762// the buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700763DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
764 int height,
765 int format,
766 void* first_scan,
767 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700768
769// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400770// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700771// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700772// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400773// FPDFBitmap_Create.
774// left - The left position. Starting from 0 at the
775// left-most pixel.
776// top - The top position. Starting from 0 at the
777// top-most line.
778// width - Width in pixels to be filled.
779// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700780// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400781// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700782// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700783// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700784// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400785// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700786// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700787//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400788// NOTE: If the alpha channel is used, this function does NOT
789// composite the background with the source color, instead the
790// background will be replaced by the source color and the alpha.
791//
792// If the alpha channel is not used, the alpha parameter is ignored.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700793DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
794 int left,
795 int top,
796 int width,
797 int height,
798 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700799
800// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400801// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700802// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400803// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700804// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700805// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700806// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700807// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400808//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700809// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400810// then manipulate any color and/or alpha values for any pixels in the
811// bitmap.
812//
813// The data is in BGRA format. Where the A maybe unused if alpha was
814// not specified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700815DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
816
817// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400818// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700819// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400820// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700821// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400822// The width of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700823DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
824
825// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400826// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700827// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400828// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700829// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400830// The height of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700831DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
832
833// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400834// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700835// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400836// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700837// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400838// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700839// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400840// The stride may be more than width * number of bytes per pixel.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700841DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
842
843// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400844// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700845// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400846// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700847// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700848// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700849// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400850// This function will not destroy any external buffers provided when
851// the bitmap was created.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700852DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
853
854// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700855// Whether the PDF document prefers to be scaled or not.
856// Parameters:
857// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700858// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700859// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700860DLLEXPORT FPDF_BOOL STDCALL
861FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700862
Bo Xu9114e832014-07-14 13:22:47 -0700863// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700864// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700865// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700866// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700867// Return value:
868// The number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700869DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
870
871// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700872// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700873// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700874// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700875// Return value:
876// The print page range to be used for printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700877DLLEXPORT FPDF_PAGERANGE STDCALL
878FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700879
880// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700881// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -0400882// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700883// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700884// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700885// Return value:
886// The paper handling option to be used when printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700887DLLEXPORT FPDF_DUPLEXTYPE STDCALL
888FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700889
Bo Xu4d62b6b2015-01-10 22:52:59 -0800890// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700891// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800892// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700893// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800894// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700895// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800896DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
897
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700898// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -0400899// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -0700900// Parameters:
901// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400902// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700903// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400904// The handle to the destination.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700905DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
906 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700907
Bo Xu4d62b6b2015-01-10 22:52:59 -0800908// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -0400909// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800910// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700911// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -0400912// index - The index of a named destination.
913// buffer - The buffer to store the destination name,
914// used as wchar_t*.
915// buflen [in/out] - Size of the buffer in bytes on input,
916// length of the result in bytes on output
917// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800918// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400919// The destination handle for a given index, or NULL if there is no
920// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800921// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700922// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400923// 1) First time pass in |buffer| as NULL and get buflen.
924// 2) Second time pass in allocated |buffer| and buflen to retrieve
925// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800926//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400927// If buflen is not sufficiently large, it will be set to -1 upon
928// return.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700929DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
930 int index,
931 void* buffer,
932 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -0800933
Tom Sepezc46d0002015-11-30 15:46:36 -0800934#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -0700935// Function: FPDF_BStr_Init
936// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700937DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
938
Tom Sepez9857e202015-05-13 17:09:26 -0700939// Function: FPDF_BStr_Set
940// Helper function to set string data.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700941DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
942 FPDF_LPCSTR bstr,
943 int length);
Bo Xufdc00a72014-10-28 23:03:33 -0700944
Tom Sepez9857e202015-05-13 17:09:26 -0700945// Function: FPDF_BStr_Clear
946// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700947DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -0800948#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700949
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700950#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -0700951}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700952#endif
953
Tom Sepez9857e202015-05-13 17:09:26 -0700954#endif // PUBLIC_FPDFVIEW_H_