blob: 4e2e698918118d912d5acc4f5bb95ff505dab544 [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
147#define DLLEXPORT __declspec(dllexport)
148#define STDCALL __stdcall
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700149#else
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000150#define DLLEXPORT
151#define STDCALL
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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000168DLLEXPORT void STDCALL 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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000202DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
203 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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000216DLLEXPORT void STDCALL 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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000229DLLEXPORT void STDCALL 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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000248DLLEXPORT void STDCALL
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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000258DLLEXPORT void STDCALL 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).
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000271DLLEXPORT FPDF_BOOL STDCALL FPDF_SetPrintPostscriptLevel(int postscript_level);
rbpotter38a01b92017-07-13 11:58:01 -0700272
rbpottere8468c42017-07-11 10:04:29 -0700273// Function: FPDF_SetPrintMode
274// Set printing mode when printing on Windows.
rbpotterdb764702017-01-12 10:31:43 -0800275// Experimental API.
276// Parameters:
rbpottere8468c42017-07-11 10:04:29 -0700277// mode - FPDF_PRINTMODE_EMF to output EMF (default)
278// FPDF_PRINTMODE_TEXTONLY to output text only (for charstream
279// devices)
280// FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 postscript
281// FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 postscript
rbpotterdb764702017-01-12 10:31:43 -0800282// Return value:
rbpottere8468c42017-07-11 10:04:29 -0700283// True if successful, false if unsuccessful (typically invalid input).
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000284DLLEXPORT FPDF_BOOL STDCALL FPDF_SetPrintMode(int mode);
rbpotterdb764702017-01-12 10:31:43 -0800285#endif // defined(_WIN32)
thestigfdb35ff2016-07-18 13:45:44 -0700286
Tom Sepez3c3201f2015-05-20 10:20:35 -0700287// Function: FPDF_LoadDocument
288// Open and load a PDF document.
289// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400290// file_path - Path to the PDF file (including extension).
291// password - A string used as the password for the PDF file.
292// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700293// Return value:
294// A handle to the loaded document, or NULL on failure.
295// Comments:
296// Loaded document can be closed by FPDF_CloseDocument().
297// If this function fails, you can use FPDF_GetLastError() to retrieve
298// the reason why it failed.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000299DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
300 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700301
302// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700303// Open and load a PDF document from memory.
304// Parameters:
305// data_buf - Pointer to a buffer containing the PDF document.
306// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400307// password - A string used as the password for the PDF file.
308// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700309// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400310// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700311// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700312// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400313// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700314// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400315// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700316// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800317// If PDFium is built with the XFA module, the application should call
318// FPDF_LoadXFA() function after the PDF document loaded to support XFA
319// fields defined in the fpdfformfill.h file.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000320DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
321 int size,
322 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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000447DLLEXPORT FPDF_DOCUMENT STDCALL
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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000461DLLEXPORT FPDF_BOOL STDCALL 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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000485DLLEXPORT unsigned long STDCALL 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.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000495DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700496
Bo Xuc5cab022014-09-19 19:16:31 -0700497// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400498// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700499// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400500// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700501// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400502// The security handler revision number. Please refer to the PDF
503// Reference for a detailed description. If the document is not
504// protected, -1 will be returned.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000505DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
Bo Xuc5cab022014-09-19 19:16:31 -0700506
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700507// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400508// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700509// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400510// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700511// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700512// Total number of pages in the document.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000513DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700514
515// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400516// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700517// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700518// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700519// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700520// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400521// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700522// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400523// The loaded page can be rendered to devices using FPDF_RenderPage.
524// The loaded page can be closed using FPDF_ClosePage.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000525DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
526 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700527
528// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700529// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700530// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400531// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700532// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700533// Page width (excluding non-displayable area) measured in points.
534// One point is 1/72 inch (around 0.3528 mm).
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000535DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700536
537// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700538// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700539// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400540// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700541// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700542// Page height (excluding non-displayable area) measured in points.
543// One point is 1/72 inch (around 0.3528 mm)
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000544DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700545
546// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400547// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700548// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400549// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700550// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400551// width - Pointer to a double to receive the page width
552// (in points).
553// height - Pointer to a double to receive the page height
554// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700555// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700556// Non-zero for success. 0 for error (document or page not found).
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000557DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
558 int page_index,
559 double* width,
560 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700561
Dan Sinclair49f88b72015-10-20 15:18:51 -0400562// Page rendering flags. They can be combined with bit-wise OR.
563//
564// Set if annotations are to be rendered.
565#define FPDF_ANNOT 0x01
566// Set if using text rendering optimized for LCD display.
567#define FPDF_LCD_TEXT 0x02
568// Don't use the native text output available on some platforms
569#define FPDF_NO_NATIVETEXT 0x04
570// Grayscale output.
571#define FPDF_GRAYSCALE 0x08
572// Set if you want to get some debug info.
573#define FPDF_DEBUG_INFO 0x80
574// Set if you don't want to catch exceptions.
575#define FPDF_NO_CATCH 0x100
576// Limit image cache size.
577#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
578// Always use halftone for image stretching.
579#define FPDF_RENDER_FORCEHALFTONE 0x400
580// Render for printing.
581#define FPDF_PRINTING 0x800
582// Set to disable anti-aliasing on text.
583#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
584// Set to disable anti-aliasing on images.
585#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
586// Set to disable anti-aliasing on paths.
587#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
588// Set whether to render in a reverse Byte order, this flag is only used when
589// rendering to a bitmap.
590#define FPDF_REVERSE_BYTE_ORDER 0x10
591
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700592#ifdef _WIN32
593// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400594// Render contents of a page to a device (screen, bitmap, or printer).
595// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700596// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400597// dc - Handle to the device context.
598// page - Handle to the page. Returned by FPDF_LoadPage.
599// start_x - Left pixel position of the display area in
600// device coordinates.
601// start_y - Top pixel position of the display area in device
602// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700603// size_x - Horizontal size (in pixels) for displaying the page.
604// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400605// rotate - Page orientation:
606// 0 (normal)
607// 1 (rotated 90 degrees clockwise)
608// 2 (rotated 180 degrees)
609// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700610// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400611// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700612// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700613// None.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000614DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
615 FPDF_PAGE page,
616 int start_x,
617 int start_y,
618 int size_x,
619 int size_y,
620 int rotate,
621 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700622#endif
623
624// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400625// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700626// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700627// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400628// output buffer). The bitmap handle can be created
Jane Liu28fb7ba2017-08-02 21:45:57 -0400629// by FPDFBitmap_Create or retrieved from an image
630// object by FPDFImageObj_GetBitmap.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700631// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400632// start_x - Left pixel position of the display area in
633// bitmap coordinates.
634// start_y - Top pixel position of the display area in bitmap
635// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700636// size_x - Horizontal size (in pixels) for displaying the page.
637// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400638// rotate - Page orientation:
639// 0 (normal)
640// 1 (rotated 90 degrees clockwise)
641// 2 (rotated 180 degrees)
642// 3 (rotated 90 degrees counter-clockwise)
thestiga78ba602016-11-23 15:25:48 -0800643// flags - 0 for normal display, or combination of the Page
644// Rendering flags defined above. With the FPDF_ANNOT
645// flag, it renders all annotations that do not require
646// user-interaction, which are all annotations except
647// widget and popup annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700648// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700649// None.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000650DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
651 FPDF_PAGE page,
652 int start_x,
653 int start_y,
654 int size_x,
655 int size_y,
656 int rotate,
657 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700658
thestiga78ba602016-11-23 15:25:48 -0800659// Function: FPDF_RenderPageBitmapWithMatrix
660// Render contents of a page to a device independent bitmap.
661// Parameters:
662// bitmap - Handle to the device independent bitmap (as the
663// output buffer). The bitmap handle can be created
Jane Liu28fb7ba2017-08-02 21:45:57 -0400664// by FPDFBitmap_Create or retrieved by
665// FPDFImageObj_GetBitmap.
thestiga78ba602016-11-23 15:25:48 -0800666// page - Handle to the page. Returned by FPDF_LoadPage
667// matrix - The transform matrix.
668// clipping - The rect to clip to.
669// flags - 0 for normal display, or combination of the Page
670// Rendering flags defined above. With the FPDF_ANNOT
671// flag, it renders all annotations that do not require
672// user-interaction, which are all annotations except
673// widget and popup annotations.
674// Return value:
675// None.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000676DLLEXPORT void STDCALL FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
677 FPDF_PAGE page,
678 const FS_MATRIX* matrix,
679 const FS_RECTF* clipping,
680 int flags);
thestiga78ba602016-11-23 15:25:48 -0800681
Cary Clark399be5b2016-03-14 16:51:29 -0400682#ifdef _SKIA_SUPPORT_
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000683DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
684 int size_x,
685 int size_y);
Cary Clark399be5b2016-03-14 16:51:29 -0400686#endif
687
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700688// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700689// Close a loaded PDF page.
690// Parameters:
691// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700692// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700693// None.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000694DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700695
696// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700697// Close a loaded PDF document.
698// Parameters:
699// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700700// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700701// None.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000702DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700703
704// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400705// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700706// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400707// page - Handle to the page. Returned by FPDF_LoadPage.
708// start_x - Left pixel position of the display area in
709// device coordinates.
710// start_y - Top pixel position of the display area in device
711// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700712// size_x - Horizontal size (in pixels) for displaying the page.
713// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400714// rotate - Page orientation:
715// 0 (normal)
716// 1 (rotated 90 degrees clockwise)
717// 2 (rotated 180 degrees)
718// 3 (rotated 90 degrees counter-clockwise)
719// device_x - X value in device coordinates to be converted.
720// device_y - Y value in device coordinates to be converted.
721// page_x - A pointer to a double receiving the converted X
722// value in page coordinates.
723// page_y - A pointer to a double receiving the converted Y
724// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700725// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700726// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700727// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400728// The page coordinate system has its origin at the left-bottom corner
729// of the page, with the X-axis on the bottom going to the right, and
730// the Y-axis on the left side going up.
731//
732// NOTE: this coordinate system can be altered when you zoom, scroll,
733// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700734// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700735//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700736// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400737// its origin is at the left-top corner of the window. However this
738// origin can be altered by the Windows coordinate transformation
739// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700740//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400741// You must make sure the start_x, start_y, size_x, size_y
742// and rotate parameters have exactly same values as you used in
743// the FPDF_RenderPage() function call.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000744DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
745 int start_x,
746 int start_y,
747 int size_x,
748 int size_y,
749 int rotate,
750 int device_x,
751 int device_y,
752 double* page_x,
753 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700754
755// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400756// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700757// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400758// page - Handle to the page. Returned by FPDF_LoadPage.
759// start_x - Left pixel position of the display area in
760// device coordinates.
761// start_y - Top pixel position of the display area in device
762// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700763// size_x - Horizontal size (in pixels) for displaying the page.
764// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400765// rotate - Page orientation:
766// 0 (normal)
767// 1 (rotated 90 degrees clockwise)
768// 2 (rotated 180 degrees)
769// 3 (rotated 90 degrees counter-clockwise)
770// page_x - X value in page coordinates.
771// page_y - Y value in page coordinate.
772// device_x - A pointer to an integer receiving the result X
773// value in device coordinates.
774// device_y - A pointer to an integer receiving the result Y
775// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700776// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700777// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700778// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400779// See comments for FPDF_DeviceToPage().
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000780DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
781 int start_x,
782 int start_y,
783 int size_x,
784 int size_y,
785 int rotate,
786 double page_x,
787 double page_y,
788 int* device_x,
789 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700790
791// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400792// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700793// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400794// width - The number of pixels in width for the bitmap.
795// Must be greater than 0.
796// height - The number of pixels in height for the bitmap.
797// Must be greater than 0.
798// alpha - A flag indicating whether the alpha channel is used.
799// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700800// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400801// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700802// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700803// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400804// The bitmap always uses 4 bytes per pixel. The first byte is always
805// double word aligned.
806//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700807// The byte order is BGRx (the last byte unused if no alpha channel) or
808// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700809//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400810// The pixels in a horizontal line are stored side by side, with the
811// left most pixel stored first (with lower memory address).
812// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700813//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400814// Lines are stored one after another, with the top most line stored
815// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700816//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700817// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400818// bitmap, but it doesn't initialize the buffer. Applications can use
819// FPDFBitmap_FillRect to fill the bitmap using any color.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000820DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
821 int height,
822 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700823
824// More DIB formats
Jane Liu28fb7ba2017-08-02 21:45:57 -0400825// Unknown or unsupported format.
826#define FPDFBitmap_Unknown 0
Dan Sinclair49f88b72015-10-20 15:18:51 -0400827// Gray scale bitmap, one byte per pixel.
828#define FPDFBitmap_Gray 1
829// 3 bytes per pixel, byte order: blue, green, red.
830#define FPDFBitmap_BGR 2
831// 4 bytes per pixel, byte order: blue, green, red, unused.
832#define FPDFBitmap_BGRx 3
833// 4 bytes per pixel, byte order: blue, green, red, alpha.
834#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700835
836// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400837// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700838// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400839// width - The number of pixels in width for the bitmap.
840// Must be greater than 0.
841// height - The number of pixels in height for the bitmap.
842// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700843// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400844// above.
845// first_scan - A pointer to the first byte of the first line if
846// using an external buffer. If this parameter is NULL,
847// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700848// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400849// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700850// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400851// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700852// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400853// Similar to FPDFBitmap_Create function, but allows for more formats
854// and an external buffer is supported. The bitmap created by this
855// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700856// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700857//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400858// If an external buffer is used, then the application should destroy
859// the buffer by itself. FPDFBitmap_Destroy function will not destroy
860// the buffer.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000861DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
862 int height,
863 int format,
864 void* first_scan,
865 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700866
Jane Liu28fb7ba2017-08-02 21:45:57 -0400867// Function: FPDFBitmap_GetFormat
868// Get the format of the bitmap.
869// Parameters:
870// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
871// or FPDFImageObj_GetBitmap.
872// Return value:
873// The format of the bitmap.
874// Comments:
875// Only formats supported by FPDFBitmap_CreateEx are supported by this
876// function; see the list of such formats above.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000877DLLEXPORT int STDCALL FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
Jane Liu28fb7ba2017-08-02 21:45:57 -0400878
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700879// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400880// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700881// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700882// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400883// FPDFBitmap_Create.
884// left - The left position. Starting from 0 at the
885// left-most pixel.
886// top - The top position. Starting from 0 at the
887// top-most line.
888// width - Width in pixels to be filled.
889// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700890// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400891// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700892// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700893// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700894// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400895// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700896// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700897//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400898// NOTE: If the alpha channel is used, this function does NOT
899// composite the background with the source color, instead the
900// background will be replaced by the source color and the alpha.
901//
902// If the alpha channel is not used, the alpha parameter is ignored.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000903DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
904 int left,
905 int top,
906 int width,
907 int height,
908 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700909
910// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400911// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700912// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400913// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
914// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700915// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700916// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700917// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700918// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400919//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700920// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400921// then manipulate any color and/or alpha values for any pixels in the
922// bitmap.
923//
924// The data is in BGRA format. Where the A maybe unused if alpha was
925// not specified.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000926DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700927
928// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400929// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700930// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400931// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
932// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700933// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400934// The width of the bitmap in pixels.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000935DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700936
937// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400938// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700939// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400940// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
941// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700942// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400943// The height of the bitmap in pixels.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000944DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700945
946// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400947// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700948// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400949// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
950// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700951// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400952// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700953// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400954// The stride may be more than width * number of bytes per pixel.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000955DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700956
957// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400958// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700959// Parameters:
Jane Liu28fb7ba2017-08-02 21:45:57 -0400960// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create
961// or FPDFImageObj_GetBitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700962// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700963// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700964// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400965// This function will not destroy any external buffers provided when
966// the bitmap was created.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000967DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700968
969// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700970// Whether the PDF document prefers to be scaled or not.
971// Parameters:
972// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700973// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700974// None.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000975DLLEXPORT FPDF_BOOL STDCALL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700976FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700977
Bo Xu9114e832014-07-14 13:22:47 -0700978// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700979// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700980// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700981// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700982// Return value:
983// The number of copies to be printed.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000984DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700985
986// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700987// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700988// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700989// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700990// Return value:
991// The print page range to be used for printing.
Henrique Nakashima7e805d12017-08-10 15:13:19 +0000992DLLEXPORT FPDF_PAGERANGE STDCALL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700993FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700994
995// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700996// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -0400997// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700998// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700999// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -07001000// Return value:
1001// The paper handling option to be used when printing.
Henrique Nakashima7e805d12017-08-10 15:13:19 +00001002DLLEXPORT FPDF_DUPLEXTYPE STDCALL
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001003FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -07001004
thestig04bebfe2016-11-04 16:07:25 -07001005// Function: FPDF_VIEWERREF_GetName
1006// Gets the contents for a viewer ref, with a given key. The value must
1007// be of type "name".
1008// Parameters:
1009// document - Handle to the loaded document.
1010// key - Name of the key in the viewer pref dictionary.
1011// buffer - A string to write the contents of the key to.
1012// length - Length of the buffer.
1013// Return value:
1014// The number of bytes in the contents, including the NULL terminator.
1015// Thus if the return value is 0, then that indicates an error, such
1016// as when |document| is invalid or |buffer| is NULL. If |length| is
1017// less than the returned length, or |buffer| is NULL, |buffer| will
1018// not be modified.
Henrique Nakashima7e805d12017-08-10 15:13:19 +00001019DLLEXPORT unsigned long STDCALL FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
1020 FPDF_BYTESTRING key,
1021 char* buffer,
1022 unsigned long length);
thestig04bebfe2016-11-04 16:07:25 -07001023
Bo Xu4d62b6b2015-01-10 22:52:59 -08001024// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -07001025// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001026// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001027// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -08001028// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -07001029// The count of named destinations.
Henrique Nakashima7e805d12017-08-10 15:13:19 +00001030DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001031
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001032// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -04001033// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -07001034// Parameters:
1035// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -04001036// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001037// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001038// The handle to the destination.
Henrique Nakashima7e805d12017-08-10 15:13:19 +00001039DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
1040 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001041
Bo Xu4d62b6b2015-01-10 22:52:59 -08001042// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -04001043// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001044// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001045// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -04001046// index - The index of a named destination.
1047// buffer - The buffer to store the destination name,
1048// used as wchar_t*.
1049// buflen [in/out] - Size of the buffer in bytes on input,
1050// length of the result in bytes on output
1051// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001052// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001053// The destination handle for a given index, or NULL if there is no
1054// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001055// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -07001056// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001057// 1) First time pass in |buffer| as NULL and get buflen.
1058// 2) Second time pass in allocated |buffer| and buflen to retrieve
1059// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001060//
Dan Sinclair49f88b72015-10-20 15:18:51 -04001061// If buflen is not sufficiently large, it will be set to -1 upon
1062// return.
Henrique Nakashima7e805d12017-08-10 15:13:19 +00001063DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
1064 int index,
1065 void* buffer,
1066 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001067
Tom Sepezc46d0002015-11-30 15:46:36 -08001068#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -07001069// Function: FPDF_BStr_Init
1070// Helper function to initialize a byte string.
Henrique Nakashima7e805d12017-08-10 15:13:19 +00001071DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
Bo Xufdc00a72014-10-28 23:03:33 -07001072
Tom Sepez9857e202015-05-13 17:09:26 -07001073// Function: FPDF_BStr_Set
1074// Helper function to set string data.
Henrique Nakashima7e805d12017-08-10 15:13:19 +00001075DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
1076 FPDF_LPCSTR bstr,
1077 int length);
Bo Xufdc00a72014-10-28 23:03:33 -07001078
Tom Sepez9857e202015-05-13 17:09:26 -07001079// Function: FPDF_BStr_Clear
1080// Helper function to clear a byte string.
Henrique Nakashima7e805d12017-08-10 15:13:19 +00001081DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -08001082#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -07001083
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001084#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -07001085}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001086#endif
1087
Tom Sepez9857e202015-05-13 17:09:26 -07001088#endif // PUBLIC_FPDFVIEW_H_