blob: f8997098738aaa71721cbd5a8a1999f1f0b8ef0c [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
Nico Weber9d8ec5a2015-08-04 13:00:21 -070070typedef const unsigned short*
71 FPDF_WIDESTRING; // Foxit PDF SDK always use UTF-16LE encoding wide string,
72// each character use 2 bytes (except surrogation), with low byte first.
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_
76/** @brief Structure for byte string.
77 *
78 * @note In SDK, a byte string commonly means a UTF-16LE format string.
79 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -070080typedef struct _FPDF_BSTR {
81 /**
82 * @brief String buffer.
83 */
84 char* str;
85 /**
86 * @brief Length of a string, in bytes.
87 */
88 int len;
Bo Xufdc00a72014-10-28 23:03:33 -070089} FPDF_BSTR;
90
91#endif
92
Nico Weber9d8ec5a2015-08-04 13:00:21 -070093// For Windows programmers: for most case it's OK to treat FPDF_WIDESTRING as
94// Windows unicode string,
95// however, special care needs to be taken if you expect to process
96// Unicode larger than 0xffff.
97// For Linux/Unix programmers: most compiler/library environment uses 4 bytes
98// for a Unicode character,
99// you have to convert between FPDF_WIDESTRING and system wide string by
100// yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700101
102#ifdef _WIN32_WCE
103typedef const unsigned short* FPDF_STRING;
104#else
105typedef const char* FPDF_STRING;
106#endif
107
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700108/** @brief Matrix for transformation. */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700109typedef struct _FS_MATRIX_ {
110 float a; /**< @brief Coefficient a.*/
111 float b; /**< @brief Coefficient b.*/
112 float c; /**< @brief Coefficient c.*/
113 float d; /**< @brief Coefficient d.*/
114 float e; /**< @brief Coefficient e.*/
115 float f; /**< @brief Coefficient f.*/
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700116} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700117
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700118/** @brief Rectangle area(float) in device or page coordination system. */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700119typedef struct _FS_RECTF_ {
120 /**@{*/
121 /** @brief The x-coordinate of the left-top corner. */
122 float left;
123 /** @brief The y-coordinate of the left-top corner. */
124 float top;
125 /** @brief The x-coordinate of the right-bottom corner. */
126 float right;
127 /** @brief The y-coordinate of the right-bottom corner. */
128 float bottom;
129 /**@}*/
130} * FS_LPRECTF, FS_RECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700131/** @brief Const Pointer to ::FS_RECTF structure.*/
Tom Sepez9857e202015-05-13 17:09:26 -0700132typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700133
134#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
135// On Windows system, functions are exported in a DLL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700136#define DLLEXPORT __declspec(dllexport)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700137#define STDCALL __stdcall
138#else
139#define DLLEXPORT
140#define STDCALL
141#endif
142
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700143// Exported Functions
144#ifdef __cplusplus
145extern "C" {
146#endif
147
148// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700149// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700150// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700151// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700152// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700153// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700154// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700155// Convenience function to call FPDF_InitLibraryWithConfig() for
156// backwards comatibility purposes.
157DLLEXPORT void STDCALL FPDF_InitLibrary();
158
159// Process-wide options for initializing library.
160typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700161 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700162 int version;
163
164 // Array of paths to scan in place of the defaults when using built-in
165 // FXGE font loading code. The array is terminated by a NULL pointer.
166 // The Array may be NULL itself to use the default paths. May be ignored
167 // entirely depending upon the platform.
168 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700169
170 // Version 2.
171
172 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
173 void* m_pIsolate;
174
175 // The embedder data slot to use in the v8::Isolate to store PDFium's
176 // per-isolate data. The value needs to be between 0 and
177 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
178 // for most embedders.
179 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700180} FPDF_LIBRARY_CONFIG;
181
182// Function: FPDF_InitLibraryWithConfig
183// Initialize the FPDFSDK library
184// Parameters:
185// cfg - configuration information as above.
186// Return value:
187// None.
188// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700189// You have to call this function before you can call any PDF
190// processing functions.
Lei Zhang6f62d532015-09-23 15:31:44 -0700191DLLEXPORT void STDCALL
192FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700193
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700194// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700195// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700196// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700197// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700198// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700199// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700200// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700201// You can call this function to release all memory blocks allocated by
202// the library.
203// After this function called, you should not call any PDF processing
204// functions.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700205DLLEXPORT void STDCALL FPDF_DestroyLibrary();
206
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700207// Policy for accessing the local machine time.
208#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700209
210// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700211// Set the policy for the sandbox environment.
212// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700213// policy - The specified policy for setting, for
214// example:FPDF_POLICY_MACHINETIME_ACCESS.
Tom Sepez9857e202015-05-13 17:09:26 -0700215// enable - True for enable, False for disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700216// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700217// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700218DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
219 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700220
Tom Sepez3c3201f2015-05-20 10:20:35 -0700221// Function: FPDF_LoadDocument
222// Open and load a PDF document.
223// Parameters:
224// file_path [in] - Path to the PDF file (including extension).
225// password [in] - A string used as the password for PDF file.
226// If no password needed, empty or NULL can be used.
227// Return value:
228// A handle to the loaded document, or NULL on failure.
229// Comments:
230// Loaded document can be closed by FPDF_CloseDocument().
231// If this function fails, you can use FPDF_GetLastError() to retrieve
232// the reason why it failed.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700233// The application should call ::FPDF_LoadXFA function after PDF
234// document loaded
Tom Sepez3c3201f2015-05-20 10:20:35 -0700235// to support XFA fields in fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700236DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700237 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700238
239// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700240// Open and load a PDF document from memory.
241// Parameters:
242// data_buf - Pointer to a buffer containing the PDF document.
243// size - Number of bytes in the PDF document.
244// password - A string used as the password for PDF file.
245// If no password needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700246// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700247// A handle to the loaded document. If failed, NULL is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700248// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700249// The memory buffer must remain valid when the document is open.
250// Loaded document can be closed by FPDF_CloseDocument.
251// If this function fails, you can use FPDF_GetLastError() to retrieve
252// the reason why it fails.
Bo Xufdc00a72014-10-28 23:03:33 -0700253// Notes:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700254// The application should call ::FPDF_LoadXFA function after PDF
255// document loaded
Tom Sepez9857e202015-05-13 17:09:26 -0700256// to support XFA fields in fpdfformfill.h file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700257//
Tom Sepez9857e202015-05-13 17:09:26 -0700258DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700259 int size,
260 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700261
262// Structure for custom file access.
263typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700264 // File length, in bytes.
265 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700266
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700267 // A function pointer for getting a block of data from specific position.
268 // Position is specified by byte offset from beginning of the file.
269 // The position and size will never go out range of file length.
270 // It may be possible for FPDFSDK to call this function multiple times for
271 // same position.
272 // Return value: should be non-zero if successful, zero for error.
273 int (*m_GetBlock)(void* param,
274 unsigned long position,
275 unsigned char* pBuf,
276 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700277
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700278 // A custom pointer for all implementation specific data.
279 // This pointer will be used as the first parameter to m_GetBlock callback.
280 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700281} FPDF_FILEACCESS;
282
Bo Xufdc00a72014-10-28 23:03:33 -0700283/**
284 * @brief Structure for file reading or writing (I/O).
285 *
286 * @note This is a handler and should be implemented by callers.
287 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700288typedef struct _FPDF_FILEHANDLER {
289 /**
290 * @brief User-defined data.
291 * @note Callers can use this field to track controls.
292 */
293 FPDF_LPVOID clientData;
294 /**
295 * @brief Callback function to release the current file stream object.
296 *
297 * @param[in] clientData Pointer to user-defined data.
298 *
299 * @return None.
300 */
301 void (*Release)(FPDF_LPVOID clientData);
302 /**
303 * @brief Callback function to retrieve the current file stream size.
304 *
305 * @param[in] clientData Pointer to user-defined data.
306 *
307 * @return Size of file stream.
308 */
309 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
310 /**
311 * @brief Callback function to read data from the current file stream.
312 *
313 * @param[in] clientData Pointer to user-defined data.
314 * @param[in] offset Offset position starts from the beginning of file
315 * stream. This parameter indicates reading position.
316 * @param[in] buffer Memory buffer to store data which are read from
317 * file stream. This parameter should not be <b>NULL</b>.
318 * @param[in] size Size of data which should be read from file
319 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
320 * should be enough to store specified data.
321 *
322 * @return 0 for success, other value for failure.
323 */
324 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size);
325 /**
326 * @brief Callback function to write data into the current file stream.
327 *
328 * @param[in] clientData Pointer to user-defined data.
329 * @param[in] offset Offset position starts from the beginning of file
330 * stream. This parameter indicates writing position.
331 * @param[in] buffer Memory buffer contains data which is written into
332 * file stream. This parameter should not be <b>NULL</b>.
333 * @param[in] size Size of data which should be written into file
334 * stream, in bytes.
335 *
336 * @return 0 for success, other value for failure.
337 */
338 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size);
339 /**
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
360} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
361
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:
Tom Sepez9857e202015-05-13 17:09:26 -0700365// pFileAccess - A structure for access the file.
366// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700367// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700368// A handle to the loaded document. If failed, NULL is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700369// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700370// The application should maintain the file resources being valid until
371// the PDF document close.
Tom Sepez9857e202015-05-13 17:09:26 -0700372// Loaded document can be closed by FPDF_CloseDocument.
Bo Xufdc00a72014-10-28 23:03:33 -0700373// Notes:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700374// The application should call ::FPDF_LoadXFA function after PDF
375// document loaded
Tom Sepez9857e202015-05-13 17:09:26 -0700376// to support XFA fields in fpdfformfill.h file.
Bo Xufdc00a72014-10-28 23:03:33 -0700377//
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
Tom Sepez9857e202015-05-13 17:09:26 -0700382// Get the file version of the specific PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700383// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700384// doc - Handle to document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700385// fileVersion - The PDF file version. File version: 14 for 1.4, 15
386// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700387// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700388// TRUE if this call succeed, If failed, FALSE is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700389// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700390// If the document is created by function ::FPDF_CreateNewDocument,
391// then this function would always fail.
Bo Xufdc00a72014-10-28 23:03:33 -0700392//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700393DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
394 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700395
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700396#define FPDF_ERR_SUCCESS 0 // No error.
397#define FPDF_ERR_UNKNOWN 1 // Unknown error.
398#define FPDF_ERR_FILE 2 // File not found or could not be opened.
399#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
400#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
401#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
402#define FPDF_ERR_PAGE 6 // Page not found or content error.
403#define FPDF_ERR_XFALOAD 7 // Load XFA error.
404#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700405
406// Function: FPDF_GetLastError
Tom Sepez9857e202015-05-13 17:09:26 -0700407// Get last error code when an SDK function failed.
408// Parameters:
409// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700410// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700411// A 32-bit integer indicating error codes (defined above).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700412// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700413// If the previous SDK call succeeded, the return value of this
414// function
Tom Sepez9857e202015-05-13 17:09:26 -0700415// is not defined.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700416//
Tom Sepez9857e202015-05-13 17:09:26 -0700417DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700418
419// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700420// Get file permission flags of the document.
421// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700422// document - Handle to document. Returned by FPDF_LoadDocument
423// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700424// Return value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700425// A 32-bit integer indicating permission flags. Please refer to PDF
426// Reference for
427// detailed description. If the document is not protected, 0xffffffff
428// will be returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700429//
Tom Sepez9857e202015-05-13 17:09:26 -0700430DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700431
Bo Xuc5cab022014-09-19 19:16:31 -0700432// Function: FPDF_GetSecurityHandlerRevision
Tom Sepez9857e202015-05-13 17:09:26 -0700433// Get the revision for security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700434// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700435// document - Handle to document. Returned by FPDF_LoadDocument
436// function.
Bo Xuc5cab022014-09-19 19:16:31 -0700437// Return value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700438// The security handler revision number. Please refer to PDF Reference
439// for
440// detailed description. If the document is not protected, -1 will be
441// returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700442//
443DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
444
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700445// Function: FPDF_GetPageCount
Tom Sepez9857e202015-05-13 17:09:26 -0700446// Get total number of pages in a document.
447// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700448// document - Handle to document. Returned by FPDF_LoadDocument
449// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700450// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700451// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700452//
453DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
454
455// Function: FPDF_LoadPage
Tom Sepez9857e202015-05-13 17:09:26 -0700456// Load a page inside a document.
457// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700458// document - Handle to document. Returned by FPDF_LoadDocument
459// function.
Tom Sepez9857e202015-05-13 17:09:26 -0700460// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700461// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700462// A handle to the loaded page. If failed, NULL is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700463// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700464// Loaded page can be rendered to devices using FPDF_RenderPage
465// function.
Tom Sepez9857e202015-05-13 17:09:26 -0700466// Loaded page can be closed by FPDF_ClosePage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700467//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700468DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
469 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700470
471// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700472// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700473// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700474// page - Handle to the page. Returned by FPDF_LoadPage
475// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700476// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700477// Page width (excluding non-displayable area) measured in points.
478// One point is 1/72 inch (around 0.3528 mm).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700479//
480DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
481
482// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700483// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700484// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700485// page - Handle to the page. Returned by FPDF_LoadPage
486// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700487// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700488// Page height (excluding non-displayable area) measured in points.
489// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700490//
491DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
492
493// Function: FPDF_GetPageSizeByIndex
Tom Sepez9857e202015-05-13 17:09:26 -0700494// Get the size of a page by index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700495// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700496// document - Handle to document. Returned by FPDF_LoadDocument
497// function.
Tom Sepez9857e202015-05-13 17:09:26 -0700498// page_index - Page index, zero for the first page.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700499// width - Pointer to a double value receiving the page width
500// (in points).
501// height - Pointer to a double value receiving the page height
502// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700503// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700504// Non-zero for success. 0 for error (document or page not found).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700505//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700506DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
507 int page_index,
508 double* width,
509 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700510
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700511// Page rendering flags. They can be combined with bit OR.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700512#define FPDF_ANNOT 0x01 // Set if annotations are to be rendered.
513#define FPDF_LCD_TEXT \
514 0x02 // Set if using text rendering optimized for LCD display.
515#define FPDF_NO_NATIVETEXT \
516 0x04 // Don't use the native text output available on some platforms
517#define FPDF_GRAYSCALE 0x08 // Grayscale output.
518#define FPDF_DEBUG_INFO 0x80 // Set if you want to get some debug info.
519// Please discuss with Foxit first if you need to collect debug info.
520#define FPDF_NO_CATCH 0x100 // Set if you don't want to catch exception.
521#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 // Limit image cache size.
522#define FPDF_RENDER_FORCEHALFTONE \
523 0x400 // Always use halftone for image stretching.
524#define FPDF_PRINTING 0x800 // Render for printing.
525#define FPDF_REVERSE_BYTE_ORDER \
526 0x10 // set whether render in a reverse Byte order, this flag only
527// enable when render to a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700528#ifdef _WIN32
529// Function: FPDF_RenderPage
Tom Sepez9857e202015-05-13 17:09:26 -0700530// Render contents in a page to a device (screen, bitmap, or printer).
531// This function is only supported on Windows system.
532// Parameters:
533// dc - Handle to device context.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700534// page - Handle to the page. Returned by FPDF_LoadPage
535// function.
536// start_x - Left pixel position of the display area in the
537// device coordinate.
538// start_y - Top pixel position of the display area in the device
539// coordinate.
Tom Sepez9857e202015-05-13 17:09:26 -0700540// size_x - Horizontal size (in pixels) for displaying the page.
541// size_y - Vertical size (in pixels) for displaying the page.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700542// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees
543// clockwise),
544// 2 (rotated 180 degrees), 3 (rotated 90 degrees
545// counter-clockwise).
546// flags - 0 for normal display, or combination of flags
547// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700548// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700549// None.
Bo Xufdc00a72014-10-28 23:03:33 -0700550// Notes:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700551// The method can not support to render the page for the document
552// consists of dynamic XFA fields.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700553//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700554DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
555 FPDF_PAGE page,
556 int start_x,
557 int start_y,
558 int size_x,
559 int size_y,
560 int rotate,
561 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700562#endif
563
564// Function: FPDF_RenderPageBitmap
Tom Sepez9857e202015-05-13 17:09:26 -0700565// Render contents in a page to a device independent bitmap
566// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700567// bitmap - Handle to the device independent bitmap (as the
568// output buffer).
569// Bitmap handle can be created by FPDFBitmap_Create
570// function.
571// page - Handle to the page. Returned by FPDF_LoadPage
572// function.
573// start_x - Left pixel position of the display area in the
574// bitmap coordinate.
575// start_y - Top pixel position of the display area in the bitmap
576// coordinate.
Tom Sepez9857e202015-05-13 17:09:26 -0700577// size_x - Horizontal size (in pixels) for displaying the page.
578// size_y - Vertical size (in pixels) for displaying the page.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700579// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees
580// clockwise),
581// 2 (rotated 180 degrees), 3 (rotated 90 degrees
582// counter-clockwise).
583// flags - 0 for normal display, or combination of flags
584// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700585// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700586// None.
Bo Xufdc00a72014-10-28 23:03:33 -0700587// Notes:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700588// The method can not support to render the page for the document
589// consists of dynamic XFA fields.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700590//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700591DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
592 FPDF_PAGE page,
593 int start_x,
594 int start_y,
595 int size_x,
596 int size_y,
597 int rotate,
598 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700599
600// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700601// Close a loaded PDF page.
602// Parameters:
603// page - Handle to the loaded page.
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 -0700606//
607DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
608
609// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700610// Close a loaded PDF document.
611// Parameters:
612// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700613// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700614// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700615//
616DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
617
618// Function: FPDF_DeviceToPage
Tom Sepez9857e202015-05-13 17:09:26 -0700619// Convert the screen coordinate of a point to page coordinate.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700620// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700621// page - Handle to the page. Returned by FPDF_LoadPage
622// function.
623// start_x - Left pixel position of the display area in the
624// device coordinate.
625// start_y - Top pixel position of the display area in the device
626// coordinate.
Tom Sepez9857e202015-05-13 17:09:26 -0700627// size_x - Horizontal size (in pixels) for displaying the page.
628// size_y - Vertical size (in pixels) for displaying the page.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700629// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees
630// clockwise),
631// 2 (rotated 180 degrees), 3 (rotated 90 degrees
632// counter-clockwise).
633// device_x - X value in device coordinate, for the point to be
634// converted.
635// device_y - Y value in device coordinate, for the point to be
636// converted.
637// page_x - A Pointer to a double receiving the converted X
638// value in page coordinate.
639// page_y - A Pointer to a double receiving the converted Y
640// value in page coordinate.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700641// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700642// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700643// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700644// The page coordinate system has its origin at left-bottom corner of
645// the page, with X axis goes along
646// the bottom side to the right, and Y axis goes along the left side
647// upward. NOTE: this coordinate system
648// can be altered when you zoom, scroll, or rotate a page, however, a
649// point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700650// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700651//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700652// The device coordinate system is device dependent. For screen device,
653// its origin is at left-top
654// corner of the window. However this origin can be altered by Windows
655// coordinate transformation
656// utilities. You must make sure the start_x, start_y, size_x, size_y
657// and rotate parameters have exactly
Tom Sepez9857e202015-05-13 17:09:26 -0700658// same values as you used in FPDF_RenderPage() function call.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700659//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700660DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
661 int start_x,
662 int start_y,
663 int size_x,
664 int size_y,
665 int rotate,
666 int device_x,
667 int device_y,
668 double* page_x,
669 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700670
671// Function: FPDF_PageToDevice
Tom Sepez9857e202015-05-13 17:09:26 -0700672// Convert the page coordinate of a point to screen coordinate.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700673// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700674// page - Handle to the page. Returned by FPDF_LoadPage
675// function.
676// start_x - Left pixel position of the display area in the
677// device coordinate.
678// start_y - Top pixel position of the display area in the device
679// coordinate.
Tom Sepez9857e202015-05-13 17:09:26 -0700680// size_x - Horizontal size (in pixels) for displaying the page.
681// size_y - Vertical size (in pixels) for displaying the page.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700682// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees
683// clockwise),
684// 2 (rotated 180 degrees), 3 (rotated 90 degrees
685// counter-clockwise).
686// page_x - X value in page coordinate, for the point to be
687// converted.
688// page_y - Y value in page coordinate, for the point to be
689// converted.
690// device_x - A pointer to an integer receiving the result X value
691// in device coordinate.
692// device_y - A pointer to an integer receiving the result Y value
693// in device coordinate.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700694// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700695// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700696// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700697// See comments of FPDF_DeviceToPage() function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700698//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700699DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
700 int start_x,
701 int start_y,
702 int size_x,
703 int size_y,
704 int rotate,
705 double page_x,
706 double page_y,
707 int* device_x,
708 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700709
710// Function: FPDFBitmap_Create
Tom Sepez9857e202015-05-13 17:09:26 -0700711// Create a Foxit Device Independent Bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700712// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700713// width - Number of pixels in a horizontal line of the bitmap.
714// Must be greater than 0.
715// height - Number of pixels in a vertical line of the bitmap.
716// Must be greater than 0.
717// alpha - A flag indicating whether alpha channel is used.
718// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700719// Return value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700720// The created bitmap handle, or NULL if parameter error or out of
721// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700722// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700723// An FXDIB always use 4 byte per pixel. The first byte of a pixel is
724// always double word aligned.
725// Each pixel contains red (R), green (G), blue (B) and optionally
726// alpha (A) values.
727// The byte order is BGRx (the last byte unused if no alpha channel) or
728// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700729//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700730// The pixels in a horizontal line (also called scan line) are stored
731// side by side, with left most
732// pixel stored first (with lower memory address). Each scan line uses
733// width*4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700734//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700735// Scan lines are stored one after another, with top most scan line
736// stored first. There is no gap
Tom Sepez9857e202015-05-13 17:09:26 -0700737// between adjacent scan lines.
738//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700739// This function allocates enough memory for holding all pixels in the
740// bitmap, but it doesn't
741// initialize the buffer. Applications can use FPDFBitmap_FillRect to
742// fill the bitmap using any color.
743DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
744 int height,
745 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700746
747// More DIB formats
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700748#define FPDFBitmap_Gray 1 // Gray scale bitmap, one byte per pixel.
749#define FPDFBitmap_BGR 2 // 3 bytes per pixel, byte order: blue, green, red.
750#define FPDFBitmap_BGRx \
751 3 // 4 bytes per pixel, byte order: blue, green, red, unused.
752#define FPDFBitmap_BGRA \
753 4 // 4 bytes per pixel, byte order: blue, green, red, alpha.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700754
755// Function: FPDFBitmap_CreateEx
Tom Sepez9857e202015-05-13 17:09:26 -0700756// Create a Foxit Device Independent Bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700757// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700758// width - Number of pixels in a horizontal line of the bitmap.
759// Must be greater than 0.
760// height - Number of pixels in a vertical line of the bitmap.
761// Must be greater than 0.
762// format - A number indicating for bitmap format, as defined
763// above.
764// first_scan - A pointer to the first byte of first scan line, for
765// external buffer
766// only. If this parameter is NULL, then the SDK will
767// create its own buffer.
768// stride - Number of bytes for each scan line, for external
769// buffer only..
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700770// Return value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700771// The created bitmap handle, or NULL if parameter error or out of
772// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700773// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700774// Similar to FPDFBitmap_Create function, with more formats and
775// external buffer supported.
776// Bitmap created by this function can be used in any place that a
777// FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700778// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700779//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700780// If external scanline buffer is used, then the application should
781// destroy the buffer
Tom Sepez9857e202015-05-13 17:09:26 -0700782// by itself. FPDFBitmap_Destroy function will not destroy the buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700783//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700784DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
785 int height,
786 int format,
787 void* first_scan,
788 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700789
790// Function: FPDFBitmap_FillRect
Tom Sepez9857e202015-05-13 17:09:26 -0700791// Fill a rectangle area in an FXDIB.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700792// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700793// bitmap - The handle to the bitmap. Returned by
794// FPDFBitmap_Create function.
795// left - The left side position. Starting from 0 at the
796// left-most pixel.
797// top - The top side position. Starting from 0 at the
798// top-most scan line.
Tom Sepez9857e202015-05-13 17:09:26 -0700799// width - Number of pixels to be filled in each scan line.
800// height - Number of scan lines to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700801// color - A 32-bit value specifing the color, in 8888 ARGB
802// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700803// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700804// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700805// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700806// This function set the color and (optionally) alpha value in
807// specified region of the bitmap.
808// NOTE: If alpha channel is used, this function does NOT composite the
809// background with the source color,
810// instead the background will be replaced by the source color and
811// alpha.
Tom Sepez9857e202015-05-13 17:09:26 -0700812// If alpha channel is not used, the "alpha" parameter is ignored.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700813//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700814DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
815 int left,
816 int top,
817 int width,
818 int height,
819 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700820
821// Function: FPDFBitmap_GetBuffer
Tom Sepez9857e202015-05-13 17:09:26 -0700822// Get data buffer of an FXDIB
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700823// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700824// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
825// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700826// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700827// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700828// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700829// The stride may be more than width * number of bytes per pixel
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700830// Applications can use this function to get the bitmap buffer pointer,
831// then manipulate any color
Tom Sepez9857e202015-05-13 17:09:26 -0700832// and/or alpha values for any pixels in the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700833DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
834
835// Function: FPDFBitmap_GetWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700836// Get width of an FXDIB.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700837// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700838// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
839// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700840// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700841// The number of pixels in a horizontal line of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700842DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
843
844// Function: FPDFBitmap_GetHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700845// Get height of an FXDIB.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700846// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700847// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
848// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700849// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700850// The number of pixels in a vertical line of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700851DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
852
853// Function: FPDFBitmap_GetStride
Tom Sepez9857e202015-05-13 17:09:26 -0700854// Get number of bytes for each scan line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700855// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700856// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
857// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700858// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700859// The number of bytes for each scan line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700860// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700861// The stride may be more than width * number of bytes per pixel
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700862DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
863
864// Function: FPDFBitmap_Destroy
Tom Sepez9857e202015-05-13 17:09:26 -0700865// Destroy an FXDIB and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700866// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700867// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
868// function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700869// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700870// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700871// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700872// This function will not destroy any external buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700873//
874DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
875
876// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700877// Whether the PDF document prefers to be scaled or not.
878// Parameters:
879// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700880// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700881// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700882//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700883DLLEXPORT FPDF_BOOL STDCALL
884FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700885
Bo Xu9114e832014-07-14 13:22:47 -0700886// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700887// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700888// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700889// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700890// Return value:
891// The number of copies to be printed.
892//
893DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
894
895// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700896// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700897// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700898// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700899// Return value:
900// The print page range to be used for printing.
901//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700902DLLEXPORT FPDF_PAGERANGE STDCALL
903FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700904
905// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700906// Returns the paper handling option to be used when printing from
907// print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700908// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700909// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700910// Return value:
911// The paper handling option to be used when printing.
912//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700913DLLEXPORT FPDF_DUPLEXTYPE STDCALL
914FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700915
Bo Xu4d62b6b2015-01-10 22:52:59 -0800916// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700917// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800918// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700919// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800920// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700921// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800922DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
923
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700924// Function: FPDF_GetNamedDestByName
Tom Sepez9857e202015-05-13 17:09:26 -0700925// get a special dest handle by the index.
926// Parameters:
927// document - Handle to the loaded document.
928// name - The name of a special named dest.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700929// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700930// The handle of the dest.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700931//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700932DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
933 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700934
Bo Xu4d62b6b2015-01-10 22:52:59 -0800935// Function: FPDF_GetNamedDest
Tom Sepez9857e202015-05-13 17:09:26 -0700936// Get the specified named destinations of the PDF document by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800937// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700938// document - Handle to a document
939// index - The index of named destination.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700940// buffer - The buffer to obtain destination name, used as
941// wchar_t*.
942// buflen [in/out] - Size of the buffer in bytes on input, length of
943// the result in bytes on output or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800944// Return value:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700945// The destination handle of a named destination, or NULL if no named
946// destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800947// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700948// Call this function twice to get the name of the named destination:
949// 1) First time pass in |buffer| as NULL and get buflen.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700950// 2) Second time pass in allocated |buffer| and buflen to retrieve
951// |buffer|, which should be used as wchar_t*.
952// If buflen is not sufficiently large, it will be set to -1 upon
953// return.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800954//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700955DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
956 int index,
957 void* buffer,
958 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -0800959
Tom Sepez9857e202015-05-13 17:09:26 -0700960// Function: FPDF_BStr_Init
961// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700962DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
963
Tom Sepez9857e202015-05-13 17:09:26 -0700964// Function: FPDF_BStr_Set
965// Helper function to set string data.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700966DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
967 FPDF_LPCSTR bstr,
968 int length);
Bo Xufdc00a72014-10-28 23:03:33 -0700969
Tom Sepez9857e202015-05-13 17:09:26 -0700970// Function: FPDF_BStr_Clear
971// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700972DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
973
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700974#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -0700975}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700976#endif
977
Tom Sepez9857e202015-05-13 17:09:26 -0700978#endif // PUBLIC_FPDFVIEW_H_