blob: 135d00a8f4cf5805577f019e04f24620ff499833 [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;
55
56#ifdef PDF_ENABLE_XFA
57typedef void* FPDF_STRINGHANDLE;
58typedef void* FPDF_WIDGET;
59#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070060
61// Basic data types
Tom Sepez9857e202015-05-13 17:09:26 -070062typedef int FPDF_BOOL;
63typedef int FPDF_ERROR;
64typedef unsigned long FPDF_DWORD;
65typedef float FS_FLOAT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070066
Tom Sepezc46d0002015-11-30 15:46:36 -080067#ifdef PDF_ENABLE_XFA
68typedef void* FPDF_LPVOID;
69typedef void const* FPDF_LPCVOID;
70typedef char const* FPDF_LPCSTR;
71typedef int FPDF_RESULT;
72#endif
73
Bo Xu9114e832014-07-14 13:22:47 -070074// Duplex types
75typedef enum _FPDF_DUPLEXTYPE_ {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070076 DuplexUndefined = 0,
77 Simplex,
78 DuplexFlipShortEdge,
79 DuplexFlipLongEdge
Bo Xu9114e832014-07-14 13:22:47 -070080} FPDF_DUPLEXTYPE;
81
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070082// String types
Tom Sepez9857e202015-05-13 17:09:26 -070083typedef unsigned short FPDF_WCHAR;
84typedef unsigned char const* FPDF_LPCBYTE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070085
Nico Weber9d8ec5a2015-08-04 13:00:21 -070086// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
87// encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070088typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070089
Dan Sinclair49f88b72015-10-20 15:18:51 -040090// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
91// bytes (except surrogation), with the low byte first.
92typedef const unsigned short* FPDF_WIDESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070093
Tom Sepezc46d0002015-11-30 15:46:36 -080094#ifdef PDF_ENABLE_XFA
Dan Sinclair49f88b72015-10-20 15:18:51 -040095// Structure for a byte string.
96// Note, a byte string commonly means a UTF-16LE formated string.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070097typedef struct _FPDF_BSTR {
Dan Sinclair49f88b72015-10-20 15:18:51 -040098 // String buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070099 char* str;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400100 // Length of the string, in bytes.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700101 int len;
Bo Xufdc00a72014-10-28 23:03:33 -0700102} FPDF_BSTR;
Tom Sepezc46d0002015-11-30 15:46:36 -0800103#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700104
Dan Sinclair49f88b72015-10-20 15:18:51 -0400105// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
106// Windows unicode string, however, special care needs to be taken if you
107// expect to process Unicode larger than 0xffff.
108//
109// For Linux/Unix programmers: most compiler/library environments use 4 bytes
110// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
111// system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700112typedef const char* FPDF_STRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113
Dan Sinclair49f88b72015-10-20 15:18:51 -0400114// Matrix for transformation.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700115typedef struct _FS_MATRIX_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400116 float a;
117 float b;
118 float c;
119 float d;
120 float e;
121 float f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700122} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700123
Dan Sinclair49f88b72015-10-20 15:18:51 -0400124// Rectangle area(float) in device or page coordinate system.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700125typedef struct _FS_RECTF_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400126 // The x-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700127 float left;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400128 // The y-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700129 float top;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400130 // The x-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700131 float right;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400132 // The y-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700133 float bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700134} * FS_LPRECTF, FS_RECTF;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400135
136// Const Pointer to FS_RECTF structure.
Tom Sepez9857e202015-05-13 17:09:26 -0700137typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700138
Jane Liu4fd9a472017-06-01 18:56:09 -0400139// Annotation subtype.
140typedef int FPDF_ANNOTATION_SUBTYPE;
141
Jane Liu2e1a32b2017-07-06 12:01:25 -0400142// Dictionary value types.
143typedef int FPDF_OBJECT_TYPE;
144
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000145#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
146// On Windows system, functions are exported in a DLL
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400147#define FPDF_EXPORT __declspec(dllexport)
148#define FPDF_CALLCONV __stdcall
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700149#else
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400150#define FPDF_EXPORT
151#define FPDF_CALLCONV
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700152#endif
153
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700154// Exported Functions
155#ifdef __cplusplus
156extern "C" {
157#endif
158
159// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700160// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700161// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700162// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700163// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700164// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700165// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700166// Convenience function to call FPDF_InitLibraryWithConfig() for
167// backwards comatibility purposes.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400168FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibrary();
Lei Zhang6f62d532015-09-23 15:31:44 -0700169
Dan Sinclair49f88b72015-10-20 15:18:51 -0400170// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700171typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700172 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700173 int version;
174
175 // Array of paths to scan in place of the defaults when using built-in
176 // FXGE font loading code. The array is terminated by a NULL pointer.
177 // The Array may be NULL itself to use the default paths. May be ignored
178 // entirely depending upon the platform.
179 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700180
181 // Version 2.
182
183 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
184 void* m_pIsolate;
185
186 // The embedder data slot to use in the v8::Isolate to store PDFium's
187 // per-isolate data. The value needs to be between 0 and
188 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
189 // for most embedders.
190 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700191} FPDF_LIBRARY_CONFIG;
192
193// Function: FPDF_InitLibraryWithConfig
194// Initialize the FPDFSDK library
195// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400196// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700197// Return value:
198// None.
199// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700200// You have to call this function before you can call any PDF
201// processing functions.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400202FPDF_EXPORT void FPDF_CALLCONV
203FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700204
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700205// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700206// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700207// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700208// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700209// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700210// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700211// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700212// You can call this function to release all memory blocks allocated by
213// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400214// After this function is called, you should not call any PDF
215// processing functions.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400216FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700217
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700218// Policy for accessing the local machine time.
219#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700220
221// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700222// Set the policy for the sandbox environment.
223// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400224// policy - The specified policy for setting, for example:
225// FPDF_POLICY_MACHINETIME_ACCESS.
226// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700227// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700228// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400229FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
230 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700231
rbpotterdb764702017-01-12 10:31:43 -0800232#if defined(_WIN32)
233#if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
thestigfdb35ff2016-07-18 13:45:44 -0700234// Pointer to a helper function to make |font| with |text| of |text_length|
235// accessible when printing text with GDI. This is useful in sandboxed
236// environments where PDFium's access to GDI may be restricted.
237typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
238 const wchar_t* text,
239 size_t text_length);
240
241// Function: FPDF_SetTypefaceAccessibleFunc
242// Set the function pointer that makes GDI fonts available in sandboxed
243// environments. Experimental API.
244// Parameters:
245// func - A function pointer. See description above.
246// Return value:
247// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400248FPDF_EXPORT void FPDF_CALLCONV
thestigfdb35ff2016-07-18 13:45:44 -0700249FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func);
250
251// Function: FPDF_SetPrintTextWithGDI
252// Set whether to use GDI to draw fonts when printing on Windows.
253// Experimental API.
254// Parameters:
255// use_gdi - Set to true to enable printing text with GDI.
256// Return value:
257// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400258FPDF_EXPORT void FPDF_CALLCONV FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi);
rbpotterdb764702017-01-12 10:31:43 -0800259#endif // PDFIUM_PRINT_TEXT_WITH_GDI
260
rbpotter38a01b92017-07-13 11:58:01 -0700261// Function: FPDF_SetPrintPostscriptLevel
262// Set postscript printing level when printing on Windows.
263// Experimental API.
264// Parameters:
265// postscript_level- 0 to disable postscript printing,
266// 2 to print with postscript level 2,
267// 3 to print with postscript level 3.
268// All other values are invalid.
269// Return value:
270// True if successful, false if unsuccessful (typically invalid input).
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400271FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
272FPDF_SetPrintPostscriptLevel(int postscript_level);
rbpotter38a01b92017-07-13 11:58:01 -0700273
rbpottere8468c42017-07-11 10:04:29 -0700274// Function: FPDF_SetPrintMode
275// Set printing mode when printing on Windows.
rbpotterdb764702017-01-12 10:31:43 -0800276// Experimental API.
277// Parameters:
rbpottere8468c42017-07-11 10:04:29 -0700278// mode - FPDF_PRINTMODE_EMF to output EMF (default)
279// FPDF_PRINTMODE_TEXTONLY to output text only (for charstream
280// devices)
281// FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 postscript
282// FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 postscript
rbpotterdb764702017-01-12 10:31:43 -0800283// Return value:
rbpottere8468c42017-07-11 10:04:29 -0700284// True if successful, false if unsuccessful (typically invalid input).
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400285FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SetPrintMode(int mode);
rbpotterdb764702017-01-12 10:31:43 -0800286#endif // defined(_WIN32)
thestigfdb35ff2016-07-18 13:45:44 -0700287
Tom Sepez3c3201f2015-05-20 10:20:35 -0700288// Function: FPDF_LoadDocument
289// Open and load a PDF document.
290// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400291// file_path - Path to the PDF file (including extension).
292// password - A string used as the password for the PDF file.
293// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700294// Return value:
295// A handle to the loaded document, or NULL on failure.
296// Comments:
297// Loaded document can be closed by FPDF_CloseDocument().
298// If this function fails, you can use FPDF_GetLastError() to retrieve
299// the reason why it failed.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400300FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
301FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700302
303// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700304// Open and load a PDF document from memory.
305// Parameters:
306// data_buf - Pointer to a buffer containing the PDF document.
307// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400308// password - A string used as the password for the PDF file.
309// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700310// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400311// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700312// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700313// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400314// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700315// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400316// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700317// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800318// If PDFium is built with the XFA module, the application should call
319// FPDF_LoadXFA() function after the PDF document loaded to support XFA
320// fields defined in the fpdfformfill.h file.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400321FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
322FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700323
324// Structure for custom file access.
325typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700326 // File length, in bytes.
327 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700328
Dan Sinclair49f88b72015-10-20 15:18:51 -0400329 // A function pointer for getting a block of data from a specific position.
330 // Position is specified by byte offset from the beginning of the file.
331 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700332 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400333 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700334 // Return value: should be non-zero if successful, zero for error.
335 int (*m_GetBlock)(void* param,
336 unsigned long position,
337 unsigned char* pBuf,
338 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700339
Dan Sinclair49f88b72015-10-20 15:18:51 -0400340 // A custom pointer for all implementation specific data. This pointer will
341 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700342 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700343} FPDF_FILEACCESS;
344
Tom Sepezc46d0002015-11-30 15:46:36 -0800345#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700346/**
347 * @brief Structure for file reading or writing (I/O).
348 *
349 * @note This is a handler and should be implemented by callers.
350 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700351typedef struct _FPDF_FILEHANDLER {
352 /**
353 * @brief User-defined data.
354 * @note Callers can use this field to track controls.
355 */
356 FPDF_LPVOID clientData;
357 /**
358 * @brief Callback function to release the current file stream object.
359 *
360 * @param[in] clientData Pointer to user-defined data.
361 *
362 * @return None.
363 */
364 void (*Release)(FPDF_LPVOID clientData);
365 /**
366 * @brief Callback function to retrieve the current file stream size.
367 *
368 * @param[in] clientData Pointer to user-defined data.
369 *
370 * @return Size of file stream.
371 */
372 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
373 /**
374 * @brief Callback function to read data from the current file stream.
375 *
376 * @param[in] clientData Pointer to user-defined data.
377 * @param[in] offset Offset position starts from the beginning of file
378 * stream. This parameter indicates reading position.
379 * @param[in] buffer Memory buffer to store data which are read from
380 * file stream. This parameter should not be <b>NULL</b>.
381 * @param[in] size Size of data which should be read from file
382 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
383 * should be enough to store specified data.
384 *
385 * @return 0 for success, other value for failure.
386 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500387 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
388 FPDF_DWORD offset,
389 FPDF_LPVOID buffer,
390 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700391 /**
392 * @brief Callback function to write data into the current file stream.
393 *
394 * @param[in] clientData Pointer to user-defined data.
395 * @param[in] offset Offset position starts from the beginning of file
396 * stream. This parameter indicates writing position.
397 * @param[in] buffer Memory buffer contains data which is written into
398 * file stream. This parameter should not be <b>NULL</b>.
399 * @param[in] size Size of data which should be written into file
400 * stream, in bytes.
401 *
402 * @return 0 for success, other value for failure.
403 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500404 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
405 FPDF_DWORD offset,
406 FPDF_LPCVOID buffer,
407 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700408 /**
409 * @brief Callback function to flush all internal accessing buffers.
410 *
411 * @param[in] clientData Pointer to user-defined data.
412 *
413 * @return 0 for success, other value for failure.
414 */
415 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
416 /**
417 * @brief Callback function to change file size.
418 *
419 * @details This function is called under writing mode usually. Implementer
420 * can determine whether to realize it based on application requests.
421 *
422 * @param[in] clientData Pointer to user-defined data.
423 * @param[in] size New size of file stream, in bytes.
424 *
425 * @return 0 for success, other value for failure.
426 */
427 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700428} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
429
Tom Sepezc46d0002015-11-30 15:46:36 -0800430#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700431// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700432// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700433// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400434// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700435// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700436// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400437// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700438// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400439// The application must keep the file resources valid until the PDF
440// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700441//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400442// The loaded document can be closed with FPDF_CloseDocument.
443// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800444// If PDFium is built with the XFA module, the application should call
445// FPDF_LoadXFA() function after the PDF document loaded to support XFA
446// fields defined in the fpdfformfill.h file.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400447FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700448FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700449
450// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400451// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700452// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400453// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700454// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400455// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700456// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400457// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700458// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400459// If the document was created by FPDF_CreateNewDocument,
460// then this function will always fail.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400461FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetFileVersion(FPDF_DOCUMENT doc,
462 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700463
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700464#define FPDF_ERR_SUCCESS 0 // No error.
465#define FPDF_ERR_UNKNOWN 1 // Unknown error.
466#define FPDF_ERR_FILE 2 // File not found or could not be opened.
467#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
468#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
469#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
470#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800471#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700472#define FPDF_ERR_XFALOAD 7 // Load XFA error.
473#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800474#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700475
476// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400477// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700478// Parameters:
479// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700480// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400481// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700482// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700483// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400484// function is not defined.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400485FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700486
487// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700488// Get file permission flags of the document.
489// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400490// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700491// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400492// A 32-bit integer indicating permission flags. Please refer to the
493// PDF Reference for detailed descriptions. If the document is not
494// protected, 0xffffffff will be returned.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400495FPDF_EXPORT unsigned long FPDF_CALLCONV
496FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700497
Bo Xuc5cab022014-09-19 19:16:31 -0700498// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400499// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700500// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400501// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700502// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400503// The security handler revision number. Please refer to the PDF
504// Reference for a detailed description. If the document is not
505// protected, -1 will be returned.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400506FPDF_EXPORT int FPDF_CALLCONV
507FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
Bo Xuc5cab022014-09-19 19:16:31 -0700508
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700509// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400510// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700511// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400512// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700513// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700514// Total number of pages in the document.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400515FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700516
517// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400518// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700519// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700520// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700521// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700522// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400523// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700524// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400525// The loaded page can be rendered to devices using FPDF_RenderPage.
526// The loaded page can be closed using FPDF_ClosePage.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400527FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document,
528 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700529
530// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700531// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700532// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400533// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700534// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700535// Page width (excluding non-displayable area) measured in points.
536// One point is 1/72 inch (around 0.3528 mm).
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400537FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700538
539// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700540// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700541// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400542// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700543// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700544// Page height (excluding non-displayable area) measured in points.
545// One point is 1/72 inch (around 0.3528 mm)
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400546FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700547
548// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400549// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700550// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400551// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700552// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400553// width - Pointer to a double to receive the page width
554// (in points).
555// height - Pointer to a double to receive the page height
556// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700557// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700558// Non-zero for success. 0 for error (document or page not found).
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400559FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
560 int page_index,
561 double* width,
562 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700563
Dan Sinclair49f88b72015-10-20 15:18:51 -0400564// Page rendering flags. They can be combined with bit-wise OR.
565//
566// Set if annotations are to be rendered.
567#define FPDF_ANNOT 0x01
568// Set if using text rendering optimized for LCD display.
569#define FPDF_LCD_TEXT 0x02
570// Don't use the native text output available on some platforms
571#define FPDF_NO_NATIVETEXT 0x04
572// Grayscale output.
573#define FPDF_GRAYSCALE 0x08
574// Set if you want to get some debug info.
575#define FPDF_DEBUG_INFO 0x80
576// Set if you don't want to catch exceptions.
577#define FPDF_NO_CATCH 0x100
578// Limit image cache size.
579#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
580// Always use halftone for image stretching.
581#define FPDF_RENDER_FORCEHALFTONE 0x400
582// Render for printing.
583#define FPDF_PRINTING 0x800
584// Set to disable anti-aliasing on text.
585#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
586// Set to disable anti-aliasing on images.
587#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
588// Set to disable anti-aliasing on paths.
589#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
590// Set whether to render in a reverse Byte order, this flag is only used when
591// rendering to a bitmap.
592#define FPDF_REVERSE_BYTE_ORDER 0x10
593
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700594#ifdef _WIN32
595// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400596// Render contents of a page to a device (screen, bitmap, or printer).
597// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700598// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400599// dc - Handle to the device context.
600// page - Handle to the page. Returned by FPDF_LoadPage.
601// start_x - Left pixel position of the display area in
602// device coordinates.
603// start_y - Top pixel position of the display area in device
604// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700605// size_x - Horizontal size (in pixels) for displaying the page.
606// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400607// rotate - Page orientation:
608// 0 (normal)
609// 1 (rotated 90 degrees clockwise)
610// 2 (rotated 180 degrees)
611// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700612// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400613// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700614// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700615// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400616FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc,
617 FPDF_PAGE page,
618 int start_x,
619 int start_y,
620 int size_x,
621 int size_y,
622 int rotate,
623 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700624#endif
625
626// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400627// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700628// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700629// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400630// output buffer). The bitmap handle can be created
Jane Liu28fb7ba2017-08-02 21:45:57 -0400631// by FPDFBitmap_Create or retrieved from an image
632// object by FPDFImageObj_GetBitmap.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700633// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400634// start_x - Left pixel position of the display area in
635// bitmap coordinates.
636// start_y - Top pixel position of the display area in bitmap
637// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700638// size_x - Horizontal size (in pixels) for displaying the page.
639// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400640// rotate - Page orientation:
641// 0 (normal)
642// 1 (rotated 90 degrees clockwise)
643// 2 (rotated 180 degrees)
644// 3 (rotated 90 degrees counter-clockwise)
thestiga78ba602016-11-23 15:25:48 -0800645// flags - 0 for normal display, or combination of the Page
646// Rendering flags defined above. With the FPDF_ANNOT
647// flag, it renders all annotations that do not require
648// user-interaction, which are all annotations except
649// widget and popup annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700650// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700651// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400652FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
653 FPDF_PAGE page,
654 int start_x,
655 int start_y,
656 int size_x,
657 int size_y,
658 int rotate,
659 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700660
thestiga78ba602016-11-23 15:25:48 -0800661// Function: FPDF_RenderPageBitmapWithMatrix
662// Render contents of a page to a device independent bitmap.
663// Parameters:
664// bitmap - Handle to the device independent bitmap (as the
665// output buffer). The bitmap handle can be created
Jane Liu28fb7ba2017-08-02 21:45:57 -0400666// by FPDFBitmap_Create or retrieved by
667// FPDFImageObj_GetBitmap.
thestiga78ba602016-11-23 15:25:48 -0800668// page - Handle to the page. Returned by FPDF_LoadPage
Nicolas Pena24b07332017-09-13 18:02:11 -0400669// matrix - The transform matrix. It must be invertible.
thestiga78ba602016-11-23 15:25:48 -0800670// clipping - The rect to clip to.
671// flags - 0 for normal display, or combination of the Page
672// Rendering flags defined above. With the FPDF_ANNOT
673// flag, it renders all annotations that do not require
674// user-interaction, which are all annotations except
675// widget and popup annotations.
676// Return value:
Nicolas Pena24b07332017-09-13 18:02:11 -0400677// None. Note that behavior is undefined if det of |matrix| is 0.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400678FPDF_EXPORT void FPDF_CALLCONV
679FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
680 FPDF_PAGE page,
681 const FS_MATRIX* matrix,
682 const FS_RECTF* clipping,
683 int flags);
thestiga78ba602016-11-23 15:25:48 -0800684
Cary Clark399be5b2016-03-14 16:51:29 -0400685#ifdef _SKIA_SUPPORT_
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400686FPDF_EXPORT FPDF_RECORDER FPDF_CALLCONV FPDF_RenderPageSkp(FPDF_PAGE page,
687 int size_x,
688 int size_y);
Cary Clark399be5b2016-03-14 16:51:29 -0400689#endif
690
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700691// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700692// Close a loaded PDF page.
693// Parameters:
694// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700695// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700696// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400697FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700698
699// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700700// Close a loaded PDF document.
701// Parameters:
702// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700703// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700704// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400705FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700706
707// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400708// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700709// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400710// page - Handle to the page. Returned by FPDF_LoadPage.
711// start_x - Left pixel position of the display area in
712// device coordinates.
713// start_y - Top pixel position of the display area in device
714// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700715// size_x - Horizontal size (in pixels) for displaying the page.
716// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400717// rotate - Page orientation:
718// 0 (normal)
719// 1 (rotated 90 degrees clockwise)
720// 2 (rotated 180 degrees)
721// 3 (rotated 90 degrees counter-clockwise)
722// device_x - X value in device coordinates to be converted.
723// device_y - Y value in device coordinates to be converted.
724// page_x - A pointer to a double receiving the converted X
725// value in page coordinates.
726// page_y - A pointer to a double receiving the converted Y
727// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700728// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700729// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700730// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400731// The page coordinate system has its origin at the left-bottom corner
732// of the page, with the X-axis on the bottom going to the right, and
733// the Y-axis on the left side going up.
734//
735// NOTE: this coordinate system can be altered when you zoom, scroll,
736// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700737// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700738//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700739// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400740// its origin is at the left-top corner of the window. However this
741// origin can be altered by the Windows coordinate transformation
742// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700743//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400744// You must make sure the start_x, start_y, size_x, size_y
745// and rotate parameters have exactly same values as you used in
746// the FPDF_RenderPage() function call.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400747FPDF_EXPORT void FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page,
748 int start_x,
749 int start_y,
750 int size_x,
751 int size_y,
752 int rotate,
753 int device_x,
754 int device_y,
755 double* page_x,
756 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700757
758// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400759// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700760// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400761// page - Handle to the page. Returned by FPDF_LoadPage.
762// start_x - Left pixel position of the display area in
763// device coordinates.
764// start_y - Top pixel position of the display area in device
765// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700766// size_x - Horizontal size (in pixels) for displaying the page.
767// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400768// rotate - Page orientation:
769// 0 (normal)
770// 1 (rotated 90 degrees clockwise)
771// 2 (rotated 180 degrees)
772// 3 (rotated 90 degrees counter-clockwise)
773// page_x - X value in page coordinates.
774// page_y - Y value in page coordinate.
775// device_x - A pointer to an integer receiving the result X
776// value in device coordinates.
777// device_y - A pointer to an integer receiving the result Y
778// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700779// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700780// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700781// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400782// See comments for FPDF_DeviceToPage().
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400783FPDF_EXPORT void FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page,
784 int start_x,
785 int start_y,
786 int size_x,
787 int size_y,
788 int rotate,
789 double page_x,
790 double page_y,
791 int* device_x,
792 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700793
794// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400795// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700796// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400797// width - The number of pixels in width for the bitmap.
798// Must be greater than 0.
799// height - The number of pixels in height for the bitmap.
800// Must be greater than 0.
801// alpha - A flag indicating whether the alpha channel is used.
802// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700803// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400804// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700805// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700806// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400807// The bitmap always uses 4 bytes per pixel. The first byte is always
808// double word aligned.
809//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700810// The byte order is BGRx (the last byte unused if no alpha channel) or
811// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700812//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400813// The pixels in a horizontal line are stored side by side, with the
814// left most pixel stored first (with lower memory address).
815// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700816//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400817// Lines are stored one after another, with the top most line stored
818// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700819//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700820// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400821// bitmap, but it doesn't initialize the buffer. Applications can use
822// FPDFBitmap_FillRect to fill the bitmap using any color.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400823FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width,
824 int height,
825 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700826
827// More DIB formats
Jane Liu28fb7ba2017-08-02 21:45:57 -0400828// Unknown or unsupported format.
829#define FPDFBitmap_Unknown 0
Dan Sinclair49f88b72015-10-20 15:18:51 -0400830// Gray scale bitmap, one byte per pixel.
831#define FPDFBitmap_Gray 1
832// 3 bytes per pixel, byte order: blue, green, red.
833#define FPDFBitmap_BGR 2
834// 4 bytes per pixel, byte order: blue, green, red, unused.
835#define FPDFBitmap_BGRx 3
836// 4 bytes per pixel, byte order: blue, green, red, alpha.
837#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700838
839// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400840// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700841// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400842// width - The number of pixels in width for the bitmap.
843// Must be greater than 0.
844// height - The number of pixels in height for the bitmap.
845// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700846// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400847// above.
848// first_scan - A pointer to the first byte of the first line if
849// using an external buffer. If this parameter is NULL,
850// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700851// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400852// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700853// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400854// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700855// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400856// Similar to FPDFBitmap_Create function, but allows for more formats
857// and an external buffer is supported. The bitmap created by this
858// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700859// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700860//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400861// If an external buffer is used, then the application should destroy
862// the buffer by itself. FPDFBitmap_Destroy function will not destroy
863// the buffer.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400864FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
865 int height,
866 int format,
867 void* first_scan,
868 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700869
Jane Liu28fb7ba2017-08-02 21:45:57 -0400870// Function: FPDFBitmap_GetFormat
871// Get the format of the bitmap.
872// Parameters:
873// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
874// or FPDFImageObj_GetBitmap.
875// Return value:
876// The format of the bitmap.
877// Comments:
878// Only formats supported by FPDFBitmap_CreateEx are supported by this
879// function; see the list of such formats above.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400880FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
Jane Liu28fb7ba2017-08-02 21:45:57 -0400881
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700882// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400883// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700884// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700885// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400886// FPDFBitmap_Create.
887// left - The left position. Starting from 0 at the
888// left-most pixel.
889// top - The top position. Starting from 0 at the
890// top-most line.
891// width - Width in pixels to be filled.
892// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700893// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400894// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700895// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700896// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700897// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400898// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700899// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700900//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400901// NOTE: If the alpha channel is used, this function does NOT
902// composite the background with the source color, instead the
903// background will be replaced by the source color and the alpha.
904//
905// If the alpha channel is not used, the alpha parameter is ignored.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400906FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
907 int left,
908 int top,
909 int width,
910 int height,
911 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700912
913// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400914// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700915// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400916// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
917// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700918// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700919// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700920// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700921// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400922//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700923// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400924// then manipulate any color and/or alpha values for any pixels in the
925// bitmap.
926//
927// The data is in BGRA format. Where the A maybe unused if alpha was
928// not specified.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400929FPDF_EXPORT void* FPDF_CALLCONV FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700930
931// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400932// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700933// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400934// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
935// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700936// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400937// The width of the bitmap in pixels.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400938FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700939
940// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400941// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700942// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400943// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
944// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700945// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400946// The height of the bitmap in pixels.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400947FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700948
949// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400950// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700951// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400952// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
953// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700954// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400955// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700956// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400957// The stride may be more than width * number of bytes per pixel.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400958FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700959
960// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400961// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700962// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400963// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
964// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700965// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700966// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700967// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400968// This function will not destroy any external buffers provided when
969// the bitmap was created.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400970FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700971
972// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700973// Whether the PDF document prefers to be scaled or not.
974// Parameters:
975// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700976// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700977// None.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400978FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700979FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700980
Bo Xu9114e832014-07-14 13:22:47 -0700981// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700982// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700983// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700984// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700985// Return value:
986// The number of copies to be printed.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400987FPDF_EXPORT int FPDF_CALLCONV
988FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700989
990// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700991// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700992// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700993// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700994// Return value:
995// The print page range to be used for printing.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400996FPDF_EXPORT FPDF_PAGERANGE FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700997FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700998
999// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001000// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -04001001// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -07001002// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001003// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -07001004// Return value:
1005// The paper handling option to be used when printing.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001006FPDF_EXPORT FPDF_DUPLEXTYPE FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001007FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -07001008
thestig04bebfe2016-11-04 16:07:25 -07001009// Function: FPDF_VIEWERREF_GetName
1010// Gets the contents for a viewer ref, with a given key. The value must
1011// be of type "name".
1012// Parameters:
1013// document - Handle to the loaded document.
1014// key - Name of the key in the viewer pref dictionary.
1015// buffer - A string to write the contents of the key to.
1016// length - Length of the buffer.
1017// Return value:
1018// The number of bytes in the contents, including the NULL terminator.
1019// Thus if the return value is 0, then that indicates an error, such
1020// as when |document| is invalid or |buffer| is NULL. If |length| is
1021// less than the returned length, or |buffer| is NULL, |buffer| will
1022// not be modified.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001023FPDF_EXPORT unsigned long FPDF_CALLCONV
1024FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
1025 FPDF_BYTESTRING key,
1026 char* buffer,
1027 unsigned long length);
thestig04bebfe2016-11-04 16:07:25 -07001028
Bo Xu4d62b6b2015-01-10 22:52:59 -08001029// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -07001030// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001031// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001032// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -08001033// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -07001034// The count of named destinations.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001035FPDF_EXPORT FPDF_DWORD FPDF_CALLCONV
1036FPDF_CountNamedDests(FPDF_DOCUMENT document);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001037
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001038// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -04001039// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -07001040// Parameters:
1041// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -04001042// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001043// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001044// The handle to the destination.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001045FPDF_EXPORT FPDF_DEST FPDF_CALLCONV
1046FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001047
Bo Xu4d62b6b2015-01-10 22:52:59 -08001048// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -04001049// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001050// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001051// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -04001052// index - The index of a named destination.
1053// buffer - The buffer to store the destination name,
1054// used as wchar_t*.
1055// buflen [in/out] - Size of the buffer in bytes on input,
1056// length of the result in bytes on output
1057// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001058// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001059// The destination handle for a given index, or NULL if there is no
1060// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001061// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -07001062// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001063// 1) First time pass in |buffer| as NULL and get buflen.
1064// 2) Second time pass in allocated |buffer| and buflen to retrieve
1065// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001066//
Dan Sinclair49f88b72015-10-20 15:18:51 -04001067// If buflen is not sufficiently large, it will be set to -1 upon
1068// return.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001069FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document,
1070 int index,
1071 void* buffer,
1072 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001073
Tom Sepezc46d0002015-11-30 15:46:36 -08001074#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -07001075// Function: FPDF_BStr_Init
1076// Helper function to initialize a byte string.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001077FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* str);
Bo Xufdc00a72014-10-28 23:03:33 -07001078
Tom Sepez9857e202015-05-13 17:09:26 -07001079// Function: FPDF_BStr_Set
1080// Helper function to set string data.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001081FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Set(FPDF_BSTR* str,
1082 FPDF_LPCSTR bstr,
1083 int length);
Bo Xufdc00a72014-10-28 23:03:33 -07001084
Tom Sepez9857e202015-05-13 17:09:26 -07001085// Function: FPDF_BStr_Clear
1086// Helper function to clear a byte string.
Dan Sinclair00d2ad12017-08-10 14:13:02 -04001087FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -08001088#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -07001089
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001090#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -07001091}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001092#endif
1093
Tom Sepez9857e202015-05-13 17:09:26 -07001094#endif // PUBLIC_FPDFVIEW_H_