blob: e56071a557d19e6d18c7545351aa91b834c6522d [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;
28typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
29typedef 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_ {
55 DuplexUndefined = 0,
56 Simplex,
57 DuplexFlipShortEdge,
58 DuplexFlipLongEdge
59} 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
66// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070067typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070068
Tom Sepez9857e202015-05-13 17:09:26 -070069typedef const unsigned short* FPDF_WIDESTRING; // Foxit PDF SDK always use UTF-16LE encoding wide string,
70 // each character use 2 bytes (except surrogation), with low byte first.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070071
Bo Xufdc00a72014-10-28 23:03:33 -070072#ifndef _FPDF_DEF_STR_
73#define _FPDF_DEF_STR_
74/** @brief Structure for byte string.
75 *
76 * @note In SDK, a byte string commonly means a UTF-16LE format string.
77 */
78typedef struct _FPDF_BSTR
79{
Tom Sepez9857e202015-05-13 17:09:26 -070080 /**
81 * @brief String buffer.
82 */
83 char* str;
84 /**
85 * @brief Length of a string, in bytes.
86 */
87 int len;
Bo Xufdc00a72014-10-28 23:03:33 -070088} FPDF_BSTR;
89
90#endif
91
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070092// For Windows programmers: for most case it's OK to treat FPDF_WIDESTRING as Windows unicode string,
Tom Sepez9857e202015-05-13 17:09:26 -070093// however, special care needs to be taken if you expect to process Unicode larger than 0xffff.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070094// For Linux/Unix programmers: most compiler/library environment uses 4 bytes for a Unicode character,
Tom Sepez9857e202015-05-13 17:09:26 -070095// you have to convert between FPDF_WIDESTRING and system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070096
97#ifdef _WIN32_WCE
98typedef const unsigned short* FPDF_STRING;
99#else
100typedef const char* FPDF_STRING;
101#endif
102
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700103/** @brief Matrix for transformation. */
104typedef struct _FS_MATRIX_
105{
Tom Sepez9857e202015-05-13 17:09:26 -0700106 float a; /**< @brief Coefficient a.*/
107 float b; /**< @brief Coefficient b.*/
108 float c; /**< @brief Coefficient c.*/
109 float d; /**< @brief Coefficient d.*/
110 float e; /**< @brief Coefficient e.*/
111 float f; /**< @brief Coefficient f.*/
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700112} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700114/** @brief Rectangle area(float) in device or page coordination system. */
115typedef struct _FS_RECTF_
116{
Tom Sepez9857e202015-05-13 17:09:26 -0700117 /**@{*/
118 /** @brief The x-coordinate of the left-top corner. */
119 float left;
120 /** @brief The y-coordinate of the left-top corner. */
121 float top;
122 /** @brief The x-coordinate of the right-bottom corner. */
123 float right;
124 /** @brief The y-coordinate of the right-bottom corner. */
125 float bottom;
126 /**@}*/
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700127}* FS_LPRECTF, FS_RECTF;
128/** @brief Const Pointer to ::FS_RECTF structure.*/
Tom Sepez9857e202015-05-13 17:09:26 -0700129typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700130
131#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
132// On Windows system, functions are exported in a DLL
133#define DLLEXPORT __declspec( dllexport )
134#define STDCALL __stdcall
135#else
136#define DLLEXPORT
137#define STDCALL
138#endif
139
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700140// Exported Functions
141#ifdef __cplusplus
142extern "C" {
143#endif
144
145// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700146// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700147// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700148// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700149// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700150// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700151// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700152// You have to call this function before you can call any PDF processing functions.
John Abd-El-Malek207299b2014-12-15 12:13:45 -0800153DLLEXPORT void STDCALL FPDF_InitLibrary();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700154
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700155// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700156// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700157// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700158// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700159// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700160// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700161// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700162// You can call this function to release all memory blocks allocated by the library.
163// After this function called, you should not call any PDF processing functions.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700164DLLEXPORT void STDCALL FPDF_DestroyLibrary();
165
166//Policy for accessing the local machine time.
Tom Sepez9857e202015-05-13 17:09:26 -0700167#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700168
169// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700170// Set the policy for the sandbox environment.
171// Parameters:
172// policy - The specified policy for setting, for example:FPDF_POLICY_MACHINETIME_ACCESS.
173// enable - True for enable, False for disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700174// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700175// None.
176DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700177
Tom Sepez3c3201f2015-05-20 10:20:35 -0700178// Function: FPDF_LoadDocument
179// Open and load a PDF document.
180// Parameters:
181// file_path [in] - Path to the PDF file (including extension).
182// password [in] - A string used as the password for PDF file.
183// If no password needed, empty or NULL can be used.
184// Return value:
185// A handle to the loaded document, or NULL on failure.
186// Comments:
187// Loaded document can be closed by FPDF_CloseDocument().
188// If this function fails, you can use FPDF_GetLastError() to retrieve
189// the reason why it failed.
190// The application should call ::FPDF_LoadXFA function after PDF document loaded
191// to support XFA fields in fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700192DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
193 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700194
195// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700196// Open and load a PDF document from memory.
197// Parameters:
198// data_buf - Pointer to a buffer containing the PDF document.
199// size - Number of bytes in the PDF document.
200// password - A string used as the password for PDF file.
201// If no password needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700202// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700203// A handle to the loaded document. If failed, NULL is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700204// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700205// The memory buffer must remain valid when the document is open.
206// Loaded document can be closed by FPDF_CloseDocument.
207// If this function fails, you can use FPDF_GetLastError() to retrieve
208// the reason why it fails.
Bo Xufdc00a72014-10-28 23:03:33 -0700209// Notes:
Tom Sepez9857e202015-05-13 17:09:26 -0700210// The application should call ::FPDF_LoadXFA function after PDF document loaded
211// to support XFA fields in fpdfformfill.h file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700212//
Tom Sepez9857e202015-05-13 17:09:26 -0700213DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
214 int size, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700215
216// Structure for custom file access.
217typedef struct {
Tom Sepez9857e202015-05-13 17:09:26 -0700218 // File length, in bytes.
219 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700220
Tom Sepez9857e202015-05-13 17:09:26 -0700221 // A function pointer for getting a block of data from specific position.
222 // Position is specified by byte offset from beginning of the file.
223 // The position and size will never go out range of file length.
224 // It may be possible for FPDFSDK to call this function multiple times for same position.
225 // Return value: should be non-zero if successful, zero for error.
226 int (*m_GetBlock)(void* param, unsigned long position, unsigned char* pBuf, unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700227
Tom Sepez9857e202015-05-13 17:09:26 -0700228 // A custom pointer for all implementation specific data.
229 // This pointer will be used as the first parameter to m_GetBlock callback.
230 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700231} FPDF_FILEACCESS;
232
Bo Xufdc00a72014-10-28 23:03:33 -0700233/**
234 * @brief Structure for file reading or writing (I/O).
235 *
236 * @note This is a handler and should be implemented by callers.
237 */
238typedef struct _FPDF_FILEHANDLER
239{
Tom Sepez9857e202015-05-13 17:09:26 -0700240 /**
241 * @brief User-defined data.
242 * @note Callers can use this field to track controls.
243 */
244 FPDF_LPVOID clientData;
245 /**
246 * @brief Callback function to release the current file stream object.
247 *
248 * @param[in] clientData Pointer to user-defined data.
249 *
250 * @return None.
251 */
252 void (*Release)(FPDF_LPVOID clientData);
253 /**
254 * @brief Callback function to retrieve the current file stream size.
255 *
256 * @param[in] clientData Pointer to user-defined data.
257 *
258 * @return Size of file stream.
259 */
260 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
261 /**
262 * @brief Callback function to read data from the current file stream.
263 *
264 * @param[in] clientData Pointer to user-defined data.
265 * @param[in] offset Offset position starts from the beginning of file stream. This parameter indicates reading position.
266 * @param[in] buffer Memory buffer to store data which are read from file stream. This parameter should not be <b>NULL</b>.
267 * @param[in] size Size of data which should be read from file stream, in bytes. The buffer indicated by the parameter <i>buffer</i> should be enough to store specified data.
268 *
269 * @return 0 for success, other value for failure.
270 */
271 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size);
272 /**
273 * @brief Callback function to write data into the current file stream.
274 *
275 * @param[in] clientData Pointer to user-defined data.
276 * @param[in] offset Offset position starts from the beginning of file stream. This parameter indicates writing position.
277 * @param[in] buffer Memory buffer contains data which is written into file stream. This parameter should not be <b>NULL</b>.
278 * @param[in] size Size of data which should be written into file stream, in bytes.
279 *
280 * @return 0 for success, other value for failure.
281 */
282 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size);
283 /**
284 * @brief Callback function to flush all internal accessing buffers.
285 *
286 * @param[in] clientData Pointer to user-defined data.
287 *
288 * @return 0 for success, other value for failure.
289 */
290 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
291 /**
292 * @brief Callback function to change file size.
293 *
294 * @details This function is called under writing mode usually. Implementer can determine whether to realize it based on application requests.
295 *
296 * @param[in] clientData Pointer to user-defined data.
297 * @param[in] size New size of file stream, in bytes.
298 *
299 * @return 0 for success, other value for failure.
300 */
301 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700302
303} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
304
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700305// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700306// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700307// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700308// pFileAccess - A structure for access the file.
309// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700310// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700311// A handle to the loaded document. If failed, NULL is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700312// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700313// The application should maintain the file resources being valid until the PDF document close.
314// Loaded document can be closed by FPDF_CloseDocument.
Bo Xufdc00a72014-10-28 23:03:33 -0700315// Notes:
Tom Sepez9857e202015-05-13 17:09:26 -0700316// The application should call ::FPDF_LoadXFA function after PDF document loaded
317// to support XFA fields in fpdfformfill.h file.
Bo Xufdc00a72014-10-28 23:03:33 -0700318//
Tom Sepez9857e202015-05-13 17:09:26 -0700319DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess,
320 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700321
322// Function: FPDF_GetFileVersion
Tom Sepez9857e202015-05-13 17:09:26 -0700323// Get the file version of the specific PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700324// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700325// doc - Handle to document.
326// fileVersion - The PDF file version. File version: 14 for 1.4, 15 for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700327// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700328// TRUE if this call succeed, If failed, FALSE is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700329// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700330// If the document is created by function ::FPDF_CreateNewDocument, then this function would always fail.
Bo Xufdc00a72014-10-28 23:03:33 -0700331//
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700332DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVersion);
333
Tom Sepez9857e202015-05-13 17:09:26 -0700334#define FPDF_ERR_SUCCESS 0 // No error.
335#define FPDF_ERR_UNKNOWN 1 // Unknown error.
336#define FPDF_ERR_FILE 2 // File not found or could not be opened.
337#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
338#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
339#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
340#define FPDF_ERR_PAGE 6 // Page not found or content error.
341#define FPDF_ERR_XFALOAD 7 // Load XFA error.
342#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700343
344// Function: FPDF_GetLastError
Tom Sepez9857e202015-05-13 17:09:26 -0700345// Get last error code when an SDK function failed.
346// Parameters:
347// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700348// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700349// A 32-bit integer indicating error codes (defined above).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700350// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700351// If the previous SDK call succeeded, the return value of this function
352// is not defined.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700353//
Tom Sepez9857e202015-05-13 17:09:26 -0700354DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700355
356// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700357// Get file permission flags of the document.
358// Parameters:
359// document - Handle to document. Returned by FPDF_LoadDocument function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700360// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700361// A 32-bit integer indicating permission flags. Please refer to PDF Reference for
362// detailed description. If the document is not protected, 0xffffffff will be returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700363//
Tom Sepez9857e202015-05-13 17:09:26 -0700364DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700365
Bo Xuc5cab022014-09-19 19:16:31 -0700366// Function: FPDF_GetSecurityHandlerRevision
Tom Sepez9857e202015-05-13 17:09:26 -0700367// Get the revision for security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700368// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700369// document - Handle to document. Returned by FPDF_LoadDocument function.
Bo Xuc5cab022014-09-19 19:16:31 -0700370// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700371// The security handler revision number. Please refer to PDF Reference for
372// detailed description. If the document is not protected, -1 will be returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700373//
374DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
375
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700376// Function: FPDF_GetPageCount
Tom Sepez9857e202015-05-13 17:09:26 -0700377// Get total number of pages in a document.
378// Parameters:
379// document - Handle to document. Returned by FPDF_LoadDocument function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700380// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700381// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700382//
383DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
384
385// Function: FPDF_LoadPage
Tom Sepez9857e202015-05-13 17:09:26 -0700386// Load a page inside a document.
387// Parameters:
388// document - Handle to document. Returned by FPDF_LoadDocument function.
389// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700390// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700391// A handle to the loaded page. If failed, NULL is returned.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700392// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700393// Loaded page can be rendered to devices using FPDF_RenderPage function.
394// Loaded page can be closed by FPDF_ClosePage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700395//
Tom Sepez9857e202015-05-13 17:09:26 -0700396DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700397
398// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700399// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700400// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700401// page - Handle to the page. Returned by FPDF_LoadPage function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700402// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700403// Page width (excluding non-displayable area) measured in points.
404// One point is 1/72 inch (around 0.3528 mm).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700405//
406DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
407
408// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700409// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700410// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700411// page - Handle to the page. Returned by FPDF_LoadPage function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700412// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700413// Page height (excluding non-displayable area) measured in points.
414// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700415//
416DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
417
418// Function: FPDF_GetPageSizeByIndex
Tom Sepez9857e202015-05-13 17:09:26 -0700419// Get the size of a page by index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700420// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700421// document - Handle to document. Returned by FPDF_LoadDocument function.
422// page_index - Page index, zero for the first page.
423// width - Pointer to a double value receiving the page width (in points).
424// height - Pointer to a double value receiving the page height (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700425// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700426// Non-zero for success. 0 for error (document or page not found).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700427//
428DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, double* width, double* height);
429
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700430// Page rendering flags. They can be combined with bit OR.
Tom Sepez9857e202015-05-13 17:09:26 -0700431#define FPDF_ANNOT 0x01 // Set if annotations are to be rendered.
432#define FPDF_LCD_TEXT 0x02 // Set if using text rendering optimized for LCD display.
433#define FPDF_NO_NATIVETEXT 0x04 // Don't use the native text output available on some platforms
434#define FPDF_GRAYSCALE 0x08 // Grayscale output.
435#define FPDF_DEBUG_INFO 0x80 // Set if you want to get some debug info.
436 // Please discuss with Foxit first if you need to collect debug info.
437#define FPDF_NO_CATCH 0x100 // Set if you don't want to catch exception.
438#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 // Limit image cache size.
439#define FPDF_RENDER_FORCEHALFTONE 0x400 // Always use halftone for image stretching.
440#define FPDF_PRINTING 0x800 // Render for printing.
441#define FPDF_REVERSE_BYTE_ORDER 0x10 //set whether render in a reverse Byte order, this flag only
442 //enable when render to a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700443#ifdef _WIN32
444// Function: FPDF_RenderPage
Tom Sepez9857e202015-05-13 17:09:26 -0700445// Render contents in a page to a device (screen, bitmap, or printer).
446// This function is only supported on Windows system.
447// Parameters:
448// dc - Handle to device context.
449// page - Handle to the page. Returned by FPDF_LoadPage function.
450// start_x - Left pixel position of the display area in the device coordinate.
451// start_y - Top pixel position of the display area in the device coordinate.
452// size_x - Horizontal size (in pixels) for displaying the page.
453// size_y - Vertical size (in pixels) for displaying the page.
454// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
455// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
456// flags - 0 for normal display, or combination of flags defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700457// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700458// None.
Bo Xufdc00a72014-10-28 23:03:33 -0700459// Notes:
Tom Sepez9857e202015-05-13 17:09:26 -0700460// The method can not support to render the page for the document consists of dynamic XFA fields.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700461//
462DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
Tom Sepez9857e202015-05-13 17:09:26 -0700463 int rotate, int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700464#endif
465
466// Function: FPDF_RenderPageBitmap
Tom Sepez9857e202015-05-13 17:09:26 -0700467// Render contents in a page to a device independent bitmap
468// Parameters:
469// bitmap - Handle to the device independent bitmap (as the output buffer).
470// Bitmap handle can be created by FPDFBitmap_Create function.
471// page - Handle to the page. Returned by FPDF_LoadPage function.
472// start_x - Left pixel position of the display area in the bitmap coordinate.
473// start_y - Top pixel position of the display area in the bitmap coordinate.
474// size_x - Horizontal size (in pixels) for displaying the page.
475// size_y - Vertical size (in pixels) for displaying the page.
476// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
477// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
478// flags - 0 for normal display, or combination of flags defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700479// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700480// None.
Bo Xufdc00a72014-10-28 23:03:33 -0700481// Notes:
Tom Sepez9857e202015-05-13 17:09:26 -0700482// The method can not support to render the page for the document consists of dynamic XFA fields.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700483//
Tom Sepez9857e202015-05-13 17:09:26 -0700484DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y,
485 int size_x, int size_y, int rotate, int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700486
487// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700488// Close a loaded PDF page.
489// Parameters:
490// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700491// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700492// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700493//
494DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
495
496// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700497// Close a loaded PDF document.
498// Parameters:
499// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700500// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700501// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700502//
503DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
504
505// Function: FPDF_DeviceToPage
Tom Sepez9857e202015-05-13 17:09:26 -0700506// Convert the screen coordinate of a point to page coordinate.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700507// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700508// page - Handle to the page. Returned by FPDF_LoadPage function.
509// start_x - Left pixel position of the display area in the device coordinate.
510// start_y - Top pixel position of the display area in the device coordinate.
511// size_x - Horizontal size (in pixels) for displaying the page.
512// size_y - Vertical size (in pixels) for displaying the page.
513// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
514// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
515// device_x - X value in device coordinate, for the point to be converted.
516// device_y - Y value in device coordinate, for the point to be converted.
517// page_x - A Pointer to a double receiving the converted X value in page coordinate.
518// page_y - A Pointer to a double receiving the converted Y value in page coordinate.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700519// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700520// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700521// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700522// The page coordinate system has its origin at left-bottom corner of the page, with X axis goes along
523// the bottom side to the right, and Y axis goes along the left side upward. NOTE: this coordinate system
524// can be altered when you zoom, scroll, or rotate a page, however, a point on the page should always have
525// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700526//
Tom Sepez9857e202015-05-13 17:09:26 -0700527// The device coordinate system is device dependent. For screen device, its origin is at left-top
528// corner of the window. However this origin can be altered by Windows coordinate transformation
529// utilities. You must make sure the start_x, start_y, size_x, size_y and rotate parameters have exactly
530// same values as you used in FPDF_RenderPage() function call.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700531//
532DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
Tom Sepez9857e202015-05-13 17:09:26 -0700533 int rotate, int device_x, int device_y, double* page_x, double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700534
535// Function: FPDF_PageToDevice
Tom Sepez9857e202015-05-13 17:09:26 -0700536// Convert the page coordinate of a point to screen coordinate.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700537// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700538// page - Handle to the page. Returned by FPDF_LoadPage function.
539// start_x - Left pixel position of the display area in the device coordinate.
540// start_y - Top pixel position of the display area in the device coordinate.
541// size_x - Horizontal size (in pixels) for displaying the page.
542// size_y - Vertical size (in pixels) for displaying the page.
543// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
544// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
545// page_x - X value in page coordinate, for the point to be converted.
546// page_y - Y value in page coordinate, for the point to be converted.
547// device_x - A pointer to an integer receiving the result X value in device coordinate.
548// device_y - A pointer to an integer receiving the result Y value in device coordinate.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700549// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700550// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700551// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700552// See comments of FPDF_DeviceToPage() function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700553//
554DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
Tom Sepez9857e202015-05-13 17:09:26 -0700555 int rotate, double page_x, double page_y, int* device_x, int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700556
557// Function: FPDFBitmap_Create
Tom Sepez9857e202015-05-13 17:09:26 -0700558// Create a Foxit Device Independent Bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700559// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700560// width - Number of pixels in a horizontal line of the bitmap. Must be greater than 0.
561// height - Number of pixels in a vertical line of the bitmap. Must be greater than 0.
562// alpha - A flag indicating whether alpha channel is used. Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700563// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700564// The created bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700565// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700566// An FXDIB always use 4 byte per pixel. The first byte of a pixel is always double word aligned.
567// Each pixel contains red (R), green (G), blue (B) and optionally alpha (A) values.
568// The byte order is BGRx (the last byte unused if no alpha channel) or BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700569//
Tom Sepez9857e202015-05-13 17:09:26 -0700570// The pixels in a horizontal line (also called scan line) are stored side by side, with left most
571// pixel stored first (with lower memory address). Each scan line uses width*4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700572//
Tom Sepez9857e202015-05-13 17:09:26 -0700573// Scan lines are stored one after another, with top most scan line stored first. There is no gap
574// between adjacent scan lines.
575//
576// This function allocates enough memory for holding all pixels in the bitmap, but it doesn't
577// initialize the buffer. Applications can use FPDFBitmap_FillRect to fill the bitmap using any color.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700578DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha);
579
580// More DIB formats
Tom Sepez9857e202015-05-13 17:09:26 -0700581#define FPDFBitmap_Gray 1 // Gray scale bitmap, one byte per pixel.
582#define FPDFBitmap_BGR 2 // 3 bytes per pixel, byte order: blue, green, red.
583#define FPDFBitmap_BGRx 3 // 4 bytes per pixel, byte order: blue, green, red, unused.
584#define FPDFBitmap_BGRA 4 // 4 bytes per pixel, byte order: blue, green, red, alpha.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700585
586// Function: FPDFBitmap_CreateEx
Tom Sepez9857e202015-05-13 17:09:26 -0700587// Create a Foxit Device Independent Bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700588// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700589// width - Number of pixels in a horizontal line of the bitmap. Must be greater than 0.
590// height - Number of pixels in a vertical line of the bitmap. Must be greater than 0.
591// format - A number indicating for bitmap format, as defined above.
592// first_scan - A pointer to the first byte of first scan line, for external buffer
593// only. If this parameter is NULL, then the SDK will create its own buffer.
594// stride - Number of bytes for each scan line, for external buffer only..
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700595// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700596// The created bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700597// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700598// Similar to FPDFBitmap_Create function, with more formats and external buffer supported.
599// Bitmap created by this function can be used in any place that a FPDF_BITMAP handle is
600// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700601//
Tom Sepez9857e202015-05-13 17:09:26 -0700602// If external scanline buffer is used, then the application should destroy the buffer
603// by itself. FPDFBitmap_Destroy function will not destroy the buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700604//
605DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, int height, int format, void* first_scan, int stride);
606
607// Function: FPDFBitmap_FillRect
Tom Sepez9857e202015-05-13 17:09:26 -0700608// Fill a rectangle area in an FXDIB.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700609// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700610// bitmap - The handle to the bitmap. Returned by FPDFBitmap_Create function.
611// left - The left side position. Starting from 0 at the left-most pixel.
612// top - The top side position. Starting from 0 at the top-most scan line.
613// width - Number of pixels to be filled in each scan line.
614// height - Number of scan lines to be filled.
615// color - A 32-bit value specifing the color, in 8888 ARGB format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700616// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700617// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700618// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700619// This function set the color and (optionally) alpha value in specified region of the bitmap.
620// NOTE: If alpha channel is used, this function does NOT composite the background with the source color,
621// instead the background will be replaced by the source color and alpha.
622// If alpha channel is not used, the "alpha" parameter is ignored.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700623//
Lei Zhang532a6a72014-07-09 11:47:15 -0700624DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top, int width, int height, FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700625
626// Function: FPDFBitmap_GetBuffer
Tom Sepez9857e202015-05-13 17:09:26 -0700627// Get data buffer of an FXDIB
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700628// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700629// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700630// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700631// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700632// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700633// The stride may be more than width * number of bytes per pixel
634// Applications can use this function to get the bitmap buffer pointer, then manipulate any color
635// and/or alpha values for any pixels in the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700636DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
637
638// Function: FPDFBitmap_GetWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700639// Get width of an FXDIB.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700640// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700641// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700642// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700643// The number of pixels in a horizontal line of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700644DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
645
646// Function: FPDFBitmap_GetHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700647// Get height of an FXDIB.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700648// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700649// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700650// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700651// The number of pixels in a vertical line of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700652DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
653
654// Function: FPDFBitmap_GetStride
Tom Sepez9857e202015-05-13 17:09:26 -0700655// Get number of bytes for each scan line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700656// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700657// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700658// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700659// The number of bytes for each scan line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700660// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700661// The stride may be more than width * number of bytes per pixel
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700662DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
663
664// Function: FPDFBitmap_Destroy
Tom Sepez9857e202015-05-13 17:09:26 -0700665// Destroy an FXDIB and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700666// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700667// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700668// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700669// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700670// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700671// This function will not destroy any external buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700672//
673DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
674
675// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700676// Whether the PDF document prefers to be scaled or not.
677// Parameters:
678// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700679// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700680// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700681//
682DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
683
Bo Xu9114e832014-07-14 13:22:47 -0700684// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700685// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700686// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700687// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700688// Return value:
689// The number of copies to be printed.
690//
691DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
692
693// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700694// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700695// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700696// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700697// Return value:
698// The print page range to be used for printing.
699//
700DLLEXPORT FPDF_PAGERANGE STDCALL FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
701
702// Function: FPDF_VIEWERREF_GetDuplex
Tom Sepez9857e202015-05-13 17:09:26 -0700703// Returns the paper handling option to be used when printing from print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700704// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700705// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700706// Return value:
707// The paper handling option to be used when printing.
708//
709DLLEXPORT FPDF_DUPLEXTYPE STDCALL FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
710
Bo Xu4d62b6b2015-01-10 22:52:59 -0800711// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700712// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800713// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700714// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800715// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700716// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800717DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
718
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700719// Function: FPDF_GetNamedDestByName
Tom Sepez9857e202015-05-13 17:09:26 -0700720// get a special dest handle by the index.
721// Parameters:
722// document - Handle to the loaded document.
723// name - The name of a special named dest.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700724// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700725// The handle of the dest.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700726//
Tom Sepezcf22eb82015-05-12 17:28:08 -0700727DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700728
Bo Xu4d62b6b2015-01-10 22:52:59 -0800729// Function: FPDF_GetNamedDest
Tom Sepez9857e202015-05-13 17:09:26 -0700730// Get the specified named destinations of the PDF document by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800731// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700732// document - Handle to a document
733// index - The index of named destination.
734// buffer - The buffer to obtain destination name, used as wchar_t*.
735// buflen [in/out] - Size of the buffer in bytes on input, length of the result in bytes on output or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800736// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700737// The destination handle of a named destination, or NULL if no named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800738// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700739// Call this function twice to get the name of the named destination:
740// 1) First time pass in |buffer| as NULL and get buflen.
741// 2) Second time pass in allocated |buffer| and buflen to retrieve |buffer|, which should be used as wchar_t*.
742// If buflen is not sufficiently large, it will be set to -1 upon return.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800743//
Tom Sepezcf22eb82015-05-12 17:28:08 -0700744DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -0800745
Tom Sepez9857e202015-05-13 17:09:26 -0700746// Function: FPDF_BStr_Init
747// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700748DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
749
Tom Sepez9857e202015-05-13 17:09:26 -0700750// Function: FPDF_BStr_Set
751// Helper function to set string data.
Bo Xufdc00a72014-10-28 23:03:33 -0700752DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, FPDF_LPCSTR bstr, int length);
753
Tom Sepez9857e202015-05-13 17:09:26 -0700754// Function: FPDF_BStr_Clear
755// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700756DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
757
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700758#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -0700759}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700760#endif
761
Tom Sepez9857e202015-05-13 17:09:26 -0700762#endif // PUBLIC_FPDFVIEW_H_