blob: cbb577b2fd476c93b05dc9960112722de2dfcc14 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Tom Sepez9857e202015-05-13 17:09:26 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez1ed8a212015-05-11 15:25:39 -07007// NOTE: External docs refer to this file as "fpdfview.h", so do not rename
Dan Sinclair50cce602016-02-24 09:51:16 -05008// despite lack of consistency with other public files.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Tom Sepez9857e202015-05-13 17:09:26 -070010#ifndef PUBLIC_FPDFVIEW_H_
11#define PUBLIC_FPDFVIEW_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070012
13#if defined(_WIN32) && !defined(__WINDOWS__)
14#include <windows.h>
15#endif
16
Tom Sepezc46d0002015-11-30 15:46:36 -080017#ifdef PDF_ENABLE_XFA
Dan Sinclair3ebd1212016-03-09 09:59:23 -050018// PDF_USE_XFA is set in confirmation that this version of PDFium can support
19// XFA forms as requested by the PDF_ENABLE_XFA setting.
Bo Xubb5ef882014-11-06 16:13:33 -080020#define PDF_USE_XFA
Tom Sepezc46d0002015-11-30 15:46:36 -080021#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022
23// PDF types
Tom Sepez9857e202015-05-13 17:09:26 -070024typedef void* FPDF_ACTION;
Tom Sepezc46d0002015-11-30 15:46:36 -080025typedef void* FPDF_BITMAP;
26typedef void* FPDF_BOOKMARK;
27typedef void* FPDF_CLIPPATH;
28typedef void* FPDF_DEST;
29typedef void* FPDF_DOCSCHHANDLE;
30typedef void* FPDF_DOCUMENT;
31typedef void* FPDF_FONT;
32typedef void* FPDF_HMODULE;
Tom Sepez9857e202015-05-13 17:09:26 -070033typedef void* FPDF_LINK;
Tom Sepezc46d0002015-11-30 15:46:36 -080034typedef void* FPDF_MODULEMGR;
35typedef void* FPDF_PAGE;
36typedef void* FPDF_PAGELINK;
37typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
Tom Sepez9857e202015-05-13 17:09:26 -070038typedef void* FPDF_PAGERANGE;
Tom Sepezc46d0002015-11-30 15:46:36 -080039typedef void* FPDF_PATH;
Cary Clark399be5b2016-03-14 16:51:29 -040040typedef void* FPDF_RECORDER;
Tom Sepezc46d0002015-11-30 15:46:36 -080041typedef void* FPDF_SCHHANDLE;
42typedef void* FPDF_TEXTPAGE;
43
44#ifdef PDF_ENABLE_XFA
45typedef void* FPDF_STRINGHANDLE;
46typedef void* FPDF_WIDGET;
47#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070048
49// Basic data types
Tom Sepez9857e202015-05-13 17:09:26 -070050typedef int FPDF_BOOL;
51typedef int FPDF_ERROR;
52typedef unsigned long FPDF_DWORD;
53typedef float FS_FLOAT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070054
Tom Sepezc46d0002015-11-30 15:46:36 -080055#ifdef PDF_ENABLE_XFA
56typedef void* FPDF_LPVOID;
57typedef void const* FPDF_LPCVOID;
58typedef char const* FPDF_LPCSTR;
59typedef int FPDF_RESULT;
60#endif
61
Bo Xu9114e832014-07-14 13:22:47 -070062// Duplex types
63typedef enum _FPDF_DUPLEXTYPE_ {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070064 DuplexUndefined = 0,
65 Simplex,
66 DuplexFlipShortEdge,
67 DuplexFlipLongEdge
Bo Xu9114e832014-07-14 13:22:47 -070068} FPDF_DUPLEXTYPE;
69
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070070// String types
Tom Sepez9857e202015-05-13 17:09:26 -070071typedef unsigned short FPDF_WCHAR;
72typedef unsigned char const* FPDF_LPCBYTE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070073
Nico Weber9d8ec5a2015-08-04 13:00:21 -070074// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
75// encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070076typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070077
Dan Sinclair49f88b72015-10-20 15:18:51 -040078// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
79// bytes (except surrogation), with the low byte first.
80typedef const unsigned short* FPDF_WIDESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070081
Tom Sepezc46d0002015-11-30 15:46:36 -080082#ifdef PDF_ENABLE_XFA
Dan Sinclair49f88b72015-10-20 15:18:51 -040083// Structure for a byte string.
84// Note, a byte string commonly means a UTF-16LE formated string.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070085typedef struct _FPDF_BSTR {
Dan Sinclair49f88b72015-10-20 15:18:51 -040086 // String buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070087 char* str;
Dan Sinclair49f88b72015-10-20 15:18:51 -040088 // Length of the string, in bytes.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070089 int len;
Bo Xufdc00a72014-10-28 23:03:33 -070090} FPDF_BSTR;
Tom Sepezc46d0002015-11-30 15:46:36 -080091#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -070092
Dan Sinclair49f88b72015-10-20 15:18:51 -040093// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
94// Windows unicode string, however, special care needs to be taken if you
95// expect to process Unicode larger than 0xffff.
96//
97// For Linux/Unix programmers: most compiler/library environments use 4 bytes
98// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
99// system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700100typedef const char* FPDF_STRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700101
Dan Sinclair49f88b72015-10-20 15:18:51 -0400102// Matrix for transformation.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700103typedef struct _FS_MATRIX_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400104 float a;
105 float b;
106 float c;
107 float d;
108 float e;
109 float f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700110} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700111
Dan Sinclair49f88b72015-10-20 15:18:51 -0400112// Rectangle area(float) in device or page coordinate system.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700113typedef struct _FS_RECTF_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400114 // The x-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700115 float left;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400116 // The y-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700117 float top;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400118 // The x-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700119 float right;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400120 // The y-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121 float bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700122} * FS_LPRECTF, FS_RECTF;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400123
124// Const Pointer to FS_RECTF structure.
Tom Sepez9857e202015-05-13 17:09:26 -0700125typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700126
127#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
128// On Windows system, functions are exported in a DLL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700129#define DLLEXPORT __declspec(dllexport)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700130#define STDCALL __stdcall
131#else
132#define DLLEXPORT
133#define STDCALL
134#endif
135
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700136// Exported Functions
137#ifdef __cplusplus
138extern "C" {
139#endif
140
141// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700142// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700143// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700144// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700145// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700146// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700147// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700148// Convenience function to call FPDF_InitLibraryWithConfig() for
149// backwards comatibility purposes.
150DLLEXPORT void STDCALL FPDF_InitLibrary();
151
Dan Sinclair49f88b72015-10-20 15:18:51 -0400152// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700153typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700154 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700155 int version;
156
157 // Array of paths to scan in place of the defaults when using built-in
158 // FXGE font loading code. The array is terminated by a NULL pointer.
159 // The Array may be NULL itself to use the default paths. May be ignored
160 // entirely depending upon the platform.
161 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700162
163 // Version 2.
164
165 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
166 void* m_pIsolate;
167
168 // The embedder data slot to use in the v8::Isolate to store PDFium's
169 // per-isolate data. The value needs to be between 0 and
170 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
171 // for most embedders.
172 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700173} FPDF_LIBRARY_CONFIG;
174
175// Function: FPDF_InitLibraryWithConfig
176// Initialize the FPDFSDK library
177// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400178// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700179// Return value:
180// None.
181// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700182// You have to call this function before you can call any PDF
183// processing functions.
Tom Sepez326a2a72015-11-20 10:47:32 -0800184DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
185 const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700186
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700187// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700188// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700190// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700191// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700192// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700193// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700194// You can call this function to release all memory blocks allocated by
195// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400196// After this function is called, you should not call any PDF
197// processing functions.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700198DLLEXPORT void STDCALL FPDF_DestroyLibrary();
199
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700200// Policy for accessing the local machine time.
201#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700202
203// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700204// Set the policy for the sandbox environment.
205// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400206// policy - The specified policy for setting, for example:
207// FPDF_POLICY_MACHINETIME_ACCESS.
208// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700209// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700210// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700211DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
212 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700213
thestigfdb35ff2016-07-18 13:45:44 -0700214#if defined(_WIN32) && defined(PDFIUM_PRINT_TEXT_WITH_GDI)
215// Pointer to a helper function to make |font| with |text| of |text_length|
216// accessible when printing text with GDI. This is useful in sandboxed
217// environments where PDFium's access to GDI may be restricted.
218typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
219 const wchar_t* text,
220 size_t text_length);
221
222// Function: FPDF_SetTypefaceAccessibleFunc
223// Set the function pointer that makes GDI fonts available in sandboxed
224// environments. Experimental API.
225// Parameters:
226// func - A function pointer. See description above.
227// Return value:
228// None.
229DLLEXPORT void STDCALL
230FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func);
231
232// Function: FPDF_SetPrintTextWithGDI
233// Set whether to use GDI to draw fonts when printing on Windows.
234// Experimental API.
235// Parameters:
236// use_gdi - Set to true to enable printing text with GDI.
237// Return value:
238// None.
239DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi);
240#endif
241
Tom Sepez3c3201f2015-05-20 10:20:35 -0700242// Function: FPDF_LoadDocument
243// Open and load a PDF document.
244// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400245// file_path - Path to the PDF file (including extension).
246// password - A string used as the password for the PDF file.
247// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700248// Return value:
249// A handle to the loaded document, or NULL on failure.
250// Comments:
251// Loaded document can be closed by FPDF_CloseDocument().
252// If this function fails, you can use FPDF_GetLastError() to retrieve
253// the reason why it failed.
Tom Sepez9857e202015-05-13 17:09:26 -0700254DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700255 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700256
257// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700258// Open and load a PDF document from memory.
259// Parameters:
260// data_buf - Pointer to a buffer containing the PDF document.
261// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400262// password - A string used as the password for the PDF file.
263// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700264// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400265// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700266// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700267// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400268// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700269// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400270// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700271// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800272// If PDFium is built with the XFA module, the application should call
273// FPDF_LoadXFA() function after the PDF document loaded to support XFA
274// fields defined in the fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700275DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700276 int size,
277 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700278
279// Structure for custom file access.
280typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700281 // File length, in bytes.
282 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700283
Dan Sinclair49f88b72015-10-20 15:18:51 -0400284 // A function pointer for getting a block of data from a specific position.
285 // Position is specified by byte offset from the beginning of the file.
286 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700287 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400288 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700289 // Return value: should be non-zero if successful, zero for error.
290 int (*m_GetBlock)(void* param,
291 unsigned long position,
292 unsigned char* pBuf,
293 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700294
Dan Sinclair49f88b72015-10-20 15:18:51 -0400295 // A custom pointer for all implementation specific data. This pointer will
296 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700297 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700298} FPDF_FILEACCESS;
299
Tom Sepezc46d0002015-11-30 15:46:36 -0800300#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700301/**
302 * @brief Structure for file reading or writing (I/O).
303 *
304 * @note This is a handler and should be implemented by callers.
305 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700306typedef struct _FPDF_FILEHANDLER {
307 /**
308 * @brief User-defined data.
309 * @note Callers can use this field to track controls.
310 */
311 FPDF_LPVOID clientData;
312 /**
313 * @brief Callback function to release the current file stream object.
314 *
315 * @param[in] clientData Pointer to user-defined data.
316 *
317 * @return None.
318 */
319 void (*Release)(FPDF_LPVOID clientData);
320 /**
321 * @brief Callback function to retrieve the current file stream size.
322 *
323 * @param[in] clientData Pointer to user-defined data.
324 *
325 * @return Size of file stream.
326 */
327 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
328 /**
329 * @brief Callback function to read data from the current file stream.
330 *
331 * @param[in] clientData Pointer to user-defined data.
332 * @param[in] offset Offset position starts from the beginning of file
333 * stream. This parameter indicates reading position.
334 * @param[in] buffer Memory buffer to store data which are read from
335 * file stream. This parameter should not be <b>NULL</b>.
336 * @param[in] size Size of data which should be read from file
337 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
338 * should be enough to store specified data.
339 *
340 * @return 0 for success, other value for failure.
341 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500342 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
343 FPDF_DWORD offset,
344 FPDF_LPVOID buffer,
345 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700346 /**
347 * @brief Callback function to write data into the current file stream.
348 *
349 * @param[in] clientData Pointer to user-defined data.
350 * @param[in] offset Offset position starts from the beginning of file
351 * stream. This parameter indicates writing position.
352 * @param[in] buffer Memory buffer contains data which is written into
353 * file stream. This parameter should not be <b>NULL</b>.
354 * @param[in] size Size of data which should be written into file
355 * stream, in bytes.
356 *
357 * @return 0 for success, other value for failure.
358 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500359 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
360 FPDF_DWORD offset,
361 FPDF_LPCVOID buffer,
362 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700363 /**
364 * @brief Callback function to flush all internal accessing buffers.
365 *
366 * @param[in] clientData Pointer to user-defined data.
367 *
368 * @return 0 for success, other value for failure.
369 */
370 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
371 /**
372 * @brief Callback function to change file size.
373 *
374 * @details This function is called under writing mode usually. Implementer
375 * can determine whether to realize it based on application requests.
376 *
377 * @param[in] clientData Pointer to user-defined data.
378 * @param[in] size New size of file stream, in bytes.
379 *
380 * @return 0 for success, other value for failure.
381 */
382 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700383} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
384
Tom Sepezc46d0002015-11-30 15:46:36 -0800385#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700386// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700387// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700388// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400389// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700390// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700391// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400392// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700393// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400394// The application must keep the file resources valid until the PDF
395// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700396//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400397// The loaded document can be closed with FPDF_CloseDocument.
398// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800399// If PDFium is built with the XFA module, the application should call
400// FPDF_LoadXFA() function after the PDF document loaded to support XFA
401// fields defined in the fpdfformfill.h file.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700402DLLEXPORT FPDF_DOCUMENT STDCALL
403FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700404
405// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400406// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700407// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400408// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700409// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400410// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700411// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400412// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700413// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400414// If the document was created by FPDF_CreateNewDocument,
415// then this function will always fail.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700416DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
417 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700418
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700419#define FPDF_ERR_SUCCESS 0 // No error.
420#define FPDF_ERR_UNKNOWN 1 // Unknown error.
421#define FPDF_ERR_FILE 2 // File not found or could not be opened.
422#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
423#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
424#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
425#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800426#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700427#define FPDF_ERR_XFALOAD 7 // Load XFA error.
428#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800429#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700430
431// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400432// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700433// Parameters:
434// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700435// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400436// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700437// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700438// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400439// function is not defined.
Tom Sepez9857e202015-05-13 17:09:26 -0700440DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700441
442// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700443// Get file permission flags of the document.
444// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400445// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700446// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400447// A 32-bit integer indicating permission flags. Please refer to the
448// PDF Reference for detailed descriptions. If the document is not
449// protected, 0xffffffff will be returned.
Tom Sepez9857e202015-05-13 17:09:26 -0700450DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700451
Bo Xuc5cab022014-09-19 19:16:31 -0700452// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400453// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700454// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400455// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700456// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400457// The security handler revision number. Please refer to the PDF
458// Reference for a detailed description. If the document is not
459// protected, -1 will be returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700460DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
461
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700462// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400463// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700464// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400465// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700466// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700467// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700468DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
469
470// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400471// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700472// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700473// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700474// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700475// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400476// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700477// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400478// The loaded page can be rendered to devices using FPDF_RenderPage.
479// The loaded page can be closed using FPDF_ClosePage.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700480DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
481 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700482
483// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700484// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700485// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400486// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700487// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700488// Page width (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 -0700490DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
491
492// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700493// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700494// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400495// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700496// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700497// Page height (excluding non-displayable area) measured in points.
498// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700499DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
500
501// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400502// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700503// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400504// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700505// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400506// width - Pointer to a double to receive the page width
507// (in points).
508// height - Pointer to a double to receive the page height
509// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700510// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700511// Non-zero for success. 0 for error (document or page not found).
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700512DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
513 int page_index,
514 double* width,
515 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700516
Dan Sinclair49f88b72015-10-20 15:18:51 -0400517// Page rendering flags. They can be combined with bit-wise OR.
518//
519// Set if annotations are to be rendered.
520#define FPDF_ANNOT 0x01
521// Set if using text rendering optimized for LCD display.
522#define FPDF_LCD_TEXT 0x02
523// Don't use the native text output available on some platforms
524#define FPDF_NO_NATIVETEXT 0x04
525// Grayscale output.
526#define FPDF_GRAYSCALE 0x08
527// Set if you want to get some debug info.
528#define FPDF_DEBUG_INFO 0x80
529// Set if you don't want to catch exceptions.
530#define FPDF_NO_CATCH 0x100
531// Limit image cache size.
532#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
533// Always use halftone for image stretching.
534#define FPDF_RENDER_FORCEHALFTONE 0x400
535// Render for printing.
536#define FPDF_PRINTING 0x800
537// Set to disable anti-aliasing on text.
538#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
539// Set to disable anti-aliasing on images.
540#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
541// Set to disable anti-aliasing on paths.
542#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
543// Set whether to render in a reverse Byte order, this flag is only used when
544// rendering to a bitmap.
545#define FPDF_REVERSE_BYTE_ORDER 0x10
546
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700547#ifdef _WIN32
548// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400549// Render contents of a page to a device (screen, bitmap, or printer).
550// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700551// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400552// dc - Handle to the device context.
553// page - Handle to the page. Returned by FPDF_LoadPage.
554// start_x - Left pixel position of the display area in
555// device coordinates.
556// start_y - Top pixel position of the display area in device
557// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700558// size_x - Horizontal size (in pixels) for displaying the page.
559// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400560// rotate - Page orientation:
561// 0 (normal)
562// 1 (rotated 90 degrees clockwise)
563// 2 (rotated 180 degrees)
564// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700565// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400566// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700567// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700568// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700569DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
570 FPDF_PAGE page,
571 int start_x,
572 int start_y,
573 int size_x,
574 int size_y,
575 int rotate,
576 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700577#endif
578
579// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400580// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700581// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700582// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400583// output buffer). The bitmap handle can be created
584// by FPDFBitmap_Create.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700585// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400586// start_x - Left pixel position of the display area in
587// bitmap coordinates.
588// start_y - Top pixel position of the display area in bitmap
589// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700590// size_x - Horizontal size (in pixels) for displaying the page.
591// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400592// rotate - Page orientation:
593// 0 (normal)
594// 1 (rotated 90 degrees clockwise)
595// 2 (rotated 180 degrees)
596// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700597// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400598// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700599// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700600// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700601DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
602 FPDF_PAGE page,
603 int start_x,
604 int start_y,
605 int size_x,
606 int size_y,
607 int rotate,
608 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700609
Cary Clark399be5b2016-03-14 16:51:29 -0400610#ifdef _SKIA_SUPPORT_
611DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
612 int size_x,
613 int size_y);
614#endif
615
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700616// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700617// Close a loaded PDF page.
618// Parameters:
619// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700620// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700621// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700622DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
623
624// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700625// Close a loaded PDF document.
626// Parameters:
627// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700628// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700629// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700630DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
631
632// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400633// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700634// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400635// page - Handle to the page. Returned by FPDF_LoadPage.
636// start_x - Left pixel position of the display area in
637// device coordinates.
638// start_y - Top pixel position of the display area in device
639// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700640// size_x - Horizontal size (in pixels) for displaying the page.
641// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400642// rotate - Page orientation:
643// 0 (normal)
644// 1 (rotated 90 degrees clockwise)
645// 2 (rotated 180 degrees)
646// 3 (rotated 90 degrees counter-clockwise)
647// device_x - X value in device coordinates to be converted.
648// device_y - Y value in device coordinates to be converted.
649// page_x - A pointer to a double receiving the converted X
650// value in page coordinates.
651// page_y - A pointer to a double receiving the converted Y
652// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700653// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700654// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700655// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400656// The page coordinate system has its origin at the left-bottom corner
657// of the page, with the X-axis on the bottom going to the right, and
658// the Y-axis on the left side going up.
659//
660// NOTE: this coordinate system can be altered when you zoom, scroll,
661// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700662// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700663//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700664// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400665// its origin is at the left-top corner of the window. However this
666// origin can be altered by the Windows coordinate transformation
667// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700668//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400669// You must make sure the start_x, start_y, size_x, size_y
670// and rotate parameters have exactly same values as you used in
671// the FPDF_RenderPage() function call.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700672DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
673 int start_x,
674 int start_y,
675 int size_x,
676 int size_y,
677 int rotate,
678 int device_x,
679 int device_y,
680 double* page_x,
681 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700682
683// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400684// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700685// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400686// page - Handle to the page. Returned by FPDF_LoadPage.
687// start_x - Left pixel position of the display area in
688// device coordinates.
689// start_y - Top pixel position of the display area in device
690// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700691// size_x - Horizontal size (in pixels) for displaying the page.
692// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400693// rotate - Page orientation:
694// 0 (normal)
695// 1 (rotated 90 degrees clockwise)
696// 2 (rotated 180 degrees)
697// 3 (rotated 90 degrees counter-clockwise)
698// page_x - X value in page coordinates.
699// page_y - Y value in page coordinate.
700// device_x - A pointer to an integer receiving the result X
701// value in device coordinates.
702// device_y - A pointer to an integer receiving the result Y
703// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700704// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700705// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700706// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400707// See comments for FPDF_DeviceToPage().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700708DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
709 int start_x,
710 int start_y,
711 int size_x,
712 int size_y,
713 int rotate,
714 double page_x,
715 double page_y,
716 int* device_x,
717 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700718
719// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400720// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700721// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400722// width - The number of pixels in width for the bitmap.
723// Must be greater than 0.
724// height - The number of pixels in height for the bitmap.
725// Must be greater than 0.
726// alpha - A flag indicating whether the alpha channel is used.
727// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700728// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400729// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700730// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700731// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400732// The bitmap always uses 4 bytes per pixel. The first byte is always
733// double word aligned.
734//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700735// The byte order is BGRx (the last byte unused if no alpha channel) or
736// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700737//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400738// The pixels in a horizontal line are stored side by side, with the
739// left most pixel stored first (with lower memory address).
740// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700741//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400742// Lines are stored one after another, with the top most line stored
743// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700744//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700745// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400746// bitmap, but it doesn't initialize the buffer. Applications can use
747// FPDFBitmap_FillRect to fill the bitmap using any color.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700748DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
749 int height,
750 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700751
752// More DIB formats
Dan Sinclair49f88b72015-10-20 15:18:51 -0400753// Gray scale bitmap, one byte per pixel.
754#define FPDFBitmap_Gray 1
755// 3 bytes per pixel, byte order: blue, green, red.
756#define FPDFBitmap_BGR 2
757// 4 bytes per pixel, byte order: blue, green, red, unused.
758#define FPDFBitmap_BGRx 3
759// 4 bytes per pixel, byte order: blue, green, red, alpha.
760#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700761
762// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400763// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700764// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400765// width - The number of pixels in width for the bitmap.
766// Must be greater than 0.
767// height - The number of pixels in height for the bitmap.
768// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700769// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400770// above.
771// first_scan - A pointer to the first byte of the first line if
772// using an external buffer. If this parameter is NULL,
773// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700774// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400775// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700776// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400777// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700778// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400779// Similar to FPDFBitmap_Create function, but allows for more formats
780// and an external buffer is supported. The bitmap created by this
781// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700782// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700783//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400784// If an external buffer is used, then the application should destroy
785// the buffer by itself. FPDFBitmap_Destroy function will not destroy
786// the buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700787DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
788 int height,
789 int format,
790 void* first_scan,
791 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700792
793// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400794// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700795// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700796// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400797// FPDFBitmap_Create.
798// left - The left position. Starting from 0 at the
799// left-most pixel.
800// top - The top position. Starting from 0 at the
801// top-most line.
802// width - Width in pixels to be filled.
803// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700804// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400805// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700806// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700807// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700808// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400809// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700810// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700811//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400812// NOTE: If the alpha channel is used, this function does NOT
813// composite the background with the source color, instead the
814// background will be replaced by the source color and the alpha.
815//
816// If the alpha channel is not used, the alpha parameter is ignored.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700817DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
818 int left,
819 int top,
820 int width,
821 int height,
822 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700823
824// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400825// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700826// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400827// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700828// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700829// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700830// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700831// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400832//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700833// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400834// then manipulate any color and/or alpha values for any pixels in the
835// bitmap.
836//
837// The data is in BGRA format. Where the A maybe unused if alpha was
838// not specified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700839DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
840
841// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400842// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700843// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400844// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700845// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400846// The width of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700847DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
848
849// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400850// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700851// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400852// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700853// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400854// The height of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700855DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
856
857// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400858// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700859// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400860// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700861// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400862// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700863// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400864// The stride may be more than width * number of bytes per pixel.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700865DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
866
867// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400868// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700869// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400870// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700871// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700872// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700873// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400874// This function will not destroy any external buffers provided when
875// the bitmap was created.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700876DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
877
878// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700879// Whether the PDF document prefers to be scaled or not.
880// Parameters:
881// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700882// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700883// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700884DLLEXPORT FPDF_BOOL STDCALL
885FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700886
Bo Xu9114e832014-07-14 13:22:47 -0700887// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700888// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700889// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700890// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700891// Return value:
892// The number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700893DLLEXPORT 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.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700901DLLEXPORT FPDF_PAGERANGE STDCALL
902FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700903
904// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700905// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -0400906// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700907// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700908// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700909// Return value:
910// The paper handling option to be used when printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700911DLLEXPORT FPDF_DUPLEXTYPE STDCALL
912FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700913
Bo Xu4d62b6b2015-01-10 22:52:59 -0800914// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700915// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800916// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700917// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800918// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700919// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800920DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
921
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700922// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -0400923// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -0700924// Parameters:
925// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400926// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700927// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400928// The handle to the destination.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700929DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
930 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700931
Bo Xu4d62b6b2015-01-10 22:52:59 -0800932// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -0400933// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800934// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700935// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -0400936// index - The index of a named destination.
937// buffer - The buffer to store the destination name,
938// used as wchar_t*.
939// buflen [in/out] - Size of the buffer in bytes on input,
940// length of the result in bytes on output
941// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800942// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400943// The destination handle for a given index, or NULL if there is no
944// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800945// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700946// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400947// 1) First time pass in |buffer| as NULL and get buflen.
948// 2) Second time pass in allocated |buffer| and buflen to retrieve
949// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800950//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400951// If buflen is not sufficiently large, it will be set to -1 upon
952// return.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700953DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
954 int index,
955 void* buffer,
956 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -0800957
Tom Sepezc46d0002015-11-30 15:46:36 -0800958#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -0700959// Function: FPDF_BStr_Init
960// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700961DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
962
Tom Sepez9857e202015-05-13 17:09:26 -0700963// Function: FPDF_BStr_Set
964// Helper function to set string data.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700965DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
966 FPDF_LPCSTR bstr,
967 int length);
Bo Xufdc00a72014-10-28 23:03:33 -0700968
Tom Sepez9857e202015-05-13 17:09:26 -0700969// Function: FPDF_BStr_Clear
970// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -0700971DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -0800972#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700973
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_