blob: d5c5a325424a85467b32afc543739f76e168a5f4 [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
8// despite lack of consitency 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
Bo Xubb5ef882014-11-06 16:13:33 -080017// TODO: remove the #define when XFA is officially in pdfium
18#define PDF_USE_XFA
19
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070020// Data types
Tom Sepez9857e202015-05-13 17:09:26 -070021typedef void* FPDF_MODULEMGR;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022
23// PDF types
Tom Sepez9857e202015-05-13 17:09:26 -070024typedef void* FPDF_DOCUMENT;
25typedef void* FPDF_PAGE;
26typedef void* FPDF_WIDGET;
27typedef void* FPDF_STRINGHANDLE;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070028typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
Tom Sepez9857e202015-05-13 17:09:26 -070029typedef void* FPDF_PATH;
30typedef void* FPDF_CLIPPATH;
31typedef void* FPDF_BITMAP;
32typedef void* FPDF_FONT;
33typedef void* FPDF_TEXTPAGE;
34typedef void* FPDF_SCHHANDLE;
35typedef void* FPDF_PAGELINK;
36typedef void* FPDF_HMODULE;
37typedef void* FPDF_DOCSCHHANDLE;
38typedef void* FPDF_BOOKMARK;
39typedef void* FPDF_DEST;
40typedef void* FPDF_ACTION;
41typedef void* FPDF_LINK;
42typedef void* FPDF_PAGERANGE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070043
44// Basic data types
Tom Sepez9857e202015-05-13 17:09:26 -070045typedef void* FPDF_LPVOID;
46typedef void const* FPDF_LPCVOID;
47typedef int FPDF_RESULT;
48typedef int FPDF_BOOL;
49typedef int FPDF_ERROR;
50typedef unsigned long FPDF_DWORD;
51typedef float FS_FLOAT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070052
Bo Xu9114e832014-07-14 13:22:47 -070053// Duplex types
54typedef enum _FPDF_DUPLEXTYPE_ {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070055 DuplexUndefined = 0,
56 Simplex,
57 DuplexFlipShortEdge,
58 DuplexFlipLongEdge
Bo Xu9114e832014-07-14 13:22:47 -070059} FPDF_DUPLEXTYPE;
60
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070061// String types
Tom Sepez9857e202015-05-13 17:09:26 -070062typedef unsigned short FPDF_WCHAR;
63typedef unsigned char const* FPDF_LPCBYTE;
64typedef char const* FPDF_LPCSTR;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070065
Nico Weber9d8ec5a2015-08-04 13:00:21 -070066// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
67// encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070068typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070069
Dan Sinclair49f88b72015-10-20 15:18:51 -040070// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
71// bytes (except surrogation), with the low byte first.
72typedef const unsigned short* FPDF_WIDESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070073
Bo Xufdc00a72014-10-28 23:03:33 -070074#ifndef _FPDF_DEF_STR_
75#define _FPDF_DEF_STR_
Dan Sinclair49f88b72015-10-20 15:18:51 -040076// Structure for a byte string.
77// Note, a byte string commonly means a UTF-16LE formated string.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070078typedef struct _FPDF_BSTR {
Dan Sinclair49f88b72015-10-20 15:18:51 -040079 // String buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070080 char* str;
Dan Sinclair49f88b72015-10-20 15:18:51 -040081 // Length of the string, in bytes.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070082 int len;
Bo Xufdc00a72014-10-28 23:03:33 -070083} FPDF_BSTR;
84
85#endif
86
Dan Sinclair49f88b72015-10-20 15:18:51 -040087// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
88// Windows unicode string, however, special care needs to be taken if you
89// expect to process Unicode larger than 0xffff.
90//
91// For Linux/Unix programmers: most compiler/library environments use 4 bytes
92// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
93// system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070094
95#ifdef _WIN32_WCE
96typedef const unsigned short* FPDF_STRING;
97#else
98typedef const char* FPDF_STRING;
99#endif
100
Dan Sinclair49f88b72015-10-20 15:18:51 -0400101// Matrix for transformation.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102typedef struct _FS_MATRIX_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400103 float a;
104 float b;
105 float c;
106 float d;
107 float e;
108 float f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700109} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700110
Dan Sinclair49f88b72015-10-20 15:18:51 -0400111// Rectangle area(float) in device or page coordinate system.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112typedef struct _FS_RECTF_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400113 // The x-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700114 float left;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400115 // The y-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 float top;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400117 // The x-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700118 float right;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400119 // The y-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700120 float bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121} * FS_LPRECTF, FS_RECTF;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400122
123// Const Pointer to FS_RECTF structure.
Tom Sepez9857e202015-05-13 17:09:26 -0700124typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700125
126#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
127// On Windows system, functions are exported in a DLL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700128#define DLLEXPORT __declspec(dllexport)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700129#define STDCALL __stdcall
130#else
131#define DLLEXPORT
132#define STDCALL
133#endif
134
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700135// Exported Functions
136#ifdef __cplusplus
137extern "C" {
138#endif
139
140// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700141// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700142// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700143// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700144// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700145// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700146// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700147// Convenience function to call FPDF_InitLibraryWithConfig() for
148// backwards comatibility purposes.
149DLLEXPORT void STDCALL FPDF_InitLibrary();
150
Dan Sinclair49f88b72015-10-20 15:18:51 -0400151// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700152typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700153 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700154 int version;
155
156 // Array of paths to scan in place of the defaults when using built-in
157 // FXGE font loading code. The array is terminated by a NULL pointer.
158 // The Array may be NULL itself to use the default paths. May be ignored
159 // entirely depending upon the platform.
160 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700161
162 // Version 2.
163
164 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
165 void* m_pIsolate;
166
167 // The embedder data slot to use in the v8::Isolate to store PDFium's
168 // per-isolate data. The value needs to be between 0 and
169 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
170 // for most embedders.
171 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700172} FPDF_LIBRARY_CONFIG;
173
174// Function: FPDF_InitLibraryWithConfig
175// Initialize the FPDFSDK library
176// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400177// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700178// Return value:
179// None.
180// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700181// You have to call this function before you can call any PDF
182// processing functions.
Tom Sepez326a2a72015-11-20 10:47:32 -0800183DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
184 const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700185
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700186// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700187// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700188// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700189// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700190// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700191// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700192// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700193// You can call this function to release all memory blocks allocated by
194// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400195// After this function is called, you should not call any PDF
196// processing functions.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700197DLLEXPORT void STDCALL FPDF_DestroyLibrary();
198
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700199// Policy for accessing the local machine time.
200#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700201
202// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700203// Set the policy for the sandbox environment.
204// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400205// policy - The specified policy for setting, for example:
206// FPDF_POLICY_MACHINETIME_ACCESS.
207// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700208// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700209// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700210DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
211 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700212
Tom Sepez3c3201f2015-05-20 10:20:35 -0700213// Function: FPDF_LoadDocument
214// Open and load a PDF document.
215// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400216// file_path - Path to the PDF file (including extension).
217// password - A string used as the password for the PDF file.
218// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700219// Return value:
220// A handle to the loaded document, or NULL on failure.
221// Comments:
222// Loaded document can be closed by FPDF_CloseDocument().
223// If this function fails, you can use FPDF_GetLastError() to retrieve
224// the reason why it failed.
Tom Sepez326a2a72015-11-20 10:47:32 -0800225// Notes:
226// The application should call FPDF_LoadXFA function after PDF
227// document loaded to support XFA fields in fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700228DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700229 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700230
231// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700232// Open and load a PDF document from memory.
233// Parameters:
234// data_buf - Pointer to a buffer containing the PDF document.
235// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400236// password - A string used as the password for the PDF file.
237// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700238// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400239// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700240// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700241// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400242// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700243// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400244// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700245// Notes:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400246// The application should call FPDF_LoadXFA function after the
247// document is loaded to support form fields.
Tom Sepez9857e202015-05-13 17:09:26 -0700248DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700249 int size,
250 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700251
252// Structure for custom file access.
253typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700254 // File length, in bytes.
255 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700256
Dan Sinclair49f88b72015-10-20 15:18:51 -0400257 // A function pointer for getting a block of data from a specific position.
258 // Position is specified by byte offset from the beginning of the file.
259 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700260 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400261 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700262 // Return value: should be non-zero if successful, zero for error.
263 int (*m_GetBlock)(void* param,
264 unsigned long position,
265 unsigned char* pBuf,
266 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700267
Dan Sinclair49f88b72015-10-20 15:18:51 -0400268 // A custom pointer for all implementation specific data. This pointer will
269 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700270 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700271} FPDF_FILEACCESS;
272
Bo Xufdc00a72014-10-28 23:03:33 -0700273/**
274 * @brief Structure for file reading or writing (I/O).
275 *
276 * @note This is a handler and should be implemented by callers.
277 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700278typedef struct _FPDF_FILEHANDLER {
279 /**
280 * @brief User-defined data.
281 * @note Callers can use this field to track controls.
282 */
283 FPDF_LPVOID clientData;
284 /**
285 * @brief Callback function to release the current file stream object.
286 *
287 * @param[in] clientData Pointer to user-defined data.
288 *
289 * @return None.
290 */
291 void (*Release)(FPDF_LPVOID clientData);
292 /**
293 * @brief Callback function to retrieve the current file stream size.
294 *
295 * @param[in] clientData Pointer to user-defined data.
296 *
297 * @return Size of file stream.
298 */
299 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
300 /**
301 * @brief Callback function to read data from the current file stream.
302 *
303 * @param[in] clientData Pointer to user-defined data.
304 * @param[in] offset Offset position starts from the beginning of file
305 * stream. This parameter indicates reading position.
306 * @param[in] buffer Memory buffer to store data which are read from
307 * file stream. This parameter should not be <b>NULL</b>.
308 * @param[in] size Size of data which should be read from file
309 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
310 * should be enough to store specified data.
311 *
312 * @return 0 for success, other value for failure.
313 */
314 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size);
315 /**
316 * @brief Callback function to write data into the current file stream.
317 *
318 * @param[in] clientData Pointer to user-defined data.
319 * @param[in] offset Offset position starts from the beginning of file
320 * stream. This parameter indicates writing position.
321 * @param[in] buffer Memory buffer contains data which is written into
322 * file stream. This parameter should not be <b>NULL</b>.
323 * @param[in] size Size of data which should be written into file
324 * stream, in bytes.
325 *
326 * @return 0 for success, other value for failure.
327 */
328 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size);
329 /**
330 * @brief Callback function to flush all internal accessing buffers.
331 *
332 * @param[in] clientData Pointer to user-defined data.
333 *
334 * @return 0 for success, other value for failure.
335 */
336 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
337 /**
338 * @brief Callback function to change file size.
339 *
340 * @details This function is called under writing mode usually. Implementer
341 * can determine whether to realize it based on application requests.
342 *
343 * @param[in] clientData Pointer to user-defined data.
344 * @param[in] size New size of file stream, in bytes.
345 *
346 * @return 0 for success, other value for failure.
347 */
348 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700349
350} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
351
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700352// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700353// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700354// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400355// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700356// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700357// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400358// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700359// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400360// The application must keep the file resources valid until the PDF
361// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700362//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400363// The loaded document can be closed with FPDF_CloseDocument.
364// Notes:
365// The application should call the FPDF_LoadXFA function after the
366// document is loaded to support form fields.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700367DLLEXPORT FPDF_DOCUMENT STDCALL
368FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700369
370// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400371// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700372// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400373// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700374// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400375// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700376// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400377// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700378// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400379// If the document was created by FPDF_CreateNewDocument,
380// then this function will always fail.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700381DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
382 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700383
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700384#define FPDF_ERR_SUCCESS 0 // No error.
385#define FPDF_ERR_UNKNOWN 1 // Unknown error.
386#define FPDF_ERR_FILE 2 // File not found or could not be opened.
387#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
388#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
389#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
390#define FPDF_ERR_PAGE 6 // Page not found or content error.
391#define FPDF_ERR_XFALOAD 7 // Load XFA error.
392#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700393
394// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400395// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700396// Parameters:
397// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700398// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400399// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700400// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700401// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400402// function is not defined.
Tom Sepez9857e202015-05-13 17:09:26 -0700403DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700404
405// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700406// Get file permission flags of the document.
407// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400408// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700409// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400410// A 32-bit integer indicating permission flags. Please refer to the
411// PDF Reference for detailed descriptions. If the document is not
412// protected, 0xffffffff will be returned.
Tom Sepez9857e202015-05-13 17:09:26 -0700413DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700414
Bo Xuc5cab022014-09-19 19:16:31 -0700415// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400416// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700417// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400418// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700419// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400420// The security handler revision number. Please refer to the PDF
421// Reference for a detailed description. If the document is not
422// protected, -1 will be returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700423DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
424
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700425// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400426// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700427// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400428// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700429// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700430// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700431DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
432
433// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400434// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700435// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700436// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700437// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700438// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400439// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700440// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400441// The loaded page can be rendered to devices using FPDF_RenderPage.
442// The loaded page can be closed using FPDF_ClosePage.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700443DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
444 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700445
446// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700447// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700448// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400449// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700450// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700451// Page width (excluding non-displayable area) measured in points.
452// One point is 1/72 inch (around 0.3528 mm).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700453DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
454
455// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700456// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700457// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400458// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700459// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700460// Page height (excluding non-displayable area) measured in points.
461// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700462DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
463
464// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400465// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700466// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400467// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700468// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400469// width - Pointer to a double to receive the page width
470// (in points).
471// height - Pointer to a double to receive the page height
472// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700473// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700474// Non-zero for success. 0 for error (document or page not found).
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700475DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
476 int page_index,
477 double* width,
478 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700479
Dan Sinclair49f88b72015-10-20 15:18:51 -0400480// Page rendering flags. They can be combined with bit-wise OR.
481//
482// Set if annotations are to be rendered.
483#define FPDF_ANNOT 0x01
484// Set if using text rendering optimized for LCD display.
485#define FPDF_LCD_TEXT 0x02
486// Don't use the native text output available on some platforms
487#define FPDF_NO_NATIVETEXT 0x04
488// Grayscale output.
489#define FPDF_GRAYSCALE 0x08
490// Set if you want to get some debug info.
491#define FPDF_DEBUG_INFO 0x80
492// Set if you don't want to catch exceptions.
493#define FPDF_NO_CATCH 0x100
494// Limit image cache size.
495#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
496// Always use halftone for image stretching.
497#define FPDF_RENDER_FORCEHALFTONE 0x400
498// Render for printing.
499#define FPDF_PRINTING 0x800
500// Set to disable anti-aliasing on text.
501#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
502// Set to disable anti-aliasing on images.
503#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
504// Set to disable anti-aliasing on paths.
505#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
506// Set whether to render in a reverse Byte order, this flag is only used when
507// rendering to a bitmap.
508#define FPDF_REVERSE_BYTE_ORDER 0x10
509
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700510#ifdef _WIN32
511// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400512// Render contents of a page to a device (screen, bitmap, or printer).
513// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700514// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400515// dc - Handle to the device context.
516// page - Handle to the page. Returned by FPDF_LoadPage.
517// start_x - Left pixel position of the display area in
518// device coordinates.
519// start_y - Top pixel position of the display area in device
520// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700521// size_x - Horizontal size (in pixels) for displaying the page.
522// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400523// rotate - Page orientation:
524// 0 (normal)
525// 1 (rotated 90 degrees clockwise)
526// 2 (rotated 180 degrees)
527// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700528// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400529// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700530// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700531// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700532DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
533 FPDF_PAGE page,
534 int start_x,
535 int start_y,
536 int size_x,
537 int size_y,
538 int rotate,
539 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700540#endif
541
542// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400543// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700544// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700545// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400546// output buffer). The bitmap handle can be created
547// by FPDFBitmap_Create.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700548// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400549// start_x - Left pixel position of the display area in
550// bitmap coordinates.
551// start_y - Top pixel position of the display area in bitmap
552// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700553// size_x - Horizontal size (in pixels) for displaying the page.
554// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400555// rotate - Page orientation:
556// 0 (normal)
557// 1 (rotated 90 degrees clockwise)
558// 2 (rotated 180 degrees)
559// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700560// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400561// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700562// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700563// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700564DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
565 FPDF_PAGE page,
566 int start_x,
567 int start_y,
568 int size_x,
569 int size_y,
570 int rotate,
571 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700572
573// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700574// Close a loaded PDF page.
575// Parameters:
576// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700577// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700578// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700579DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
580
581// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700582// Close a loaded PDF document.
583// Parameters:
584// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700585// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700586// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700587DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
588
589// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400590// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700591// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400592// page - Handle to the page. Returned by FPDF_LoadPage.
593// start_x - Left pixel position of the display area in
594// device coordinates.
595// start_y - Top pixel position of the display area in device
596// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700597// size_x - Horizontal size (in pixels) for displaying the page.
598// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400599// rotate - Page orientation:
600// 0 (normal)
601// 1 (rotated 90 degrees clockwise)
602// 2 (rotated 180 degrees)
603// 3 (rotated 90 degrees counter-clockwise)
604// device_x - X value in device coordinates to be converted.
605// device_y - Y value in device coordinates to be converted.
606// page_x - A pointer to a double receiving the converted X
607// value in page coordinates.
608// page_y - A pointer to a double receiving the converted Y
609// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700610// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700611// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700612// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400613// The page coordinate system has its origin at the left-bottom corner
614// of the page, with the X-axis on the bottom going to the right, and
615// the Y-axis on the left side going up.
616//
617// NOTE: this coordinate system can be altered when you zoom, scroll,
618// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700619// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700620//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700621// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400622// its origin is at the left-top corner of the window. However this
623// origin can be altered by the Windows coordinate transformation
624// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700625//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400626// You must make sure the start_x, start_y, size_x, size_y
627// and rotate parameters have exactly same values as you used in
628// the FPDF_RenderPage() function call.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700629DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
630 int start_x,
631 int start_y,
632 int size_x,
633 int size_y,
634 int rotate,
635 int device_x,
636 int device_y,
637 double* page_x,
638 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700639
640// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400641// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700642// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400643// page - Handle to the page. Returned by FPDF_LoadPage.
644// start_x - Left pixel position of the display area in
645// device coordinates.
646// start_y - Top pixel position of the display area in device
647// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700648// size_x - Horizontal size (in pixels) for displaying the page.
649// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400650// rotate - Page orientation:
651// 0 (normal)
652// 1 (rotated 90 degrees clockwise)
653// 2 (rotated 180 degrees)
654// 3 (rotated 90 degrees counter-clockwise)
655// page_x - X value in page coordinates.
656// page_y - Y value in page coordinate.
657// device_x - A pointer to an integer receiving the result X
658// value in device coordinates.
659// device_y - A pointer to an integer receiving the result Y
660// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700661// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700662// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700663// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400664// See comments for FPDF_DeviceToPage().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700665DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
666 int start_x,
667 int start_y,
668 int size_x,
669 int size_y,
670 int rotate,
671 double page_x,
672 double page_y,
673 int* device_x,
674 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700675
676// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400677// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700678// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400679// width - The number of pixels in width for the bitmap.
680// Must be greater than 0.
681// height - The number of pixels in height for the bitmap.
682// Must be greater than 0.
683// alpha - A flag indicating whether the alpha channel is used.
684// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700685// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400686// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700687// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700688// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400689// The bitmap always uses 4 bytes per pixel. The first byte is always
690// double word aligned.
691//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700692// The byte order is BGRx (the last byte unused if no alpha channel) or
693// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700694//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400695// The pixels in a horizontal line are stored side by side, with the
696// left most pixel stored first (with lower memory address).
697// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700698//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400699// Lines are stored one after another, with the top most line stored
700// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700701//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700702// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400703// bitmap, but it doesn't initialize the buffer. Applications can use
704// FPDFBitmap_FillRect to fill the bitmap using any color.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700705DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
706 int height,
707 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700708
709// More DIB formats
Dan Sinclair49f88b72015-10-20 15:18:51 -0400710// Gray scale bitmap, one byte per pixel.
711#define FPDFBitmap_Gray 1
712// 3 bytes per pixel, byte order: blue, green, red.
713#define FPDFBitmap_BGR 2
714// 4 bytes per pixel, byte order: blue, green, red, unused.
715#define FPDFBitmap_BGRx 3
716// 4 bytes per pixel, byte order: blue, green, red, alpha.
717#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700718
719// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400720// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700721// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400722// width - The number of pixels in width for the bitmap.
723// Must be greater than 0.
724// height - The number of pixels in height for the bitmap.
725// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700726// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400727// above.
728// first_scan - A pointer to the first byte of the first line if
729// using an external buffer. If this parameter is NULL,
730// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700731// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400732// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700733// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400734// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700735// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400736// Similar to FPDFBitmap_Create function, but allows for more formats
737// and an external buffer is supported. The bitmap created by this
738// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700739// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700740//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400741// If an external buffer is used, then the application should destroy
742// the buffer by itself. FPDFBitmap_Destroy function will not destroy
743// the buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700744DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
745 int height,
746 int format,
747 void* first_scan,
748 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700749
750// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400751// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700752// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700753// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400754// FPDFBitmap_Create.
755// left - The left position. Starting from 0 at the
756// left-most pixel.
757// top - The top position. Starting from 0 at the
758// top-most line.
759// width - Width in pixels to be filled.
760// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700761// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400762// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700763// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700764// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700765// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400766// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700767// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700768//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400769// NOTE: If the alpha channel is used, this function does NOT
770// composite the background with the source color, instead the
771// background will be replaced by the source color and the alpha.
772//
773// If the alpha channel is not used, the alpha parameter is ignored.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700774DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
775 int left,
776 int top,
777 int width,
778 int height,
779 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700780
781// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400782// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700783// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400784// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700785// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700786// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700787// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700788// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400789//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700790// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400791// then manipulate any color and/or alpha values for any pixels in the
792// bitmap.
793//
794// The data is in BGRA format. Where the A maybe unused if alpha was
795// not specified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700796DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
797
798// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400799// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700800// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400801// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700802// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400803// The width of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700804DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
805
806// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400807// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700808// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400809// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700810// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400811// The height of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700812DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
813
814// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400815// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700816// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400817// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700818// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400819// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700820// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400821// The stride may be more than width * number of bytes per pixel.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700822DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
823
824// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400825// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700826// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400827// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700828// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700829// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700830// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400831// This function will not destroy any external buffers provided when
832// the bitmap was created.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700833DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
834
835// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700836// Whether the PDF document prefers to be scaled or not.
837// Parameters:
838// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700839// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700840// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700841DLLEXPORT FPDF_BOOL STDCALL
842FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700843
Bo Xu9114e832014-07-14 13:22:47 -0700844// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700845// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700846// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700847// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700848// Return value:
849// The number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700850DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
851
852// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700853// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700854// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700855// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700856// Return value:
857// The print page range to be used for printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700858DLLEXPORT FPDF_PAGERANGE STDCALL
859FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700860
861// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700862// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -0400863// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700864// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700865// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700866// Return value:
867// The paper handling option to be used when printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700868DLLEXPORT FPDF_DUPLEXTYPE STDCALL
869FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700870
Bo Xu4d62b6b2015-01-10 22:52:59 -0800871// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700872// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800873// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700874// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800875// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700876// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800877DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
878
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700879// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -0400880// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -0700881// Parameters:
882// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400883// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700884// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400885// The handle to the destination.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700886DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
887 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700888
Bo Xu4d62b6b2015-01-10 22:52:59 -0800889// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -0400890// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800891// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700892// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -0400893// index - The index of a named destination.
894// buffer - The buffer to store the destination name,
895// used as wchar_t*.
896// buflen [in/out] - Size of the buffer in bytes on input,
897// length of the result in bytes on output
898// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800899// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400900// The destination handle for a given index, or NULL if there is no
901// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800902// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700903// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400904// 1) First time pass in |buffer| as NULL and get buflen.
905// 2) Second time pass in allocated |buffer| and buflen to retrieve
906// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800907//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400908// If buflen is not sufficiently large, it will be set to -1 upon
909// return.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700910DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
911 int index,
912 void* buffer,
913 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -0800914
Tom Sepez9857e202015-05-13 17:09:26 -0700915// Function: FPDF_BStr_Init
916// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700917DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
918
Tom Sepez9857e202015-05-13 17:09:26 -0700919// Function: FPDF_BStr_Set
920// Helper function to set string data.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700921DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
922 FPDF_LPCSTR bstr,
923 int length);
Bo Xufdc00a72014-10-28 23:03:33 -0700924
Tom Sepez9857e202015-05-13 17:09:26 -0700925// Function: FPDF_BStr_Clear
926// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700927DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
928
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700929#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -0700930}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700931#endif
932
Tom Sepez9857e202015-05-13 17:09:26 -0700933#endif // PUBLIC_FPDFVIEW_H_