blob: 370b84ed0ff8b50afc3b9479fc5125153be4fb60 [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
Jane Liu18ae06d2017-07-18 10:15:16 -040023// PDF object types
24#define FPDF_OBJECT_UNKNOWN 0
25#define FPDF_OBJECT_BOOLEAN 1
26#define FPDF_OBJECT_NUMBER 2
27#define FPDF_OBJECT_STRING 3
28#define FPDF_OBJECT_NAME 4
29#define FPDF_OBJECT_ARRAY 5
30#define FPDF_OBJECT_DICTIONARY 6
31#define FPDF_OBJECT_STREAM 7
32#define FPDF_OBJECT_NULLOBJ 8
33#define FPDF_OBJECT_REFERENCE 9
34
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070035// PDF types
Tom Sepez9857e202015-05-13 17:09:26 -070036typedef void* FPDF_ACTION;
Jane Liu4fd9a472017-06-01 18:56:09 -040037typedef void* FPDF_ANNOTATION;
Jane Liu18ae06d2017-07-18 10:15:16 -040038typedef void* FPDF_ATTACHMENT;
Tom Sepezc46d0002015-11-30 15:46:36 -080039typedef void* FPDF_BITMAP;
40typedef void* FPDF_BOOKMARK;
41typedef void* FPDF_CLIPPATH;
42typedef void* FPDF_DEST;
Tom Sepezc46d0002015-11-30 15:46:36 -080043typedef void* FPDF_DOCUMENT;
44typedef void* FPDF_FONT;
Tom Sepez9857e202015-05-13 17:09:26 -070045typedef void* FPDF_LINK;
Tom Sepezc46d0002015-11-30 15:46:36 -080046typedef void* FPDF_PAGE;
47typedef void* FPDF_PAGELINK;
48typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
Tom Sepez9857e202015-05-13 17:09:26 -070049typedef void* FPDF_PAGERANGE;
Cary Clark399be5b2016-03-14 16:51:29 -040050typedef void* FPDF_RECORDER;
Tom Sepezc46d0002015-11-30 15:46:36 -080051typedef void* FPDF_SCHHANDLE;
thestig9067fd62016-11-23 14:10:06 -080052typedef void* FPDF_STRUCTELEMENT;
53typedef void* FPDF_STRUCTTREE;
Tom Sepezc46d0002015-11-30 15:46:36 -080054typedef void* FPDF_TEXTPAGE;
Miklos Vajna36eed872017-09-20 22:52:43 +020055typedef void const* FPDF_PATHSEGMENT;
Tom Sepezc46d0002015-11-30 15:46:36 -080056
57#ifdef PDF_ENABLE_XFA
58typedef void* FPDF_STRINGHANDLE;
59typedef void* FPDF_WIDGET;
60#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070061
62// Basic data types
Tom Sepez9857e202015-05-13 17:09:26 -070063typedef int FPDF_BOOL;
64typedef int FPDF_ERROR;
65typedef unsigned long FPDF_DWORD;
66typedef float FS_FLOAT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070067
Tom Sepezc46d0002015-11-30 15:46:36 -080068#ifdef PDF_ENABLE_XFA
69typedef void* FPDF_LPVOID;
70typedef void const* FPDF_LPCVOID;
71typedef char const* FPDF_LPCSTR;
72typedef int FPDF_RESULT;
73#endif
74
Bo Xu9114e832014-07-14 13:22:47 -070075// Duplex types
76typedef enum _FPDF_DUPLEXTYPE_ {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070077 DuplexUndefined = 0,
78 Simplex,
79 DuplexFlipShortEdge,
80 DuplexFlipLongEdge
Bo Xu9114e832014-07-14 13:22:47 -070081} FPDF_DUPLEXTYPE;
82
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070083// String types
Tom Sepez9857e202015-05-13 17:09:26 -070084typedef unsigned short FPDF_WCHAR;
85typedef unsigned char const* FPDF_LPCBYTE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070086
Nico Weber9d8ec5a2015-08-04 13:00:21 -070087// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
88// encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070089typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070090
Dan Sinclair49f88b72015-10-20 15:18:51 -040091// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
92// bytes (except surrogation), with the low byte first.
93typedef const unsigned short* FPDF_WIDESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070094
Tom Sepezc46d0002015-11-30 15:46:36 -080095#ifdef PDF_ENABLE_XFA
Dan Sinclair49f88b72015-10-20 15:18:51 -040096// Structure for a byte string.
97// Note, a byte string commonly means a UTF-16LE formated string.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070098typedef struct _FPDF_BSTR {
Dan Sinclair49f88b72015-10-20 15:18:51 -040099 // String buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700100 char* str;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400101 // Length of the string, in bytes.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102 int len;
Bo Xufdc00a72014-10-28 23:03:33 -0700103} FPDF_BSTR;
Tom Sepezc46d0002015-11-30 15:46:36 -0800104#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700105
Dan Sinclair49f88b72015-10-20 15:18:51 -0400106// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
107// Windows unicode string, however, special care needs to be taken if you
108// expect to process Unicode larger than 0xffff.
109//
110// For Linux/Unix programmers: most compiler/library environments use 4 bytes
111// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
112// system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113typedef const char* FPDF_STRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700114
Dan Sinclair49f88b72015-10-20 15:18:51 -0400115// Matrix for transformation.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116typedef struct _FS_MATRIX_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400117 float a;
118 float b;
119 float c;
120 float d;
121 float e;
122 float f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700123} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700124
Dan Sinclair49f88b72015-10-20 15:18:51 -0400125// Rectangle area(float) in device or page coordinate system.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700126typedef struct _FS_RECTF_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400127 // The x-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700128 float left;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400129 // The y-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700130 float top;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400131 // The x-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700132 float right;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400133 // The y-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700134 float bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700135} * FS_LPRECTF, FS_RECTF;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400136
137// Const Pointer to FS_RECTF structure.
Tom Sepez9857e202015-05-13 17:09:26 -0700138typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700139
Jane Liu4fd9a472017-06-01 18:56:09 -0400140// Annotation subtype.
141typedef int FPDF_ANNOTATION_SUBTYPE;
142
Jane Liu2e1a32b2017-07-06 12:01:25 -0400143// Dictionary value types.
144typedef int FPDF_OBJECT_TYPE;
145
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000146#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
147// On Windows system, functions are exported in a DLL
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400148#define FPDF_EXPORT __declspec(dllexport)
149#define FPDF_CALLCONV __stdcall
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700150#else
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400151#define FPDF_EXPORT
152#define FPDF_CALLCONV
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700153#endif
154
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700155// Exported Functions
156#ifdef __cplusplus
157extern "C" {
158#endif
159
160// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700161// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700162// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700163// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700164// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700165// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700166// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700167// Convenience function to call FPDF_InitLibraryWithConfig() for
168// backwards comatibility purposes.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400169FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibrary();
Lei Zhang6f62d532015-09-23 15:31:44 -0700170
Dan Sinclair49f88b72015-10-20 15:18:51 -0400171// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700172typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700173 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700174 int version;
175
176 // Array of paths to scan in place of the defaults when using built-in
177 // FXGE font loading code. The array is terminated by a NULL pointer.
178 // The Array may be NULL itself to use the default paths. May be ignored
179 // entirely depending upon the platform.
180 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700181
182 // Version 2.
183
184 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
185 void* m_pIsolate;
186
187 // The embedder data slot to use in the v8::Isolate to store PDFium's
188 // per-isolate data. The value needs to be between 0 and
189 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
190 // for most embedders.
191 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700192} FPDF_LIBRARY_CONFIG;
193
194// Function: FPDF_InitLibraryWithConfig
195// Initialize the FPDFSDK library
196// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400197// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700198// Return value:
199// None.
200// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700201// You have to call this function before you can call any PDF
202// processing functions.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400203FPDF_EXPORT void FPDF_CALLCONV
204FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700205
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700206// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700207// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700208// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700209// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700210// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700211// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700212// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700213// You can call this function to release all memory blocks allocated by
214// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400215// After this function is called, you should not call any PDF
216// processing functions.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400217FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700218
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700219// Policy for accessing the local machine time.
220#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700221
222// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700223// Set the policy for the sandbox environment.
224// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400225// policy - The specified policy for setting, for example:
226// FPDF_POLICY_MACHINETIME_ACCESS.
227// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700228// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700229// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400230FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
231 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700232
rbpotterdb764702017-01-12 10:31:43 -0800233#if defined(_WIN32)
234#if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
thestigfdb35ff2016-07-18 13:45:44 -0700235// Pointer to a helper function to make |font| with |text| of |text_length|
236// accessible when printing text with GDI. This is useful in sandboxed
237// environments where PDFium's access to GDI may be restricted.
238typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
239 const wchar_t* text,
240 size_t text_length);
241
242// Function: FPDF_SetTypefaceAccessibleFunc
243// Set the function pointer that makes GDI fonts available in sandboxed
244// environments. Experimental API.
245// Parameters:
246// func - A function pointer. See description above.
247// Return value:
248// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400249FPDF_EXPORT void FPDF_CALLCONV
thestigfdb35ff2016-07-18 13:45:44 -0700250FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func);
251
252// Function: FPDF_SetPrintTextWithGDI
253// Set whether to use GDI to draw fonts when printing on Windows.
254// Experimental API.
255// Parameters:
256// use_gdi - Set to true to enable printing text with GDI.
257// Return value:
258// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400259FPDF_EXPORT void FPDF_CALLCONV FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi);
rbpotterdb764702017-01-12 10:31:43 -0800260#endif // PDFIUM_PRINT_TEXT_WITH_GDI
261
rbpotter38a01b92017-07-13 11:58:01 -0700262// Function: FPDF_SetPrintPostscriptLevel
263// Set postscript printing level when printing on Windows.
264// Experimental API.
265// Parameters:
266// postscript_level- 0 to disable postscript printing,
267// 2 to print with postscript level 2,
268// 3 to print with postscript level 3.
269// All other values are invalid.
270// Return value:
271// True if successful, false if unsuccessful (typically invalid input).
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400272FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
273FPDF_SetPrintPostscriptLevel(int postscript_level);
rbpotter38a01b92017-07-13 11:58:01 -0700274
rbpottere8468c42017-07-11 10:04:29 -0700275// Function: FPDF_SetPrintMode
276// Set printing mode when printing on Windows.
rbpotterdb764702017-01-12 10:31:43 -0800277// Experimental API.
278// Parameters:
rbpottere8468c42017-07-11 10:04:29 -0700279// mode - FPDF_PRINTMODE_EMF to output EMF (default)
280// FPDF_PRINTMODE_TEXTONLY to output text only (for charstream
281// devices)
282// FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 postscript
283// FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 postscript
rbpotterdb764702017-01-12 10:31:43 -0800284// Return value:
rbpottere8468c42017-07-11 10:04:29 -0700285// True if successful, false if unsuccessful (typically invalid input).
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400286FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SetPrintMode(int mode);
rbpotterdb764702017-01-12 10:31:43 -0800287#endif // defined(_WIN32)
thestigfdb35ff2016-07-18 13:45:44 -0700288
Tom Sepez3c3201f2015-05-20 10:20:35 -0700289// Function: FPDF_LoadDocument
290// Open and load a PDF document.
291// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400292// file_path - Path to the PDF file (including extension).
293// password - A string used as the password for the PDF file.
294// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700295// Return value:
296// A handle to the loaded document, or NULL on failure.
297// Comments:
298// Loaded document can be closed by FPDF_CloseDocument().
299// If this function fails, you can use FPDF_GetLastError() to retrieve
300// the reason why it failed.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400301FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
302FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700303
304// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700305// Open and load a PDF document from memory.
306// Parameters:
307// data_buf - Pointer to a buffer containing the PDF document.
308// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400309// password - A string used as the password for the PDF file.
310// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700311// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400312// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700313// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700314// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400315// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700316// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400317// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700318// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800319// If PDFium is built with the XFA module, the application should call
320// FPDF_LoadXFA() function after the PDF document loaded to support XFA
321// fields defined in the fpdfformfill.h file.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400322FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
323FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700324
325// Structure for custom file access.
326typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700327 // File length, in bytes.
328 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700329
Dan Sinclair49f88b72015-10-20 15:18:51 -0400330 // A function pointer for getting a block of data from a specific position.
331 // Position is specified by byte offset from the beginning of the file.
332 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700333 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400334 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700335 // Return value: should be non-zero if successful, zero for error.
336 int (*m_GetBlock)(void* param,
337 unsigned long position,
338 unsigned char* pBuf,
339 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700340
Dan Sinclair49f88b72015-10-20 15:18:51 -0400341 // A custom pointer for all implementation specific data. This pointer will
342 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700343 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700344} FPDF_FILEACCESS;
345
Tom Sepezc46d0002015-11-30 15:46:36 -0800346#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700347/**
348 * @brief Structure for file reading or writing (I/O).
349 *
350 * @note This is a handler and should be implemented by callers.
351 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700352typedef struct _FPDF_FILEHANDLER {
353 /**
354 * @brief User-defined data.
355 * @note Callers can use this field to track controls.
356 */
357 FPDF_LPVOID clientData;
358 /**
359 * @brief Callback function to release the current file stream object.
360 *
361 * @param[in] clientData Pointer to user-defined data.
362 *
363 * @return None.
364 */
365 void (*Release)(FPDF_LPVOID clientData);
366 /**
367 * @brief Callback function to retrieve the current file stream size.
368 *
369 * @param[in] clientData Pointer to user-defined data.
370 *
371 * @return Size of file stream.
372 */
373 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
374 /**
375 * @brief Callback function to read data from the current file stream.
376 *
377 * @param[in] clientData Pointer to user-defined data.
378 * @param[in] offset Offset position starts from the beginning of file
379 * stream. This parameter indicates reading position.
380 * @param[in] buffer Memory buffer to store data which are read from
381 * file stream. This parameter should not be <b>NULL</b>.
382 * @param[in] size Size of data which should be read from file
383 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
384 * should be enough to store specified data.
385 *
386 * @return 0 for success, other value for failure.
387 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500388 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
389 FPDF_DWORD offset,
390 FPDF_LPVOID buffer,
391 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700392 /**
393 * @brief Callback function to write data into the current file stream.
394 *
395 * @param[in] clientData Pointer to user-defined data.
396 * @param[in] offset Offset position starts from the beginning of file
397 * stream. This parameter indicates writing position.
398 * @param[in] buffer Memory buffer contains data which is written into
399 * file stream. This parameter should not be <b>NULL</b>.
400 * @param[in] size Size of data which should be written into file
401 * stream, in bytes.
402 *
403 * @return 0 for success, other value for failure.
404 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500405 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
406 FPDF_DWORD offset,
407 FPDF_LPCVOID buffer,
408 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700409 /**
410 * @brief Callback function to flush all internal accessing buffers.
411 *
412 * @param[in] clientData Pointer to user-defined data.
413 *
414 * @return 0 for success, other value for failure.
415 */
416 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
417 /**
418 * @brief Callback function to change file size.
419 *
420 * @details This function is called under writing mode usually. Implementer
421 * can determine whether to realize it based on application requests.
422 *
423 * @param[in] clientData Pointer to user-defined data.
424 * @param[in] size New size of file stream, in bytes.
425 *
426 * @return 0 for success, other value for failure.
427 */
428 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700429} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
430
Tom Sepezc46d0002015-11-30 15:46:36 -0800431#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700432// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700433// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700434// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400435// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700436// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700437// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400438// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700439// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400440// The application must keep the file resources valid until the PDF
441// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700442//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400443// The loaded document can be closed with FPDF_CloseDocument.
444// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800445// If PDFium is built with the XFA module, the application should call
446// FPDF_LoadXFA() function after the PDF document loaded to support XFA
447// fields defined in the fpdfformfill.h file.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400448FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700449FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700450
451// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400452// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700453// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400454// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700455// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400456// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700457// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400458// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700459// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400460// If the document was created by FPDF_CreateNewDocument,
461// then this function will always fail.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400462FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetFileVersion(FPDF_DOCUMENT doc,
463 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700464
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700465#define FPDF_ERR_SUCCESS 0 // No error.
466#define FPDF_ERR_UNKNOWN 1 // Unknown error.
467#define FPDF_ERR_FILE 2 // File not found or could not be opened.
468#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
469#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
470#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
471#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800472#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700473#define FPDF_ERR_XFALOAD 7 // Load XFA error.
474#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800475#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700476
477// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400478// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700479// Parameters:
480// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700481// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400482// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700483// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700484// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400485// function is not defined.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400486FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700487
488// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700489// Get file permission flags of the document.
490// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400491// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700492// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400493// A 32-bit integer indicating permission flags. Please refer to the
494// PDF Reference for detailed descriptions. If the document is not
495// protected, 0xffffffff will be returned.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400496FPDF_EXPORT unsigned long FPDF_CALLCONV
497FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700498
Bo Xuc5cab022014-09-19 19:16:31 -0700499// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400500// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700501// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400502// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700503// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400504// The security handler revision number. Please refer to the PDF
505// Reference for a detailed description. If the document is not
506// protected, -1 will be returned.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400507FPDF_EXPORT int FPDF_CALLCONV
508FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
Bo Xuc5cab022014-09-19 19:16:31 -0700509
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700510// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400511// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700512// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400513// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700514// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700515// Total number of pages in the document.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400516FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700517
518// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400519// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700520// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700521// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700522// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700523// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400524// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700525// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400526// The loaded page can be rendered to devices using FPDF_RenderPage.
527// The loaded page can be closed using FPDF_ClosePage.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400528FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document,
529 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700530
531// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700532// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700533// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400534// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700535// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700536// Page width (excluding non-displayable area) measured in points.
537// One point is 1/72 inch (around 0.3528 mm).
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400538FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700539
540// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700541// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700542// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400543// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700544// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700545// Page height (excluding non-displayable area) measured in points.
546// One point is 1/72 inch (around 0.3528 mm)
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400547FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700548
549// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400550// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700551// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400552// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700553// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400554// width - Pointer to a double to receive the page width
555// (in points).
556// height - Pointer to a double to receive the page height
557// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700558// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700559// Non-zero for success. 0 for error (document or page not found).
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400560FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
561 int page_index,
562 double* width,
563 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700564
Dan Sinclair49f88b72015-10-20 15:18:51 -0400565// Page rendering flags. They can be combined with bit-wise OR.
566//
567// Set if annotations are to be rendered.
568#define FPDF_ANNOT 0x01
569// Set if using text rendering optimized for LCD display.
570#define FPDF_LCD_TEXT 0x02
571// Don't use the native text output available on some platforms
572#define FPDF_NO_NATIVETEXT 0x04
573// Grayscale output.
574#define FPDF_GRAYSCALE 0x08
575// Set if you want to get some debug info.
576#define FPDF_DEBUG_INFO 0x80
577// Set if you don't want to catch exceptions.
578#define FPDF_NO_CATCH 0x100
579// Limit image cache size.
580#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
581// Always use halftone for image stretching.
582#define FPDF_RENDER_FORCEHALFTONE 0x400
583// Render for printing.
584#define FPDF_PRINTING 0x800
585// Set to disable anti-aliasing on text.
586#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
587// Set to disable anti-aliasing on images.
588#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
589// Set to disable anti-aliasing on paths.
590#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
591// Set whether to render in a reverse Byte order, this flag is only used when
592// rendering to a bitmap.
593#define FPDF_REVERSE_BYTE_ORDER 0x10
594
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700595#ifdef _WIN32
596// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400597// Render contents of a page to a device (screen, bitmap, or printer).
598// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700599// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400600// dc - Handle to the device context.
601// page - Handle to the page. Returned by FPDF_LoadPage.
602// start_x - Left pixel position of the display area in
603// device coordinates.
604// start_y - Top pixel position of the display area in device
605// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700606// size_x - Horizontal size (in pixels) for displaying the page.
607// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400608// rotate - Page orientation:
609// 0 (normal)
610// 1 (rotated 90 degrees clockwise)
611// 2 (rotated 180 degrees)
612// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700613// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400614// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700615// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700616// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400617FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc,
618 FPDF_PAGE page,
619 int start_x,
620 int start_y,
621 int size_x,
622 int size_y,
623 int rotate,
624 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700625#endif
626
627// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400628// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700629// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700630// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400631// output buffer). The bitmap handle can be created
Jane Liu28fb7ba2017-08-02 21:45:57 -0400632// by FPDFBitmap_Create or retrieved from an image
633// object by FPDFImageObj_GetBitmap.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700634// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400635// start_x - Left pixel position of the display area in
636// bitmap coordinates.
637// start_y - Top pixel position of the display area in bitmap
638// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700639// size_x - Horizontal size (in pixels) for displaying the page.
640// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400641// rotate - Page orientation:
642// 0 (normal)
643// 1 (rotated 90 degrees clockwise)
644// 2 (rotated 180 degrees)
645// 3 (rotated 90 degrees counter-clockwise)
thestiga78ba602016-11-23 15:25:48 -0800646// flags - 0 for normal display, or combination of the Page
647// Rendering flags defined above. With the FPDF_ANNOT
648// flag, it renders all annotations that do not require
649// user-interaction, which are all annotations except
650// widget and popup annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700651// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700652// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400653FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
654 FPDF_PAGE page,
655 int start_x,
656 int start_y,
657 int size_x,
658 int size_y,
659 int rotate,
660 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700661
thestiga78ba602016-11-23 15:25:48 -0800662// Function: FPDF_RenderPageBitmapWithMatrix
663// Render contents of a page to a device independent bitmap.
664// Parameters:
665// bitmap - Handle to the device independent bitmap (as the
666// output buffer). The bitmap handle can be created
Jane Liu28fb7ba2017-08-02 21:45:57 -0400667// by FPDFBitmap_Create or retrieved by
668// FPDFImageObj_GetBitmap.
thestiga78ba602016-11-23 15:25:48 -0800669// page - Handle to the page. Returned by FPDF_LoadPage
Nicolas Pena24b07332017-09-13 18:02:11 -0400670// matrix - The transform matrix. It must be invertible.
thestiga78ba602016-11-23 15:25:48 -0800671// clipping - The rect to clip to.
672// flags - 0 for normal display, or combination of the Page
673// Rendering flags defined above. With the FPDF_ANNOT
674// flag, it renders all annotations that do not require
675// user-interaction, which are all annotations except
676// widget and popup annotations.
677// Return value:
Nicolas Pena24b07332017-09-13 18:02:11 -0400678// None. Note that behavior is undefined if det of |matrix| is 0.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400679FPDF_EXPORT void FPDF_CALLCONV
680FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
681 FPDF_PAGE page,
682 const FS_MATRIX* matrix,
683 const FS_RECTF* clipping,
684 int flags);
thestiga78ba602016-11-23 15:25:48 -0800685
Cary Clark399be5b2016-03-14 16:51:29 -0400686#ifdef _SKIA_SUPPORT_
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400687FPDF_EXPORT FPDF_RECORDER FPDF_CALLCONV FPDF_RenderPageSkp(FPDF_PAGE page,
688 int size_x,
689 int size_y);
Cary Clark399be5b2016-03-14 16:51:29 -0400690#endif
691
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700692// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700693// Close a loaded PDF page.
694// Parameters:
695// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700696// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700697// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400698FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700699
700// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700701// Close a loaded PDF document.
702// Parameters:
703// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700704// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700705// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400706FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700707
708// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400709// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700710// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400711// page - Handle to the page. Returned by FPDF_LoadPage.
712// start_x - Left pixel position of the display area in
713// device coordinates.
714// start_y - Top pixel position of the display area in device
715// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700716// size_x - Horizontal size (in pixels) for displaying the page.
717// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400718// rotate - Page orientation:
719// 0 (normal)
720// 1 (rotated 90 degrees clockwise)
721// 2 (rotated 180 degrees)
722// 3 (rotated 90 degrees counter-clockwise)
723// device_x - X value in device coordinates to be converted.
724// device_y - Y value in device coordinates to be converted.
725// page_x - A pointer to a double receiving the converted X
726// value in page coordinates.
727// page_y - A pointer to a double receiving the converted Y
728// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700729// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700730// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700731// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400732// The page coordinate system has its origin at the left-bottom corner
733// of the page, with the X-axis on the bottom going to the right, and
734// the Y-axis on the left side going up.
735//
736// NOTE: this coordinate system can be altered when you zoom, scroll,
737// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700738// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700739//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700740// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400741// its origin is at the left-top corner of the window. However this
742// origin can be altered by the Windows coordinate transformation
743// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700744//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400745// You must make sure the start_x, start_y, size_x, size_y
746// and rotate parameters have exactly same values as you used in
747// the FPDF_RenderPage() function call.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400748FPDF_EXPORT void FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page,
749 int start_x,
750 int start_y,
751 int size_x,
752 int size_y,
753 int rotate,
754 int device_x,
755 int device_y,
756 double* page_x,
757 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700758
759// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400760// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700761// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400762// page - Handle to the page. Returned by FPDF_LoadPage.
763// start_x - Left pixel position of the display area in
764// device coordinates.
765// start_y - Top pixel position of the display area in device
766// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700767// size_x - Horizontal size (in pixels) for displaying the page.
768// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400769// rotate - Page orientation:
770// 0 (normal)
771// 1 (rotated 90 degrees clockwise)
772// 2 (rotated 180 degrees)
773// 3 (rotated 90 degrees counter-clockwise)
774// page_x - X value in page coordinates.
775// page_y - Y value in page coordinate.
776// device_x - A pointer to an integer receiving the result X
777// value in device coordinates.
778// device_y - A pointer to an integer receiving the result Y
779// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700780// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700781// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700782// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400783// See comments for FPDF_DeviceToPage().
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400784FPDF_EXPORT void FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page,
785 int start_x,
786 int start_y,
787 int size_x,
788 int size_y,
789 int rotate,
790 double page_x,
791 double page_y,
792 int* device_x,
793 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700794
795// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400796// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700797// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400798// width - The number of pixels in width for the bitmap.
799// Must be greater than 0.
800// height - The number of pixels in height for the bitmap.
801// Must be greater than 0.
802// alpha - A flag indicating whether the alpha channel is used.
803// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700804// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400805// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700806// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700807// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400808// The bitmap always uses 4 bytes per pixel. The first byte is always
809// double word aligned.
810//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700811// The byte order is BGRx (the last byte unused if no alpha channel) or
812// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700813//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400814// The pixels in a horizontal line are stored side by side, with the
815// left most pixel stored first (with lower memory address).
816// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700817//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400818// Lines are stored one after another, with the top most line stored
819// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700820//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700821// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400822// bitmap, but it doesn't initialize the buffer. Applications can use
823// FPDFBitmap_FillRect to fill the bitmap using any color.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400824FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width,
825 int height,
826 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700827
828// More DIB formats
Jane Liu28fb7ba2017-08-02 21:45:57 -0400829// Unknown or unsupported format.
830#define FPDFBitmap_Unknown 0
Dan Sinclair49f88b72015-10-20 15:18:51 -0400831// Gray scale bitmap, one byte per pixel.
832#define FPDFBitmap_Gray 1
833// 3 bytes per pixel, byte order: blue, green, red.
834#define FPDFBitmap_BGR 2
835// 4 bytes per pixel, byte order: blue, green, red, unused.
836#define FPDFBitmap_BGRx 3
837// 4 bytes per pixel, byte order: blue, green, red, alpha.
838#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700839
840// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400841// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700842// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400843// width - The number of pixels in width for the bitmap.
844// Must be greater than 0.
845// height - The number of pixels in height for the bitmap.
846// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700847// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400848// above.
849// first_scan - A pointer to the first byte of the first line if
850// using an external buffer. If this parameter is NULL,
851// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700852// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400853// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700854// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400855// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700856// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400857// Similar to FPDFBitmap_Create function, but allows for more formats
858// and an external buffer is supported. The bitmap created by this
859// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700860// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700861//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400862// If an external buffer is used, then the application should destroy
863// the buffer by itself. FPDFBitmap_Destroy function will not destroy
864// the buffer.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400865FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
866 int height,
867 int format,
868 void* first_scan,
869 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700870
Jane Liu28fb7ba2017-08-02 21:45:57 -0400871// Function: FPDFBitmap_GetFormat
872// Get the format of the bitmap.
873// Parameters:
874// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
875// or FPDFImageObj_GetBitmap.
876// Return value:
877// The format of the bitmap.
878// Comments:
879// Only formats supported by FPDFBitmap_CreateEx are supported by this
880// function; see the list of such formats above.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400881FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
Jane Liu28fb7ba2017-08-02 21:45:57 -0400882
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700883// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400884// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700885// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700886// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400887// FPDFBitmap_Create.
888// left - The left position. Starting from 0 at the
889// left-most pixel.
890// top - The top position. Starting from 0 at the
891// top-most line.
892// width - Width in pixels to be filled.
893// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700894// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400895// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700896// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700897// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700898// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400899// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700900// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700901//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400902// NOTE: If the alpha channel is used, this function does NOT
903// composite the background with the source color, instead the
904// background will be replaced by the source color and the alpha.
905//
906// If the alpha channel is not used, the alpha parameter is ignored.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400907FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
908 int left,
909 int top,
910 int width,
911 int height,
912 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700913
914// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400915// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700916// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400917// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
918// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700919// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700920// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700921// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700922// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400923//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700924// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400925// then manipulate any color and/or alpha values for any pixels in the
926// bitmap.
927//
928// The data is in BGRA format. Where the A maybe unused if alpha was
929// not specified.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400930FPDF_EXPORT void* FPDF_CALLCONV FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700931
932// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400933// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700934// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400935// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
936// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700937// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400938// The width of the bitmap in pixels.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400939FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700940
941// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400942// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700943// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400944// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
945// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700946// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400947// The height of the bitmap in pixels.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400948FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700949
950// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400951// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700952// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400953// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
954// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700955// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400956// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700957// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400958// The stride may be more than width * number of bytes per pixel.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400959FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700960
961// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400962// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700963// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400964// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
965// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700966// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700967// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700968// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400969// This function will not destroy any external buffers provided when
970// the bitmap was created.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400971FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700972
973// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700974// Whether the PDF document prefers to be scaled or not.
975// Parameters:
976// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700977// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700978// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400979FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700980FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700981
Bo Xu9114e832014-07-14 13:22:47 -0700982// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700983// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700984// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700985// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700986// Return value:
987// The number of copies to be printed.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400988FPDF_EXPORT int FPDF_CALLCONV
989FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700990
991// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700992// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700993// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700994// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700995// Return value:
996// The print page range to be used for printing.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400997FPDF_EXPORT FPDF_PAGERANGE FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700998FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700999
1000// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001001// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -04001002// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -07001003// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001004// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -07001005// Return value:
1006// The paper handling option to be used when printing.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001007FPDF_EXPORT FPDF_DUPLEXTYPE FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001008FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -07001009
thestig04bebfe2016-11-04 16:07:25 -07001010// Function: FPDF_VIEWERREF_GetName
1011// Gets the contents for a viewer ref, with a given key. The value must
1012// be of type "name".
1013// Parameters:
1014// document - Handle to the loaded document.
Lei Zhangba14c0a2017-09-22 16:43:01 -07001015// key - Name of the key in the viewer pref dictionary,
1016// encoded in UTF-8.
thestig04bebfe2016-11-04 16:07:25 -07001017// buffer - A string to write the contents of the key to.
1018// length - Length of the buffer.
1019// Return value:
1020// The number of bytes in the contents, including the NULL terminator.
1021// Thus if the return value is 0, then that indicates an error, such
1022// as when |document| is invalid or |buffer| is NULL. If |length| is
1023// less than the returned length, or |buffer| is NULL, |buffer| will
1024// not be modified.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001025FPDF_EXPORT unsigned long FPDF_CALLCONV
1026FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
1027 FPDF_BYTESTRING key,
1028 char* buffer,
1029 unsigned long length);
thestig04bebfe2016-11-04 16:07:25 -07001030
Bo Xu4d62b6b2015-01-10 22:52:59 -08001031// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -07001032// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001033// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001034// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -08001035// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -07001036// The count of named destinations.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001037FPDF_EXPORT FPDF_DWORD FPDF_CALLCONV
1038FPDF_CountNamedDests(FPDF_DOCUMENT document);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001039
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001040// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -04001041// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -07001042// Parameters:
1043// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -04001044// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001045// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001046// The handle to the destination.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001047FPDF_EXPORT FPDF_DEST FPDF_CALLCONV
1048FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001049
Bo Xu4d62b6b2015-01-10 22:52:59 -08001050// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -04001051// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001052// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001053// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -04001054// index - The index of a named destination.
1055// buffer - The buffer to store the destination name,
1056// used as wchar_t*.
1057// buflen [in/out] - Size of the buffer in bytes on input,
1058// length of the result in bytes on output
1059// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001060// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001061// The destination handle for a given index, or NULL if there is no
1062// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001063// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -07001064// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001065// 1) First time pass in |buffer| as NULL and get buflen.
1066// 2) Second time pass in allocated |buffer| and buflen to retrieve
1067// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001068//
Dan Sinclair49f88b72015-10-20 15:18:51 -04001069// If buflen is not sufficiently large, it will be set to -1 upon
1070// return.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001071FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document,
1072 int index,
1073 void* buffer,
1074 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001075
Tom Sepezc46d0002015-11-30 15:46:36 -08001076#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -07001077// Function: FPDF_BStr_Init
1078// Helper function to initialize a byte string.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001079FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* str);
Bo Xufdc00a72014-10-28 23:03:33 -07001080
Tom Sepez9857e202015-05-13 17:09:26 -07001081// Function: FPDF_BStr_Set
1082// Helper function to set string data.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001083FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Set(FPDF_BSTR* str,
1084 FPDF_LPCSTR bstr,
1085 int length);
Bo Xufdc00a72014-10-28 23:03:33 -07001086
Tom Sepez9857e202015-05-13 17:09:26 -07001087// Function: FPDF_BStr_Clear
1088// Helper function to clear a byte string.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001089FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -08001090#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -07001091
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001092#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -07001093}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001094#endif
1095
Tom Sepez9857e202015-05-13 17:09:26 -07001096#endif // PUBLIC_FPDFVIEW_H_