blob: 01a856d291b521ffd664e2a9966a94d9ebc10c58 [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
Felix Kauselmann00334672017-08-09 21:44:31 +0200145// Defines FPDF_EXPORT to enable symbol export
146// for component builds
147
148#if defined(COMPONENT_BUILD)
149#if defined(_WIN32)
150
151#if defined(FPDF_IMPLEMENTATION)
152#define FPDF_EXPORT __declspec(dllexport)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700153#else
Felix Kauselmann00334672017-08-09 21:44:31 +0200154#define FPDF_EXPORT __declspec(dllimport)
155#endif // defined(FPDF_IMPLEMENTATION)
156
157#else // defined(_WIN32)
158
159#if defined(FPDF_IMPLEMENTATION)
160#define FPDF_EXPORT __attribute__((visibility("default")))
161#else
162#define FPDF_EXPORT
163#endif // defined(FPDF_IMPLEMENTATION)
164
165#endif // defined(_WIN32)
166
167#else // defined(COMPONENT_BUILD)
168#define FPDF_EXPORT
169#endif // defined(COMPONENT_BUILD)
170
171#if defined(_WIN32)
172#define FPDF_CALLCONV __cdecl
173#else
174#define FPDF_CALLCONV
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700175#endif
176
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700177// Exported Functions
178#ifdef __cplusplus
179extern "C" {
180#endif
181
182// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700183// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700184// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700185// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700186// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700187// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700188// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700189// Convenience function to call FPDF_InitLibraryWithConfig() for
190// backwards comatibility purposes.
Felix Kauselmann00334672017-08-09 21:44:31 +0200191FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibrary();
Lei Zhang6f62d532015-09-23 15:31:44 -0700192
Dan Sinclair49f88b72015-10-20 15:18:51 -0400193// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700194typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700195 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700196 int version;
197
198 // Array of paths to scan in place of the defaults when using built-in
199 // FXGE font loading code. The array is terminated by a NULL pointer.
200 // The Array may be NULL itself to use the default paths. May be ignored
201 // entirely depending upon the platform.
202 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700203
204 // Version 2.
205
206 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
207 void* m_pIsolate;
208
209 // The embedder data slot to use in the v8::Isolate to store PDFium's
210 // per-isolate data. The value needs to be between 0 and
211 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
212 // for most embedders.
213 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700214} FPDF_LIBRARY_CONFIG;
215
216// Function: FPDF_InitLibraryWithConfig
217// Initialize the FPDFSDK library
218// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400219// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700220// Return value:
221// None.
222// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700223// You have to call this function before you can call any PDF
224// processing functions.
Felix Kauselmann00334672017-08-09 21:44:31 +0200225FPDF_EXPORT void FPDF_CALLCONV
226FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700227
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700228// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700229// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700230// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700231// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700232// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700233// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700234// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700235// You can call this function to release all memory blocks allocated by
236// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400237// After this function is called, you should not call any PDF
238// processing functions.
Felix Kauselmann00334672017-08-09 21:44:31 +0200239FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700240
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700241// Policy for accessing the local machine time.
242#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700243
244// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700245// Set the policy for the sandbox environment.
246// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400247// policy - The specified policy for setting, for example:
248// FPDF_POLICY_MACHINETIME_ACCESS.
249// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700250// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700251// None.
Felix Kauselmann00334672017-08-09 21:44:31 +0200252FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
253 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700254
rbpotterdb764702017-01-12 10:31:43 -0800255#if defined(_WIN32)
256#if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
thestigfdb35ff2016-07-18 13:45:44 -0700257// Pointer to a helper function to make |font| with |text| of |text_length|
258// accessible when printing text with GDI. This is useful in sandboxed
259// environments where PDFium's access to GDI may be restricted.
260typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
261 const wchar_t* text,
262 size_t text_length);
263
264// Function: FPDF_SetTypefaceAccessibleFunc
265// Set the function pointer that makes GDI fonts available in sandboxed
266// environments. Experimental API.
267// Parameters:
268// func - A function pointer. See description above.
269// Return value:
270// None.
Felix Kauselmann00334672017-08-09 21:44:31 +0200271FPDF_EXPORT void FPDF_CALLCONV
thestigfdb35ff2016-07-18 13:45:44 -0700272FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func);
273
274// Function: FPDF_SetPrintTextWithGDI
275// Set whether to use GDI to draw fonts when printing on Windows.
276// Experimental API.
277// Parameters:
278// use_gdi - Set to true to enable printing text with GDI.
279// Return value:
280// None.
Felix Kauselmann00334672017-08-09 21:44:31 +0200281FPDF_EXPORT void FPDF_CALLCONV FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi);
rbpotterdb764702017-01-12 10:31:43 -0800282#endif // PDFIUM_PRINT_TEXT_WITH_GDI
283
rbpotter38a01b92017-07-13 11:58:01 -0700284// Function: FPDF_SetPrintPostscriptLevel
285// Set postscript printing level when printing on Windows.
286// Experimental API.
287// Parameters:
288// postscript_level- 0 to disable postscript printing,
289// 2 to print with postscript level 2,
290// 3 to print with postscript level 3.
291// All other values are invalid.
292// Return value:
293// True if successful, false if unsuccessful (typically invalid input).
Felix Kauselmann00334672017-08-09 21:44:31 +0200294FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
295FPDF_SetPrintPostscriptLevel(int postscript_level);
rbpotter38a01b92017-07-13 11:58:01 -0700296
rbpottere8468c42017-07-11 10:04:29 -0700297// Function: FPDF_SetPrintMode
298// Set printing mode when printing on Windows.
rbpotterdb764702017-01-12 10:31:43 -0800299// Experimental API.
300// Parameters:
rbpottere8468c42017-07-11 10:04:29 -0700301// mode - FPDF_PRINTMODE_EMF to output EMF (default)
302// FPDF_PRINTMODE_TEXTONLY to output text only (for charstream
303// devices)
304// FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 postscript
305// FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 postscript
rbpotterdb764702017-01-12 10:31:43 -0800306// Return value:
rbpottere8468c42017-07-11 10:04:29 -0700307// True if successful, false if unsuccessful (typically invalid input).
Felix Kauselmann00334672017-08-09 21:44:31 +0200308FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SetPrintMode(int mode);
rbpotterdb764702017-01-12 10:31:43 -0800309#endif // defined(_WIN32)
thestigfdb35ff2016-07-18 13:45:44 -0700310
Tom Sepez3c3201f2015-05-20 10:20:35 -0700311// Function: FPDF_LoadDocument
312// Open and load a PDF document.
313// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400314// file_path - Path to the PDF file (including extension).
315// password - A string used as the password for the PDF file.
316// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700317// Return value:
318// A handle to the loaded document, or NULL on failure.
319// Comments:
320// Loaded document can be closed by FPDF_CloseDocument().
321// If this function fails, you can use FPDF_GetLastError() to retrieve
322// the reason why it failed.
Felix Kauselmann00334672017-08-09 21:44:31 +0200323FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
324FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700325
326// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700327// Open and load a PDF document from memory.
328// Parameters:
329// data_buf - Pointer to a buffer containing the PDF document.
330// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400331// password - A string used as the password for the PDF file.
332// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700333// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400334// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700335// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700336// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400337// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700338// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400339// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700340// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800341// If PDFium is built with the XFA module, the application should call
342// FPDF_LoadXFA() function after the PDF document loaded to support XFA
343// fields defined in the fpdfformfill.h file.
Felix Kauselmann00334672017-08-09 21:44:31 +0200344FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
345FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700346
347// Structure for custom file access.
348typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700349 // File length, in bytes.
350 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700351
Dan Sinclair49f88b72015-10-20 15:18:51 -0400352 // A function pointer for getting a block of data from a specific position.
353 // Position is specified by byte offset from the beginning of the file.
354 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700355 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400356 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700357 // Return value: should be non-zero if successful, zero for error.
358 int (*m_GetBlock)(void* param,
359 unsigned long position,
360 unsigned char* pBuf,
361 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700362
Dan Sinclair49f88b72015-10-20 15:18:51 -0400363 // A custom pointer for all implementation specific data. This pointer will
364 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700365 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700366} FPDF_FILEACCESS;
367
Tom Sepezc46d0002015-11-30 15:46:36 -0800368#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700369/**
370 * @brief Structure for file reading or writing (I/O).
371 *
372 * @note This is a handler and should be implemented by callers.
373 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700374typedef struct _FPDF_FILEHANDLER {
375 /**
376 * @brief User-defined data.
377 * @note Callers can use this field to track controls.
378 */
379 FPDF_LPVOID clientData;
380 /**
381 * @brief Callback function to release the current file stream object.
382 *
383 * @param[in] clientData Pointer to user-defined data.
384 *
385 * @return None.
386 */
387 void (*Release)(FPDF_LPVOID clientData);
388 /**
389 * @brief Callback function to retrieve the current file stream size.
390 *
391 * @param[in] clientData Pointer to user-defined data.
392 *
393 * @return Size of file stream.
394 */
395 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
396 /**
397 * @brief Callback function to read data from the current file stream.
398 *
399 * @param[in] clientData Pointer to user-defined data.
400 * @param[in] offset Offset position starts from the beginning of file
401 * stream. This parameter indicates reading position.
402 * @param[in] buffer Memory buffer to store data which are read from
403 * file stream. This parameter should not be <b>NULL</b>.
404 * @param[in] size Size of data which should be read from file
405 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
406 * should be enough to store specified data.
407 *
408 * @return 0 for success, other value for failure.
409 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500410 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
411 FPDF_DWORD offset,
412 FPDF_LPVOID buffer,
413 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700414 /**
415 * @brief Callback function to write data into the current file stream.
416 *
417 * @param[in] clientData Pointer to user-defined data.
418 * @param[in] offset Offset position starts from the beginning of file
419 * stream. This parameter indicates writing position.
420 * @param[in] buffer Memory buffer contains data which is written into
421 * file stream. This parameter should not be <b>NULL</b>.
422 * @param[in] size Size of data which should be written into file
423 * stream, in bytes.
424 *
425 * @return 0 for success, other value for failure.
426 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500427 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
428 FPDF_DWORD offset,
429 FPDF_LPCVOID buffer,
430 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700431 /**
432 * @brief Callback function to flush all internal accessing buffers.
433 *
434 * @param[in] clientData Pointer to user-defined data.
435 *
436 * @return 0 for success, other value for failure.
437 */
438 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
439 /**
440 * @brief Callback function to change file size.
441 *
442 * @details This function is called under writing mode usually. Implementer
443 * can determine whether to realize it based on application requests.
444 *
445 * @param[in] clientData Pointer to user-defined data.
446 * @param[in] size New size of file stream, in bytes.
447 *
448 * @return 0 for success, other value for failure.
449 */
450 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700451} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
452
Tom Sepezc46d0002015-11-30 15:46:36 -0800453#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700454// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700455// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700456// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400457// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700458// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700459// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400460// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700461// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400462// The application must keep the file resources valid until the PDF
463// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700464//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400465// The loaded document can be closed with FPDF_CloseDocument.
466// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800467// If PDFium is built with the XFA module, the application should call
468// FPDF_LoadXFA() function after the PDF document loaded to support XFA
469// fields defined in the fpdfformfill.h file.
Felix Kauselmann00334672017-08-09 21:44:31 +0200470FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700471FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700472
473// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400474// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700475// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400476// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700477// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400478// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700479// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400480// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700481// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400482// If the document was created by FPDF_CreateNewDocument,
483// then this function will always fail.
Felix Kauselmann00334672017-08-09 21:44:31 +0200484FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetFileVersion(FPDF_DOCUMENT doc,
485 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700486
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700487#define FPDF_ERR_SUCCESS 0 // No error.
488#define FPDF_ERR_UNKNOWN 1 // Unknown error.
489#define FPDF_ERR_FILE 2 // File not found or could not be opened.
490#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
491#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
492#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
493#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800494#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700495#define FPDF_ERR_XFALOAD 7 // Load XFA error.
496#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800497#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700498
499// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400500// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700501// Parameters:
502// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700503// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400504// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700505// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700506// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400507// function is not defined.
Felix Kauselmann00334672017-08-09 21:44:31 +0200508FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700509
510// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700511// Get file permission flags of the document.
512// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400513// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700514// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400515// A 32-bit integer indicating permission flags. Please refer to the
516// PDF Reference for detailed descriptions. If the document is not
517// protected, 0xffffffff will be returned.
Felix Kauselmann00334672017-08-09 21:44:31 +0200518FPDF_EXPORT unsigned long FPDF_CALLCONV
519FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700520
Bo Xuc5cab022014-09-19 19:16:31 -0700521// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400522// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700523// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400524// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700525// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400526// The security handler revision number. Please refer to the PDF
527// Reference for a detailed description. If the document is not
528// protected, -1 will be returned.
Felix Kauselmann00334672017-08-09 21:44:31 +0200529FPDF_EXPORT int FPDF_CALLCONV
530FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
Bo Xuc5cab022014-09-19 19:16:31 -0700531
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700532// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400533// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700534// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400535// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700536// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700537// Total number of pages in the document.
Felix Kauselmann00334672017-08-09 21:44:31 +0200538FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700539
540// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400541// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700542// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700543// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700544// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700545// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400546// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700547// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400548// The loaded page can be rendered to devices using FPDF_RenderPage.
549// The loaded page can be closed using FPDF_ClosePage.
Felix Kauselmann00334672017-08-09 21:44:31 +0200550FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document,
551 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700552
553// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700554// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700555// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400556// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700557// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700558// Page width (excluding non-displayable area) measured in points.
559// One point is 1/72 inch (around 0.3528 mm).
Felix Kauselmann00334672017-08-09 21:44:31 +0200560FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700561
562// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700563// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700564// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400565// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700566// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700567// Page height (excluding non-displayable area) measured in points.
568// One point is 1/72 inch (around 0.3528 mm)
Felix Kauselmann00334672017-08-09 21:44:31 +0200569FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700570
571// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400572// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700573// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400574// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700575// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400576// width - Pointer to a double to receive the page width
577// (in points).
578// height - Pointer to a double to receive the page height
579// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700580// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700581// Non-zero for success. 0 for error (document or page not found).
Felix Kauselmann00334672017-08-09 21:44:31 +0200582FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
583 int page_index,
584 double* width,
585 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700586
Dan Sinclair49f88b72015-10-20 15:18:51 -0400587// Page rendering flags. They can be combined with bit-wise OR.
588//
589// Set if annotations are to be rendered.
590#define FPDF_ANNOT 0x01
591// Set if using text rendering optimized for LCD display.
592#define FPDF_LCD_TEXT 0x02
593// Don't use the native text output available on some platforms
594#define FPDF_NO_NATIVETEXT 0x04
595// Grayscale output.
596#define FPDF_GRAYSCALE 0x08
597// Set if you want to get some debug info.
598#define FPDF_DEBUG_INFO 0x80
599// Set if you don't want to catch exceptions.
600#define FPDF_NO_CATCH 0x100
601// Limit image cache size.
602#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
603// Always use halftone for image stretching.
604#define FPDF_RENDER_FORCEHALFTONE 0x400
605// Render for printing.
606#define FPDF_PRINTING 0x800
607// Set to disable anti-aliasing on text.
608#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
609// Set to disable anti-aliasing on images.
610#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
611// Set to disable anti-aliasing on paths.
612#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
613// Set whether to render in a reverse Byte order, this flag is only used when
614// rendering to a bitmap.
615#define FPDF_REVERSE_BYTE_ORDER 0x10
616
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700617#ifdef _WIN32
618// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400619// Render contents of a page to a device (screen, bitmap, or printer).
620// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700621// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400622// dc - Handle to the device context.
623// page - Handle to the page. Returned by FPDF_LoadPage.
624// start_x - Left pixel position of the display area in
625// device coordinates.
626// start_y - Top pixel position of the display area in device
627// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700628// size_x - Horizontal size (in pixels) for displaying the page.
629// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400630// rotate - Page orientation:
631// 0 (normal)
632// 1 (rotated 90 degrees clockwise)
633// 2 (rotated 180 degrees)
634// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700635// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400636// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700637// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700638// None.
Felix Kauselmann00334672017-08-09 21:44:31 +0200639FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc,
640 FPDF_PAGE page,
641 int start_x,
642 int start_y,
643 int size_x,
644 int size_y,
645 int rotate,
646 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700647#endif
648
649// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400650// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700651// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700652// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400653// output buffer). The bitmap handle can be created
Jane Liu28fb7ba2017-08-02 21:45:57 -0400654// by FPDFBitmap_Create or retrieved from an image
655// object by FPDFImageObj_GetBitmap.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700656// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400657// start_x - Left pixel position of the display area in
658// bitmap coordinates.
659// start_y - Top pixel position of the display area in bitmap
660// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700661// size_x - Horizontal size (in pixels) for displaying the page.
662// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400663// rotate - Page orientation:
664// 0 (normal)
665// 1 (rotated 90 degrees clockwise)
666// 2 (rotated 180 degrees)
667// 3 (rotated 90 degrees counter-clockwise)
thestiga78ba602016-11-23 15:25:48 -0800668// flags - 0 for normal display, or combination of the Page
669// Rendering flags defined above. With the FPDF_ANNOT
670// flag, it renders all annotations that do not require
671// user-interaction, which are all annotations except
672// widget and popup annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700673// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700674// None.
Felix Kauselmann00334672017-08-09 21:44:31 +0200675FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
676 FPDF_PAGE page,
677 int start_x,
678 int start_y,
679 int size_x,
680 int size_y,
681 int rotate,
682 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700683
thestiga78ba602016-11-23 15:25:48 -0800684// Function: FPDF_RenderPageBitmapWithMatrix
685// Render contents of a page to a device independent bitmap.
686// Parameters:
687// bitmap - Handle to the device independent bitmap (as the
688// output buffer). The bitmap handle can be created
Jane Liu28fb7ba2017-08-02 21:45:57 -0400689// by FPDFBitmap_Create or retrieved by
690// FPDFImageObj_GetBitmap.
thestiga78ba602016-11-23 15:25:48 -0800691// page - Handle to the page. Returned by FPDF_LoadPage
692// matrix - The transform matrix.
693// clipping - The rect to clip to.
694// flags - 0 for normal display, or combination of the Page
695// Rendering flags defined above. With the FPDF_ANNOT
696// flag, it renders all annotations that do not require
697// user-interaction, which are all annotations except
698// widget and popup annotations.
699// Return value:
700// None.
Felix Kauselmann00334672017-08-09 21:44:31 +0200701FPDF_EXPORT void FPDF_CALLCONV
702FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
703 FPDF_PAGE page,
704 const FS_MATRIX* matrix,
705 const FS_RECTF* clipping,
706 int flags);
thestiga78ba602016-11-23 15:25:48 -0800707
Cary Clark399be5b2016-03-14 16:51:29 -0400708#ifdef _SKIA_SUPPORT_
Felix Kauselmann00334672017-08-09 21:44:31 +0200709FPDF_EXPORT FPDF_RECORDER FPDF_CALLCONV FPDF_RenderPageSkp(FPDF_PAGE page,
710 int size_x,
711 int size_y);
Cary Clark399be5b2016-03-14 16:51:29 -0400712#endif
713
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700714// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700715// Close a loaded PDF page.
716// Parameters:
717// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700718// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700719// None.
Felix Kauselmann00334672017-08-09 21:44:31 +0200720FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700721
722// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700723// Close a loaded PDF document.
724// Parameters:
725// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700726// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700727// None.
Felix Kauselmann00334672017-08-09 21:44:31 +0200728FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700729
730// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400731// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700732// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400733// page - Handle to the page. Returned by FPDF_LoadPage.
734// start_x - Left pixel position of the display area in
735// device coordinates.
736// start_y - Top pixel position of the display area in device
737// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700738// size_x - Horizontal size (in pixels) for displaying the page.
739// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400740// rotate - Page orientation:
741// 0 (normal)
742// 1 (rotated 90 degrees clockwise)
743// 2 (rotated 180 degrees)
744// 3 (rotated 90 degrees counter-clockwise)
745// device_x - X value in device coordinates to be converted.
746// device_y - Y value in device coordinates to be converted.
747// page_x - A pointer to a double receiving the converted X
748// value in page coordinates.
749// page_y - A pointer to a double receiving the converted Y
750// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700751// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700752// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700753// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400754// The page coordinate system has its origin at the left-bottom corner
755// of the page, with the X-axis on the bottom going to the right, and
756// the Y-axis on the left side going up.
757//
758// NOTE: this coordinate system can be altered when you zoom, scroll,
759// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700760// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700761//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700762// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400763// its origin is at the left-top corner of the window. However this
764// origin can be altered by the Windows coordinate transformation
765// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700766//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400767// You must make sure the start_x, start_y, size_x, size_y
768// and rotate parameters have exactly same values as you used in
769// the FPDF_RenderPage() function call.
Felix Kauselmann00334672017-08-09 21:44:31 +0200770FPDF_EXPORT void FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page,
771 int start_x,
772 int start_y,
773 int size_x,
774 int size_y,
775 int rotate,
776 int device_x,
777 int device_y,
778 double* page_x,
779 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700780
781// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400782// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700783// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400784// page - Handle to the page. Returned by FPDF_LoadPage.
785// start_x - Left pixel position of the display area in
786// device coordinates.
787// start_y - Top pixel position of the display area in device
788// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700789// size_x - Horizontal size (in pixels) for displaying the page.
790// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400791// rotate - Page orientation:
792// 0 (normal)
793// 1 (rotated 90 degrees clockwise)
794// 2 (rotated 180 degrees)
795// 3 (rotated 90 degrees counter-clockwise)
796// page_x - X value in page coordinates.
797// page_y - Y value in page coordinate.
798// device_x - A pointer to an integer receiving the result X
799// value in device coordinates.
800// device_y - A pointer to an integer receiving the result Y
801// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700802// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700803// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700804// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400805// See comments for FPDF_DeviceToPage().
Felix Kauselmann00334672017-08-09 21:44:31 +0200806FPDF_EXPORT void FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page,
807 int start_x,
808 int start_y,
809 int size_x,
810 int size_y,
811 int rotate,
812 double page_x,
813 double page_y,
814 int* device_x,
815 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700816
817// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400818// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700819// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400820// width - The number of pixels in width for the bitmap.
821// Must be greater than 0.
822// height - The number of pixels in height for the bitmap.
823// Must be greater than 0.
824// alpha - A flag indicating whether the alpha channel is used.
825// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700826// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400827// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700828// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700829// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400830// The bitmap always uses 4 bytes per pixel. The first byte is always
831// double word aligned.
832//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700833// The byte order is BGRx (the last byte unused if no alpha channel) or
834// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700835//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400836// The pixels in a horizontal line are stored side by side, with the
837// left most pixel stored first (with lower memory address).
838// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700839//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400840// Lines are stored one after another, with the top most line stored
841// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700842//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700843// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400844// bitmap, but it doesn't initialize the buffer. Applications can use
845// FPDFBitmap_FillRect to fill the bitmap using any color.
Felix Kauselmann00334672017-08-09 21:44:31 +0200846FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width,
847 int height,
848 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700849
850// More DIB formats
Jane Liu28fb7ba2017-08-02 21:45:57 -0400851// Unknown or unsupported format.
852#define FPDFBitmap_Unknown 0
Dan Sinclair49f88b72015-10-20 15:18:51 -0400853// Gray scale bitmap, one byte per pixel.
854#define FPDFBitmap_Gray 1
855// 3 bytes per pixel, byte order: blue, green, red.
856#define FPDFBitmap_BGR 2
857// 4 bytes per pixel, byte order: blue, green, red, unused.
858#define FPDFBitmap_BGRx 3
859// 4 bytes per pixel, byte order: blue, green, red, alpha.
860#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700861
862// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400863// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700864// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400865// width - The number of pixels in width for the bitmap.
866// Must be greater than 0.
867// height - The number of pixels in height for the bitmap.
868// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700869// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400870// above.
871// first_scan - A pointer to the first byte of the first line if
872// using an external buffer. If this parameter is NULL,
873// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700874// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400875// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700876// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400877// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700878// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400879// Similar to FPDFBitmap_Create function, but allows for more formats
880// and an external buffer is supported. The bitmap created by this
881// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700882// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700883//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400884// If an external buffer is used, then the application should destroy
885// the buffer by itself. FPDFBitmap_Destroy function will not destroy
886// the buffer.
Felix Kauselmann00334672017-08-09 21:44:31 +0200887FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
888 int height,
889 int format,
890 void* first_scan,
891 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700892
Jane Liu28fb7ba2017-08-02 21:45:57 -0400893// Function: FPDFBitmap_GetFormat
894// Get the format of the bitmap.
895// Parameters:
896// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
897// or FPDFImageObj_GetBitmap.
898// Return value:
899// The format of the bitmap.
900// Comments:
901// Only formats supported by FPDFBitmap_CreateEx are supported by this
902// function; see the list of such formats above.
Felix Kauselmann00334672017-08-09 21:44:31 +0200903FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
Jane Liu28fb7ba2017-08-02 21:45:57 -0400904
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700905// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400906// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700907// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700908// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400909// FPDFBitmap_Create.
910// left - The left position. Starting from 0 at the
911// left-most pixel.
912// top - The top position. Starting from 0 at the
913// top-most line.
914// width - Width in pixels to be filled.
915// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700916// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400917// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700918// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700919// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700920// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400921// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700922// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700923//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400924// NOTE: If the alpha channel is used, this function does NOT
925// composite the background with the source color, instead the
926// background will be replaced by the source color and the alpha.
927//
928// If the alpha channel is not used, the alpha parameter is ignored.
Felix Kauselmann00334672017-08-09 21:44:31 +0200929FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
930 int left,
931 int top,
932 int width,
933 int height,
934 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700935
936// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400937// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700938// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400939// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
940// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700941// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700942// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700943// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700944// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400945//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700946// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400947// then manipulate any color and/or alpha values for any pixels in the
948// bitmap.
949//
950// The data is in BGRA format. Where the A maybe unused if alpha was
951// not specified.
Felix Kauselmann00334672017-08-09 21:44:31 +0200952FPDF_EXPORT void* FPDF_CALLCONV FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700953
954// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400955// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700956// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400957// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
958// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700959// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400960// The width of the bitmap in pixels.
Felix Kauselmann00334672017-08-09 21:44:31 +0200961FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700962
963// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400964// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700965// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400966// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
967// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700968// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400969// The height of the bitmap in pixels.
Felix Kauselmann00334672017-08-09 21:44:31 +0200970FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700971
972// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400973// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700974// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400975// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
976// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700977// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400978// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700979// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400980// The stride may be more than width * number of bytes per pixel.
Felix Kauselmann00334672017-08-09 21:44:31 +0200981FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700982
983// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400984// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700985// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400986// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
987// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700988// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700989// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700990// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400991// This function will not destroy any external buffers provided when
992// the bitmap was created.
Felix Kauselmann00334672017-08-09 21:44:31 +0200993FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700994
995// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700996// Whether the PDF document prefers to be scaled or not.
997// Parameters:
998// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700999// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -07001000// None.
Felix Kauselmann00334672017-08-09 21:44:31 +02001001FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001002FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001003
Bo Xu9114e832014-07-14 13:22:47 -07001004// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -07001005// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -07001006// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001007// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -07001008// Return value:
1009// The number of copies to be printed.
Felix Kauselmann00334672017-08-09 21:44:31 +02001010FPDF_EXPORT int FPDF_CALLCONV
1011FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -07001012
1013// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -07001014// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -07001015// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001016// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -07001017// Return value:
1018// The print page range to be used for printing.
Felix Kauselmann00334672017-08-09 21:44:31 +02001019FPDF_EXPORT FPDF_PAGERANGE FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001020FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -07001021
1022// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001023// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -04001024// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -07001025// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001026// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -07001027// Return value:
1028// The paper handling option to be used when printing.
Felix Kauselmann00334672017-08-09 21:44:31 +02001029FPDF_EXPORT FPDF_DUPLEXTYPE FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001030FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -07001031
thestig04bebfe2016-11-04 16:07:25 -07001032// Function: FPDF_VIEWERREF_GetName
1033// Gets the contents for a viewer ref, with a given key. The value must
1034// be of type "name".
1035// Parameters:
1036// document - Handle to the loaded document.
1037// key - Name of the key in the viewer pref dictionary.
1038// buffer - A string to write the contents of the key to.
1039// length - Length of the buffer.
1040// Return value:
1041// The number of bytes in the contents, including the NULL terminator.
1042// Thus if the return value is 0, then that indicates an error, such
1043// as when |document| is invalid or |buffer| is NULL. If |length| is
1044// less than the returned length, or |buffer| is NULL, |buffer| will
1045// not be modified.
Felix Kauselmann00334672017-08-09 21:44:31 +02001046FPDF_EXPORT unsigned long FPDF_CALLCONV
1047FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
1048 FPDF_BYTESTRING key,
1049 char* buffer,
1050 unsigned long length);
thestig04bebfe2016-11-04 16:07:25 -07001051
Bo Xu4d62b6b2015-01-10 22:52:59 -08001052// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -07001053// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001054// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001055// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -08001056// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -07001057// The count of named destinations.
Felix Kauselmann00334672017-08-09 21:44:31 +02001058FPDF_EXPORT FPDF_DWORD FPDF_CALLCONV
1059FPDF_CountNamedDests(FPDF_DOCUMENT document);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001060
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001061// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -04001062// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -07001063// Parameters:
1064// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -04001065// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001066// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001067// The handle to the destination.
Felix Kauselmann00334672017-08-09 21:44:31 +02001068FPDF_EXPORT FPDF_DEST FPDF_CALLCONV
1069FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001070
Bo Xu4d62b6b2015-01-10 22:52:59 -08001071// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -04001072// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001073// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001074// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -04001075// index - The index of a named destination.
1076// buffer - The buffer to store the destination name,
1077// used as wchar_t*.
1078// buflen [in/out] - Size of the buffer in bytes on input,
1079// length of the result in bytes on output
1080// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001081// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001082// The destination handle for a given index, or NULL if there is no
1083// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001084// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -07001085// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001086// 1) First time pass in |buffer| as NULL and get buflen.
1087// 2) Second time pass in allocated |buffer| and buflen to retrieve
1088// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001089//
Dan Sinclair49f88b72015-10-20 15:18:51 -04001090// If buflen is not sufficiently large, it will be set to -1 upon
1091// return.
Felix Kauselmann00334672017-08-09 21:44:31 +02001092FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document,
1093 int index,
1094 void* buffer,
1095 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001096
Tom Sepezc46d0002015-11-30 15:46:36 -08001097#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -07001098// Function: FPDF_BStr_Init
1099// Helper function to initialize a byte string.
Felix Kauselmann00334672017-08-09 21:44:31 +02001100FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* str);
Bo Xufdc00a72014-10-28 23:03:33 -07001101
Tom Sepez9857e202015-05-13 17:09:26 -07001102// Function: FPDF_BStr_Set
1103// Helper function to set string data.
Felix Kauselmann00334672017-08-09 21:44:31 +02001104FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Set(FPDF_BSTR* str,
1105 FPDF_LPCSTR bstr,
1106 int length);
Bo Xufdc00a72014-10-28 23:03:33 -07001107
Tom Sepez9857e202015-05-13 17:09:26 -07001108// Function: FPDF_BStr_Clear
1109// Helper function to clear a byte string.
Felix Kauselmann00334672017-08-09 21:44:31 +02001110FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -08001111#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -07001112
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001113#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -07001114}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001115#endif
1116
Tom Sepez9857e202015-05-13 17:09:26 -07001117#endif // PUBLIC_FPDFVIEW_H_