blob: 1ff0aeb267ed9dbc040c4cf8058d1fb7e8bd168b [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;
Jane Liu4fd9a472017-06-01 18:56:09 -040025typedef void* FPDF_ANNOTATION;
Tom Sepezc46d0002015-11-30 15:46:36 -080026typedef void* FPDF_BITMAP;
27typedef void* FPDF_BOOKMARK;
28typedef void* FPDF_CLIPPATH;
29typedef void* FPDF_DEST;
Tom Sepezc46d0002015-11-30 15:46:36 -080030typedef void* FPDF_DOCUMENT;
31typedef void* FPDF_FONT;
Tom Sepez9857e202015-05-13 17:09:26 -070032typedef void* FPDF_LINK;
Tom Sepezc46d0002015-11-30 15:46:36 -080033typedef void* FPDF_PAGE;
34typedef void* FPDF_PAGELINK;
35typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
Tom Sepez9857e202015-05-13 17:09:26 -070036typedef void* FPDF_PAGERANGE;
Cary Clark399be5b2016-03-14 16:51:29 -040037typedef void* FPDF_RECORDER;
Tom Sepezc46d0002015-11-30 15:46:36 -080038typedef void* FPDF_SCHHANDLE;
thestig9067fd62016-11-23 14:10:06 -080039typedef void* FPDF_STRUCTELEMENT;
40typedef void* FPDF_STRUCTTREE;
Tom Sepezc46d0002015-11-30 15:46:36 -080041typedef void* FPDF_TEXTPAGE;
42
43#ifdef PDF_ENABLE_XFA
44typedef void* FPDF_STRINGHANDLE;
45typedef void* FPDF_WIDGET;
46#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070047
48// Basic data types
Tom Sepez9857e202015-05-13 17:09:26 -070049typedef int FPDF_BOOL;
50typedef int FPDF_ERROR;
51typedef unsigned long FPDF_DWORD;
52typedef float FS_FLOAT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070053
Tom Sepezc46d0002015-11-30 15:46:36 -080054#ifdef PDF_ENABLE_XFA
55typedef void* FPDF_LPVOID;
56typedef void const* FPDF_LPCVOID;
57typedef char const* FPDF_LPCSTR;
58typedef int FPDF_RESULT;
59#endif
60
Bo Xu9114e832014-07-14 13:22:47 -070061// Duplex types
62typedef enum _FPDF_DUPLEXTYPE_ {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070063 DuplexUndefined = 0,
64 Simplex,
65 DuplexFlipShortEdge,
66 DuplexFlipLongEdge
Bo Xu9114e832014-07-14 13:22:47 -070067} FPDF_DUPLEXTYPE;
68
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070069// String types
Tom Sepez9857e202015-05-13 17:09:26 -070070typedef unsigned short FPDF_WCHAR;
71typedef unsigned char const* FPDF_LPCBYTE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070072
Nico Weber9d8ec5a2015-08-04 13:00:21 -070073// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
74// encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070075typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070076
Dan Sinclair49f88b72015-10-20 15:18:51 -040077// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
78// bytes (except surrogation), with the low byte first.
79typedef const unsigned short* FPDF_WIDESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070080
Tom Sepezc46d0002015-11-30 15:46:36 -080081#ifdef PDF_ENABLE_XFA
Dan Sinclair49f88b72015-10-20 15:18:51 -040082// Structure for a byte string.
83// Note, a byte string commonly means a UTF-16LE formated string.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070084typedef struct _FPDF_BSTR {
Dan Sinclair49f88b72015-10-20 15:18:51 -040085 // String buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070086 char* str;
Dan Sinclair49f88b72015-10-20 15:18:51 -040087 // Length of the string, in bytes.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070088 int len;
Bo Xufdc00a72014-10-28 23:03:33 -070089} FPDF_BSTR;
Tom Sepezc46d0002015-11-30 15:46:36 -080090#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -070091
Dan Sinclair49f88b72015-10-20 15:18:51 -040092// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
93// Windows unicode string, however, special care needs to be taken if you
94// expect to process Unicode larger than 0xffff.
95//
96// For Linux/Unix programmers: most compiler/library environments use 4 bytes
97// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
98// system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070099typedef const char* FPDF_STRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700100
Dan Sinclair49f88b72015-10-20 15:18:51 -0400101// Matrix for transformation.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102typedef struct _FS_MATRIX_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400103 float a;
104 float b;
105 float c;
106 float d;
107 float e;
108 float f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700109} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700110
Dan Sinclair49f88b72015-10-20 15:18:51 -0400111// Rectangle area(float) in device or page coordinate system.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112typedef struct _FS_RECTF_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400113 // The x-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700114 float left;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400115 // The y-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 float top;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400117 // The x-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700118 float right;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400119 // The y-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700120 float bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121} * FS_LPRECTF, FS_RECTF;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400122
123// Const Pointer to FS_RECTF structure.
Tom Sepez9857e202015-05-13 17:09:26 -0700124typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700125
Jane Liu4fd9a472017-06-01 18:56:09 -0400126// Annotation subtype.
127typedef int FPDF_ANNOTATION_SUBTYPE;
128
Jane Liu2e1a32b2017-07-06 12:01:25 -0400129// Dictionary value types.
130typedef int FPDF_OBJECT_TYPE;
131
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700132#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
133// On Windows system, functions are exported in a DLL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700134#define DLLEXPORT __declspec(dllexport)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700135#define STDCALL __stdcall
136#else
137#define DLLEXPORT
138#define STDCALL
139#endif
140
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700141// Exported Functions
142#ifdef __cplusplus
143extern "C" {
144#endif
145
146// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700147// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700148// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700149// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700150// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700151// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700152// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700153// Convenience function to call FPDF_InitLibraryWithConfig() for
154// backwards comatibility purposes.
155DLLEXPORT void STDCALL FPDF_InitLibrary();
156
Dan Sinclair49f88b72015-10-20 15:18:51 -0400157// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700158typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700159 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700160 int version;
161
162 // Array of paths to scan in place of the defaults when using built-in
163 // FXGE font loading code. The array is terminated by a NULL pointer.
164 // The Array may be NULL itself to use the default paths. May be ignored
165 // entirely depending upon the platform.
166 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700167
168 // Version 2.
169
170 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
171 void* m_pIsolate;
172
173 // The embedder data slot to use in the v8::Isolate to store PDFium's
174 // per-isolate data. The value needs to be between 0 and
175 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
176 // for most embedders.
177 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700178} FPDF_LIBRARY_CONFIG;
179
180// Function: FPDF_InitLibraryWithConfig
181// Initialize the FPDFSDK library
182// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400183// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700184// Return value:
185// None.
186// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700187// You have to call this function before you can call any PDF
188// processing functions.
Tom Sepez326a2a72015-11-20 10:47:32 -0800189DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
190 const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700191
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700192// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700193// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700194// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700195// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700196// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700197// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700198// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700199// You can call this function to release all memory blocks allocated by
200// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400201// After this function is called, you should not call any PDF
202// processing functions.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700203DLLEXPORT void STDCALL FPDF_DestroyLibrary();
204
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700205// Policy for accessing the local machine time.
206#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700207
208// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700209// Set the policy for the sandbox environment.
210// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400211// policy - The specified policy for setting, for example:
212// FPDF_POLICY_MACHINETIME_ACCESS.
213// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700214// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700215// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700216DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
217 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700218
rbpotterdb764702017-01-12 10:31:43 -0800219#if defined(_WIN32)
220#if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
thestigfdb35ff2016-07-18 13:45:44 -0700221// Pointer to a helper function to make |font| with |text| of |text_length|
222// accessible when printing text with GDI. This is useful in sandboxed
223// environments where PDFium's access to GDI may be restricted.
224typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
225 const wchar_t* text,
226 size_t text_length);
227
228// Function: FPDF_SetTypefaceAccessibleFunc
229// Set the function pointer that makes GDI fonts available in sandboxed
230// environments. Experimental API.
231// Parameters:
232// func - A function pointer. See description above.
233// Return value:
234// None.
235DLLEXPORT void STDCALL
236FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func);
237
238// Function: FPDF_SetPrintTextWithGDI
239// Set whether to use GDI to draw fonts when printing on Windows.
240// Experimental API.
241// Parameters:
242// use_gdi - Set to true to enable printing text with GDI.
243// Return value:
244// None.
245DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi);
rbpotterdb764702017-01-12 10:31:43 -0800246#endif // PDFIUM_PRINT_TEXT_WITH_GDI
247
248// Function: FPDF_SetPrintPostscriptLevel
249// Set postscript printing level when printing on Windows.
250// Experimental API.
251// Parameters:
252// postscript_level - 0 to disable postscript printing,
253// 2 to print with postscript level 2,
254// 3 to print with postscript level 3.
255// All other values are invalid.
256// Return value:
257// True if successful, false if unsucessful (typically invalid input).
Lei Zhangd1c9b452017-05-05 17:21:36 -0700258DLLEXPORT FPDF_BOOL STDCALL FPDF_SetPrintPostscriptLevel(int postscript_level);
rbpotterdb764702017-01-12 10:31:43 -0800259#endif // defined(_WIN32)
thestigfdb35ff2016-07-18 13:45:44 -0700260
Tom Sepez3c3201f2015-05-20 10:20:35 -0700261// Function: FPDF_LoadDocument
262// Open and load a PDF document.
263// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400264// file_path - Path to the PDF file (including extension).
265// password - A string used as the password for the PDF file.
266// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700267// Return value:
268// A handle to the loaded document, or NULL on failure.
269// Comments:
270// Loaded document can be closed by FPDF_CloseDocument().
271// If this function fails, you can use FPDF_GetLastError() to retrieve
272// the reason why it failed.
Tom Sepez9857e202015-05-13 17:09:26 -0700273DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700274 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700275
276// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700277// Open and load a PDF document from memory.
278// Parameters:
279// data_buf - Pointer to a buffer containing the PDF document.
280// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400281// password - A string used as the password for the PDF file.
282// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700283// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400284// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700285// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700286// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400287// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700288// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400289// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700290// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800291// If PDFium is built with the XFA module, the application should call
292// FPDF_LoadXFA() function after the PDF document loaded to support XFA
293// fields defined in the fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700294DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700295 int size,
296 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700297
298// Structure for custom file access.
299typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700300 // File length, in bytes.
301 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700302
Dan Sinclair49f88b72015-10-20 15:18:51 -0400303 // A function pointer for getting a block of data from a specific position.
304 // Position is specified by byte offset from the beginning of the file.
305 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700306 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400307 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700308 // Return value: should be non-zero if successful, zero for error.
309 int (*m_GetBlock)(void* param,
310 unsigned long position,
311 unsigned char* pBuf,
312 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700313
Dan Sinclair49f88b72015-10-20 15:18:51 -0400314 // A custom pointer for all implementation specific data. This pointer will
315 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700316 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700317} FPDF_FILEACCESS;
318
Tom Sepezc46d0002015-11-30 15:46:36 -0800319#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700320/**
321 * @brief Structure for file reading or writing (I/O).
322 *
323 * @note This is a handler and should be implemented by callers.
324 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700325typedef struct _FPDF_FILEHANDLER {
326 /**
327 * @brief User-defined data.
328 * @note Callers can use this field to track controls.
329 */
330 FPDF_LPVOID clientData;
331 /**
332 * @brief Callback function to release the current file stream object.
333 *
334 * @param[in] clientData Pointer to user-defined data.
335 *
336 * @return None.
337 */
338 void (*Release)(FPDF_LPVOID clientData);
339 /**
340 * @brief Callback function to retrieve the current file stream size.
341 *
342 * @param[in] clientData Pointer to user-defined data.
343 *
344 * @return Size of file stream.
345 */
346 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
347 /**
348 * @brief Callback function to read data from the current file stream.
349 *
350 * @param[in] clientData Pointer to user-defined data.
351 * @param[in] offset Offset position starts from the beginning of file
352 * stream. This parameter indicates reading position.
353 * @param[in] buffer Memory buffer to store data which are read from
354 * file stream. This parameter should not be <b>NULL</b>.
355 * @param[in] size Size of data which should be read from file
356 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
357 * should be enough to store specified data.
358 *
359 * @return 0 for success, other value for failure.
360 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500361 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
362 FPDF_DWORD offset,
363 FPDF_LPVOID buffer,
364 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700365 /**
366 * @brief Callback function to write data into the current file stream.
367 *
368 * @param[in] clientData Pointer to user-defined data.
369 * @param[in] offset Offset position starts from the beginning of file
370 * stream. This parameter indicates writing position.
371 * @param[in] buffer Memory buffer contains data which is written into
372 * file stream. This parameter should not be <b>NULL</b>.
373 * @param[in] size Size of data which should be written into file
374 * stream, in bytes.
375 *
376 * @return 0 for success, other value for failure.
377 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500378 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
379 FPDF_DWORD offset,
380 FPDF_LPCVOID buffer,
381 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700382 /**
383 * @brief Callback function to flush all internal accessing buffers.
384 *
385 * @param[in] clientData Pointer to user-defined data.
386 *
387 * @return 0 for success, other value for failure.
388 */
389 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
390 /**
391 * @brief Callback function to change file size.
392 *
393 * @details This function is called under writing mode usually. Implementer
394 * can determine whether to realize it based on application requests.
395 *
396 * @param[in] clientData Pointer to user-defined data.
397 * @param[in] size New size of file stream, in bytes.
398 *
399 * @return 0 for success, other value for failure.
400 */
401 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700402} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
403
Tom Sepezc46d0002015-11-30 15:46:36 -0800404#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700405// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700406// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700407// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400408// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700409// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700410// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400411// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700412// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400413// The application must keep the file resources valid until the PDF
414// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700415//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400416// The loaded document can be closed with FPDF_CloseDocument.
417// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800418// If PDFium is built with the XFA module, the application should call
419// FPDF_LoadXFA() function after the PDF document loaded to support XFA
420// fields defined in the fpdfformfill.h file.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700421DLLEXPORT FPDF_DOCUMENT STDCALL
422FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700423
424// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400425// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700426// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400427// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700428// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400429// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700430// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400431// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700432// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400433// If the document was created by FPDF_CreateNewDocument,
434// then this function will always fail.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700435DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
436 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700437
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700438#define FPDF_ERR_SUCCESS 0 // No error.
439#define FPDF_ERR_UNKNOWN 1 // Unknown error.
440#define FPDF_ERR_FILE 2 // File not found or could not be opened.
441#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
442#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
443#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
444#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800445#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700446#define FPDF_ERR_XFALOAD 7 // Load XFA error.
447#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800448#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700449
450// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400451// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700452// Parameters:
453// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700454// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400455// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700456// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700457// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400458// function is not defined.
Tom Sepez9857e202015-05-13 17:09:26 -0700459DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700460
461// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700462// Get file permission flags of the document.
463// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400464// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700465// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400466// A 32-bit integer indicating permission flags. Please refer to the
467// PDF Reference for detailed descriptions. If the document is not
468// protected, 0xffffffff will be returned.
Tom Sepez9857e202015-05-13 17:09:26 -0700469DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700470
Bo Xuc5cab022014-09-19 19:16:31 -0700471// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400472// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700473// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400474// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700475// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400476// The security handler revision number. Please refer to the PDF
477// Reference for a detailed description. If the document is not
478// protected, -1 will be returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700479DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
480
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700481// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400482// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700483// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400484// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700485// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700486// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700487DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
488
489// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400490// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700491// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700492// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700493// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700494// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400495// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700496// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400497// The loaded page can be rendered to devices using FPDF_RenderPage.
498// The loaded page can be closed using FPDF_ClosePage.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700499DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
500 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700501
502// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700503// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700504// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400505// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700506// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700507// Page width (excluding non-displayable area) measured in points.
508// One point is 1/72 inch (around 0.3528 mm).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700509DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
510
511// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700512// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700513// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400514// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700515// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700516// Page height (excluding non-displayable area) measured in points.
517// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700518DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
519
520// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400521// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700522// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400523// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700524// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400525// width - Pointer to a double to receive the page width
526// (in points).
527// height - Pointer to a double to receive the page height
528// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700529// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700530// Non-zero for success. 0 for error (document or page not found).
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700531DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
532 int page_index,
533 double* width,
534 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700535
Dan Sinclair49f88b72015-10-20 15:18:51 -0400536// Page rendering flags. They can be combined with bit-wise OR.
537//
538// Set if annotations are to be rendered.
539#define FPDF_ANNOT 0x01
540// Set if using text rendering optimized for LCD display.
541#define FPDF_LCD_TEXT 0x02
542// Don't use the native text output available on some platforms
543#define FPDF_NO_NATIVETEXT 0x04
544// Grayscale output.
545#define FPDF_GRAYSCALE 0x08
546// Set if you want to get some debug info.
547#define FPDF_DEBUG_INFO 0x80
548// Set if you don't want to catch exceptions.
549#define FPDF_NO_CATCH 0x100
550// Limit image cache size.
551#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
552// Always use halftone for image stretching.
553#define FPDF_RENDER_FORCEHALFTONE 0x400
554// Render for printing.
555#define FPDF_PRINTING 0x800
556// Set to disable anti-aliasing on text.
557#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
558// Set to disable anti-aliasing on images.
559#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
560// Set to disable anti-aliasing on paths.
561#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
562// Set whether to render in a reverse Byte order, this flag is only used when
563// rendering to a bitmap.
564#define FPDF_REVERSE_BYTE_ORDER 0x10
565
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700566#ifdef _WIN32
567// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400568// Render contents of a page to a device (screen, bitmap, or printer).
569// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700570// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400571// dc - Handle to the device context.
572// page - Handle to the page. Returned by FPDF_LoadPage.
573// start_x - Left pixel position of the display area in
574// device coordinates.
575// start_y - Top pixel position of the display area in device
576// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700577// size_x - Horizontal size (in pixels) for displaying the page.
578// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400579// rotate - Page orientation:
580// 0 (normal)
581// 1 (rotated 90 degrees clockwise)
582// 2 (rotated 180 degrees)
583// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700584// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400585// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700586// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700587// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700588DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
589 FPDF_PAGE page,
590 int start_x,
591 int start_y,
592 int size_x,
593 int size_y,
594 int rotate,
595 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700596#endif
597
598// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400599// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700600// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700601// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400602// output buffer). The bitmap handle can be created
603// by FPDFBitmap_Create.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700604// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400605// start_x - Left pixel position of the display area in
606// bitmap coordinates.
607// start_y - Top pixel position of the display area in bitmap
608// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700609// size_x - Horizontal size (in pixels) for displaying the page.
610// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400611// rotate - Page orientation:
612// 0 (normal)
613// 1 (rotated 90 degrees clockwise)
614// 2 (rotated 180 degrees)
615// 3 (rotated 90 degrees counter-clockwise)
thestiga78ba602016-11-23 15:25:48 -0800616// flags - 0 for normal display, or combination of the Page
617// Rendering flags defined above. With the FPDF_ANNOT
618// flag, it renders all annotations that do not require
619// user-interaction, which are all annotations except
620// widget and popup annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700621// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700622// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700623DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
624 FPDF_PAGE page,
625 int start_x,
626 int start_y,
627 int size_x,
628 int size_y,
629 int rotate,
630 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700631
thestiga78ba602016-11-23 15:25:48 -0800632// Function: FPDF_RenderPageBitmapWithMatrix
633// Render contents of a page to a device independent bitmap.
634// Parameters:
635// bitmap - Handle to the device independent bitmap (as the
636// output buffer). The bitmap handle can be created
637// by FPDFBitmap_Create.
638// page - Handle to the page. Returned by FPDF_LoadPage
639// matrix - The transform matrix.
640// clipping - The rect to clip to.
641// flags - 0 for normal display, or combination of the Page
642// Rendering flags defined above. With the FPDF_ANNOT
643// flag, it renders all annotations that do not require
644// user-interaction, which are all annotations except
645// widget and popup annotations.
646// Return value:
647// None.
648DLLEXPORT void STDCALL FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
649 FPDF_PAGE page,
650 const FS_MATRIX* matrix,
651 const FS_RECTF* clipping,
652 int flags);
653
Cary Clark399be5b2016-03-14 16:51:29 -0400654#ifdef _SKIA_SUPPORT_
655DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
656 int size_x,
657 int size_y);
658#endif
659
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700660// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700661// Close a loaded PDF page.
662// Parameters:
663// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700664// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700665// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700666DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
667
668// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700669// Close a loaded PDF document.
670// Parameters:
671// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700672// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700673// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700674DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
675
676// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400677// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700678// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400679// page - Handle to the page. Returned by FPDF_LoadPage.
680// start_x - Left pixel position of the display area in
681// device coordinates.
682// start_y - Top pixel position of the display area in device
683// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700684// size_x - Horizontal size (in pixels) for displaying the page.
685// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400686// rotate - Page orientation:
687// 0 (normal)
688// 1 (rotated 90 degrees clockwise)
689// 2 (rotated 180 degrees)
690// 3 (rotated 90 degrees counter-clockwise)
691// device_x - X value in device coordinates to be converted.
692// device_y - Y value in device coordinates to be converted.
693// page_x - A pointer to a double receiving the converted X
694// value in page coordinates.
695// page_y - A pointer to a double receiving the converted Y
696// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700697// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700698// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700699// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400700// The page coordinate system has its origin at the left-bottom corner
701// of the page, with the X-axis on the bottom going to the right, and
702// the Y-axis on the left side going up.
703//
704// NOTE: this coordinate system can be altered when you zoom, scroll,
705// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700706// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700707//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700708// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400709// its origin is at the left-top corner of the window. However this
710// origin can be altered by the Windows coordinate transformation
711// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700712//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400713// You must make sure the start_x, start_y, size_x, size_y
714// and rotate parameters have exactly same values as you used in
715// the FPDF_RenderPage() function call.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700716DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
717 int start_x,
718 int start_y,
719 int size_x,
720 int size_y,
721 int rotate,
722 int device_x,
723 int device_y,
724 double* page_x,
725 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700726
727// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400728// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700729// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400730// page - Handle to the page. Returned by FPDF_LoadPage.
731// start_x - Left pixel position of the display area in
732// device coordinates.
733// start_y - Top pixel position of the display area in device
734// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700735// size_x - Horizontal size (in pixels) for displaying the page.
736// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400737// rotate - Page orientation:
738// 0 (normal)
739// 1 (rotated 90 degrees clockwise)
740// 2 (rotated 180 degrees)
741// 3 (rotated 90 degrees counter-clockwise)
742// page_x - X value in page coordinates.
743// page_y - Y value in page coordinate.
744// device_x - A pointer to an integer receiving the result X
745// value in device coordinates.
746// device_y - A pointer to an integer receiving the result Y
747// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700748// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700749// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700750// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400751// See comments for FPDF_DeviceToPage().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700752DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
753 int start_x,
754 int start_y,
755 int size_x,
756 int size_y,
757 int rotate,
758 double page_x,
759 double page_y,
760 int* device_x,
761 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700762
763// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400764// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700765// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400766// width - The number of pixels in width for the bitmap.
767// Must be greater than 0.
768// height - The number of pixels in height for the bitmap.
769// Must be greater than 0.
770// alpha - A flag indicating whether the alpha channel is used.
771// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700772// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400773// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700774// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700775// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400776// The bitmap always uses 4 bytes per pixel. The first byte is always
777// double word aligned.
778//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700779// The byte order is BGRx (the last byte unused if no alpha channel) or
780// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700781//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400782// The pixels in a horizontal line are stored side by side, with the
783// left most pixel stored first (with lower memory address).
784// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700785//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400786// Lines are stored one after another, with the top most line stored
787// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700788//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700789// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400790// bitmap, but it doesn't initialize the buffer. Applications can use
791// FPDFBitmap_FillRect to fill the bitmap using any color.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700792DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
793 int height,
794 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700795
796// More DIB formats
Dan Sinclair49f88b72015-10-20 15:18:51 -0400797// Gray scale bitmap, one byte per pixel.
798#define FPDFBitmap_Gray 1
799// 3 bytes per pixel, byte order: blue, green, red.
800#define FPDFBitmap_BGR 2
801// 4 bytes per pixel, byte order: blue, green, red, unused.
802#define FPDFBitmap_BGRx 3
803// 4 bytes per pixel, byte order: blue, green, red, alpha.
804#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700805
806// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400807// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700808// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400809// width - The number of pixels in width for the bitmap.
810// Must be greater than 0.
811// height - The number of pixels in height for the bitmap.
812// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700813// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400814// above.
815// first_scan - A pointer to the first byte of the first line if
816// using an external buffer. If this parameter is NULL,
817// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700818// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400819// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700820// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400821// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700822// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400823// Similar to FPDFBitmap_Create function, but allows for more formats
824// and an external buffer is supported. The bitmap created by this
825// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700826// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700827//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400828// If an external buffer is used, then the application should destroy
829// the buffer by itself. FPDFBitmap_Destroy function will not destroy
830// the buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700831DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
832 int height,
833 int format,
834 void* first_scan,
835 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700836
837// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400838// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700839// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700840// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400841// FPDFBitmap_Create.
842// left - The left position. Starting from 0 at the
843// left-most pixel.
844// top - The top position. Starting from 0 at the
845// top-most line.
846// width - Width in pixels to be filled.
847// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700848// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400849// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700850// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700851// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700852// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400853// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700854// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700855//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400856// NOTE: If the alpha channel is used, this function does NOT
857// composite the background with the source color, instead the
858// background will be replaced by the source color and the alpha.
859//
860// If the alpha channel is not used, the alpha parameter is ignored.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700861DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
862 int left,
863 int top,
864 int width,
865 int height,
866 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700867
868// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400869// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700870// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400871// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700872// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700873// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700874// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700875// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400876//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700877// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400878// then manipulate any color and/or alpha values for any pixels in the
879// bitmap.
880//
881// The data is in BGRA format. Where the A maybe unused if alpha was
882// not specified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700883DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
884
885// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400886// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700887// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400888// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700889// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400890// The width of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700891DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
892
893// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400894// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700895// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400896// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700897// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400898// The height of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700899DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
900
901// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400902// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700903// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400904// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700905// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400906// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700907// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400908// The stride may be more than width * number of bytes per pixel.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700909DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
910
911// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400912// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700913// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400914// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700915// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700916// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700917// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400918// This function will not destroy any external buffers provided when
919// the bitmap was created.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700920DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
921
922// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700923// Whether the PDF document prefers to be scaled or not.
924// Parameters:
925// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700926// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700927// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700928DLLEXPORT FPDF_BOOL STDCALL
929FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700930
Bo Xu9114e832014-07-14 13:22:47 -0700931// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700932// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700933// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700934// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700935// Return value:
936// The number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700937DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
938
939// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700940// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700941// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700942// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700943// Return value:
944// The print page range to be used for printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700945DLLEXPORT FPDF_PAGERANGE STDCALL
946FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700947
948// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700949// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -0400950// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700951// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700952// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700953// Return value:
954// The paper handling option to be used when printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700955DLLEXPORT FPDF_DUPLEXTYPE STDCALL
956FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700957
thestig04bebfe2016-11-04 16:07:25 -0700958// Function: FPDF_VIEWERREF_GetName
959// Gets the contents for a viewer ref, with a given key. The value must
960// be of type "name".
961// Parameters:
962// document - Handle to the loaded document.
963// key - Name of the key in the viewer pref dictionary.
964// buffer - A string to write the contents of the key to.
965// length - Length of the buffer.
966// Return value:
967// The number of bytes in the contents, including the NULL terminator.
968// Thus if the return value is 0, then that indicates an error, such
969// as when |document| is invalid or |buffer| is NULL. If |length| is
970// less than the returned length, or |buffer| is NULL, |buffer| will
971// not be modified.
972DLLEXPORT unsigned long STDCALL FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
973 FPDF_BYTESTRING key,
974 char* buffer,
975 unsigned long length);
976
Bo Xu4d62b6b2015-01-10 22:52:59 -0800977// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700978// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800979// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700980// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800981// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700982// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800983DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
984
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700985// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -0400986// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -0700987// Parameters:
988// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400989// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700990// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400991// The handle to the destination.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700992DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
993 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700994
Bo Xu4d62b6b2015-01-10 22:52:59 -0800995// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -0400996// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800997// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700998// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -0400999// index - The index of a named destination.
1000// buffer - The buffer to store the destination name,
1001// used as wchar_t*.
1002// buflen [in/out] - Size of the buffer in bytes on input,
1003// length of the result in bytes on output
1004// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001005// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001006// The destination handle for a given index, or NULL if there is no
1007// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001008// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -07001009// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001010// 1) First time pass in |buffer| as NULL and get buflen.
1011// 2) Second time pass in allocated |buffer| and buflen to retrieve
1012// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001013//
Dan Sinclair49f88b72015-10-20 15:18:51 -04001014// If buflen is not sufficiently large, it will be set to -1 upon
1015// return.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001016DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
1017 int index,
1018 void* buffer,
1019 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001020
Tom Sepezc46d0002015-11-30 15:46:36 -08001021#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -07001022// Function: FPDF_BStr_Init
1023// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -07001024DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
1025
Tom Sepez9857e202015-05-13 17:09:26 -07001026// Function: FPDF_BStr_Set
1027// Helper function to set string data.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001028DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
1029 FPDF_LPCSTR bstr,
1030 int length);
Bo Xufdc00a72014-10-28 23:03:33 -07001031
Tom Sepez9857e202015-05-13 17:09:26 -07001032// Function: FPDF_BStr_Clear
1033// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -07001034DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -08001035#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -07001036
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001037#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -07001038}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001039#endif
1040
Tom Sepez9857e202015-05-13 17:09:26 -07001041#endif // PUBLIC_FPDFVIEW_H_