blob: df46e9700bc9951beabce3016f80139b20fb7e5c [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Tom Sepez9857e202015-05-13 17:09:26 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez1ed8a212015-05-11 15:25:39 -07007// NOTE: External docs refer to this file as "fpdfview.h", so do not rename
Dan Sinclair50cce602016-02-24 09:51:16 -05008// despite lack of consistency with other public files.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Tom Sepez9857e202015-05-13 17:09:26 -070010#ifndef PUBLIC_FPDFVIEW_H_
11#define PUBLIC_FPDFVIEW_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070012
13#if defined(_WIN32) && !defined(__WINDOWS__)
14#include <windows.h>
15#endif
16
Tom Sepezc46d0002015-11-30 15:46:36 -080017#ifdef PDF_ENABLE_XFA
Dan Sinclair3ebd1212016-03-09 09:59:23 -050018// PDF_USE_XFA is set in confirmation that this version of PDFium can support
19// XFA forms as requested by the PDF_ENABLE_XFA setting.
Bo Xubb5ef882014-11-06 16:13:33 -080020#define PDF_USE_XFA
Tom Sepezc46d0002015-11-30 15:46:36 -080021#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022
23// PDF types
Tom Sepez9857e202015-05-13 17:09:26 -070024typedef void* FPDF_ACTION;
Jane Liu4fd9a472017-06-01 18:56:09 -040025typedef void* FPDF_ANNOTATION;
Tom Sepezc46d0002015-11-30 15:46:36 -080026typedef void* FPDF_BITMAP;
27typedef void* FPDF_BOOKMARK;
28typedef void* FPDF_CLIPPATH;
29typedef void* FPDF_DEST;
Tom Sepezc46d0002015-11-30 15:46:36 -080030typedef void* FPDF_DOCUMENT;
31typedef void* FPDF_FONT;
Tom Sepez9857e202015-05-13 17:09:26 -070032typedef void* FPDF_LINK;
Tom Sepezc46d0002015-11-30 15:46:36 -080033typedef void* FPDF_PAGE;
34typedef void* FPDF_PAGELINK;
35typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
Tom Sepez9857e202015-05-13 17:09:26 -070036typedef void* FPDF_PAGERANGE;
Cary Clark399be5b2016-03-14 16:51:29 -040037typedef void* FPDF_RECORDER;
Tom Sepezc46d0002015-11-30 15:46:36 -080038typedef void* FPDF_SCHHANDLE;
thestig9067fd62016-11-23 14:10:06 -080039typedef void* FPDF_STRUCTELEMENT;
40typedef void* FPDF_STRUCTTREE;
Tom Sepezc46d0002015-11-30 15:46:36 -080041typedef void* FPDF_TEXTPAGE;
42
43#ifdef PDF_ENABLE_XFA
44typedef void* FPDF_STRINGHANDLE;
45typedef void* FPDF_WIDGET;
46#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070047
48// Basic data types
Tom Sepez9857e202015-05-13 17:09:26 -070049typedef int FPDF_BOOL;
50typedef int FPDF_ERROR;
51typedef unsigned long FPDF_DWORD;
52typedef float FS_FLOAT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070053
Tom Sepezc46d0002015-11-30 15:46:36 -080054#ifdef PDF_ENABLE_XFA
55typedef void* FPDF_LPVOID;
56typedef void const* FPDF_LPCVOID;
57typedef char const* FPDF_LPCSTR;
58typedef int FPDF_RESULT;
59#endif
60
Bo Xu9114e832014-07-14 13:22:47 -070061// Duplex types
62typedef enum _FPDF_DUPLEXTYPE_ {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070063 DuplexUndefined = 0,
64 Simplex,
65 DuplexFlipShortEdge,
66 DuplexFlipLongEdge
Bo Xu9114e832014-07-14 13:22:47 -070067} FPDF_DUPLEXTYPE;
68
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070069// String types
Tom Sepez9857e202015-05-13 17:09:26 -070070typedef unsigned short FPDF_WCHAR;
71typedef unsigned char const* FPDF_LPCBYTE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070072
Nico Weber9d8ec5a2015-08-04 13:00:21 -070073// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
74// encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070075typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070076
Dan Sinclair49f88b72015-10-20 15:18:51 -040077// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
78// bytes (except surrogation), with the low byte first.
79typedef const unsigned short* FPDF_WIDESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070080
Tom Sepezc46d0002015-11-30 15:46:36 -080081#ifdef PDF_ENABLE_XFA
Dan Sinclair49f88b72015-10-20 15:18:51 -040082// Structure for a byte string.
83// Note, a byte string commonly means a UTF-16LE formated string.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070084typedef struct _FPDF_BSTR {
Dan Sinclair49f88b72015-10-20 15:18:51 -040085 // String buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070086 char* str;
Dan Sinclair49f88b72015-10-20 15:18:51 -040087 // Length of the string, in bytes.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070088 int len;
Bo Xufdc00a72014-10-28 23:03:33 -070089} FPDF_BSTR;
Tom Sepezc46d0002015-11-30 15:46:36 -080090#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -070091
Dan Sinclair49f88b72015-10-20 15:18:51 -040092// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
93// Windows unicode string, however, special care needs to be taken if you
94// expect to process Unicode larger than 0xffff.
95//
96// For Linux/Unix programmers: most compiler/library environments use 4 bytes
97// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
98// system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070099typedef const char* FPDF_STRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700100
Dan Sinclair49f88b72015-10-20 15:18:51 -0400101// Matrix for transformation.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102typedef struct _FS_MATRIX_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400103 float a;
104 float b;
105 float c;
106 float d;
107 float e;
108 float f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700109} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700110
Dan Sinclair49f88b72015-10-20 15:18:51 -0400111// Rectangle area(float) in device or page coordinate system.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112typedef struct _FS_RECTF_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400113 // The x-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700114 float left;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400115 // The y-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 float top;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400117 // The x-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700118 float right;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400119 // The y-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700120 float bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121} * FS_LPRECTF, FS_RECTF;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400122
123// Const Pointer to FS_RECTF structure.
Tom Sepez9857e202015-05-13 17:09:26 -0700124typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700125
Jane Liu4fd9a472017-06-01 18:56:09 -0400126// Annotation subtype.
127typedef int FPDF_ANNOTATION_SUBTYPE;
128
Jane Liu2e1a32b2017-07-06 12:01:25 -0400129// Dictionary value types.
130typedef int FPDF_OBJECT_TYPE;
131
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700132#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
133// On Windows system, functions are exported in a DLL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700134#define DLLEXPORT __declspec(dllexport)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700135#define STDCALL __stdcall
136#else
137#define DLLEXPORT
138#define STDCALL
139#endif
140
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700141// Exported Functions
142#ifdef __cplusplus
143extern "C" {
144#endif
145
146// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700147// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700148// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700149// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700150// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700151// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700152// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700153// Convenience function to call FPDF_InitLibraryWithConfig() for
154// backwards comatibility purposes.
155DLLEXPORT void STDCALL FPDF_InitLibrary();
156
Dan Sinclair49f88b72015-10-20 15:18:51 -0400157// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700158typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700159 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700160 int version;
161
162 // Array of paths to scan in place of the defaults when using built-in
163 // FXGE font loading code. The array is terminated by a NULL pointer.
164 // The Array may be NULL itself to use the default paths. May be ignored
165 // entirely depending upon the platform.
166 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700167
168 // Version 2.
169
170 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
171 void* m_pIsolate;
172
173 // The embedder data slot to use in the v8::Isolate to store PDFium's
174 // per-isolate data. The value needs to be between 0 and
175 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
176 // for most embedders.
177 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700178} FPDF_LIBRARY_CONFIG;
179
180// Function: FPDF_InitLibraryWithConfig
181// Initialize the FPDFSDK library
182// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400183// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700184// Return value:
185// None.
186// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700187// You have to call this function before you can call any PDF
188// processing functions.
Tom Sepez326a2a72015-11-20 10:47:32 -0800189DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
190 const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700191
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700192// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700193// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700194// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700195// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700196// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700197// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700198// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700199// You can call this function to release all memory blocks allocated by
200// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400201// After this function is called, you should not call any PDF
202// processing functions.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700203DLLEXPORT void STDCALL FPDF_DestroyLibrary();
204
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700205// Policy for accessing the local machine time.
206#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700207
208// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700209// Set the policy for the sandbox environment.
210// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400211// policy - The specified policy for setting, for example:
212// FPDF_POLICY_MACHINETIME_ACCESS.
213// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700214// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700215// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700216DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
217 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700218
rbpotterdb764702017-01-12 10:31:43 -0800219#if defined(_WIN32)
220#if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
thestigfdb35ff2016-07-18 13:45:44 -0700221// Pointer to a helper function to make |font| with |text| of |text_length|
222// accessible when printing text with GDI. This is useful in sandboxed
223// environments where PDFium's access to GDI may be restricted.
224typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
225 const wchar_t* text,
226 size_t text_length);
227
228// Function: FPDF_SetTypefaceAccessibleFunc
229// Set the function pointer that makes GDI fonts available in sandboxed
230// environments. Experimental API.
231// Parameters:
232// func - A function pointer. See description above.
233// Return value:
234// None.
235DLLEXPORT void STDCALL
236FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func);
237
238// Function: FPDF_SetPrintTextWithGDI
239// Set whether to use GDI to draw fonts when printing on Windows.
240// Experimental API.
241// Parameters:
242// use_gdi - Set to true to enable printing text with GDI.
243// Return value:
244// None.
245DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi);
rbpotterdb764702017-01-12 10:31:43 -0800246#endif // PDFIUM_PRINT_TEXT_WITH_GDI
247
rbpottere8468c42017-07-11 10:04:29 -0700248// Function: FPDF_SetPrintMode
249// Set printing mode when printing on Windows.
rbpotterdb764702017-01-12 10:31:43 -0800250// Experimental API.
251// Parameters:
rbpottere8468c42017-07-11 10:04:29 -0700252// mode - FPDF_PRINTMODE_EMF to output EMF (default)
253// FPDF_PRINTMODE_TEXTONLY to output text only (for charstream
254// devices)
255// FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 postscript
256// FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 postscript
rbpotterdb764702017-01-12 10:31:43 -0800257// Return value:
rbpottere8468c42017-07-11 10:04:29 -0700258// True if successful, false if unsuccessful (typically invalid input).
259DLLEXPORT FPDF_BOOL STDCALL FPDF_SetPrintMode(int mode);
rbpotterdb764702017-01-12 10:31:43 -0800260#endif // defined(_WIN32)
thestigfdb35ff2016-07-18 13:45:44 -0700261
Tom Sepez3c3201f2015-05-20 10:20:35 -0700262// Function: FPDF_LoadDocument
263// Open and load a PDF document.
264// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400265// file_path - Path to the PDF file (including extension).
266// password - A string used as the password for the PDF file.
267// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700268// Return value:
269// A handle to the loaded document, or NULL on failure.
270// Comments:
271// Loaded document can be closed by FPDF_CloseDocument().
272// If this function fails, you can use FPDF_GetLastError() to retrieve
273// the reason why it failed.
Tom Sepez9857e202015-05-13 17:09:26 -0700274DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700275 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700276
277// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700278// Open and load a PDF document from memory.
279// Parameters:
280// data_buf - Pointer to a buffer containing the PDF document.
281// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400282// password - A string used as the password for the PDF file.
283// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700284// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400285// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700286// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700287// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400288// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700289// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400290// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700291// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800292// If PDFium is built with the XFA module, the application should call
293// FPDF_LoadXFA() function after the PDF document loaded to support XFA
294// fields defined in the fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700295DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700296 int size,
297 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700298
299// Structure for custom file access.
300typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700301 // File length, in bytes.
302 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700303
Dan Sinclair49f88b72015-10-20 15:18:51 -0400304 // A function pointer for getting a block of data from a specific position.
305 // Position is specified by byte offset from the beginning of the file.
306 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700307 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400308 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700309 // Return value: should be non-zero if successful, zero for error.
310 int (*m_GetBlock)(void* param,
311 unsigned long position,
312 unsigned char* pBuf,
313 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700314
Dan Sinclair49f88b72015-10-20 15:18:51 -0400315 // A custom pointer for all implementation specific data. This pointer will
316 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700317 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700318} FPDF_FILEACCESS;
319
Tom Sepezc46d0002015-11-30 15:46:36 -0800320#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700321/**
322 * @brief Structure for file reading or writing (I/O).
323 *
324 * @note This is a handler and should be implemented by callers.
325 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700326typedef struct _FPDF_FILEHANDLER {
327 /**
328 * @brief User-defined data.
329 * @note Callers can use this field to track controls.
330 */
331 FPDF_LPVOID clientData;
332 /**
333 * @brief Callback function to release the current file stream object.
334 *
335 * @param[in] clientData Pointer to user-defined data.
336 *
337 * @return None.
338 */
339 void (*Release)(FPDF_LPVOID clientData);
340 /**
341 * @brief Callback function to retrieve the current file stream size.
342 *
343 * @param[in] clientData Pointer to user-defined data.
344 *
345 * @return Size of file stream.
346 */
347 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
348 /**
349 * @brief Callback function to read data from the current file stream.
350 *
351 * @param[in] clientData Pointer to user-defined data.
352 * @param[in] offset Offset position starts from the beginning of file
353 * stream. This parameter indicates reading position.
354 * @param[in] buffer Memory buffer to store data which are read from
355 * file stream. This parameter should not be <b>NULL</b>.
356 * @param[in] size Size of data which should be read from file
357 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
358 * should be enough to store specified data.
359 *
360 * @return 0 for success, other value for failure.
361 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500362 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
363 FPDF_DWORD offset,
364 FPDF_LPVOID buffer,
365 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700366 /**
367 * @brief Callback function to write data into the current file stream.
368 *
369 * @param[in] clientData Pointer to user-defined data.
370 * @param[in] offset Offset position starts from the beginning of file
371 * stream. This parameter indicates writing position.
372 * @param[in] buffer Memory buffer contains data which is written into
373 * file stream. This parameter should not be <b>NULL</b>.
374 * @param[in] size Size of data which should be written into file
375 * stream, in bytes.
376 *
377 * @return 0 for success, other value for failure.
378 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500379 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
380 FPDF_DWORD offset,
381 FPDF_LPCVOID buffer,
382 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700383 /**
384 * @brief Callback function to flush all internal accessing buffers.
385 *
386 * @param[in] clientData Pointer to user-defined data.
387 *
388 * @return 0 for success, other value for failure.
389 */
390 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
391 /**
392 * @brief Callback function to change file size.
393 *
394 * @details This function is called under writing mode usually. Implementer
395 * can determine whether to realize it based on application requests.
396 *
397 * @param[in] clientData Pointer to user-defined data.
398 * @param[in] size New size of file stream, in bytes.
399 *
400 * @return 0 for success, other value for failure.
401 */
402 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700403} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
404
Tom Sepezc46d0002015-11-30 15:46:36 -0800405#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700406// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700407// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700408// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400409// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700410// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700411// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400412// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700413// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400414// The application must keep the file resources valid until the PDF
415// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700416//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400417// The loaded document can be closed with FPDF_CloseDocument.
418// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800419// If PDFium is built with the XFA module, the application should call
420// FPDF_LoadXFA() function after the PDF document loaded to support XFA
421// fields defined in the fpdfformfill.h file.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700422DLLEXPORT FPDF_DOCUMENT STDCALL
423FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700424
425// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400426// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700427// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400428// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700429// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400430// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700431// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400432// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700433// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400434// If the document was created by FPDF_CreateNewDocument,
435// then this function will always fail.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700436DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
437 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700438
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700439#define FPDF_ERR_SUCCESS 0 // No error.
440#define FPDF_ERR_UNKNOWN 1 // Unknown error.
441#define FPDF_ERR_FILE 2 // File not found or could not be opened.
442#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
443#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
444#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
445#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800446#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700447#define FPDF_ERR_XFALOAD 7 // Load XFA error.
448#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800449#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700450
451// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400452// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700453// Parameters:
454// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700455// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400456// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700457// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700458// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400459// function is not defined.
Tom Sepez9857e202015-05-13 17:09:26 -0700460DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700461
462// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700463// Get file permission flags of the document.
464// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400465// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700466// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400467// A 32-bit integer indicating permission flags. Please refer to the
468// PDF Reference for detailed descriptions. If the document is not
469// protected, 0xffffffff will be returned.
Tom Sepez9857e202015-05-13 17:09:26 -0700470DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700471
Bo Xuc5cab022014-09-19 19:16:31 -0700472// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400473// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700474// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400475// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700476// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400477// The security handler revision number. Please refer to the PDF
478// Reference for a detailed description. If the document is not
479// protected, -1 will be returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700480DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
481
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700482// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400483// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700484// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400485// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700486// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700487// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700488DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
489
490// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400491// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700492// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700493// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700494// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700495// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400496// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700497// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400498// The loaded page can be rendered to devices using FPDF_RenderPage.
499// The loaded page can be closed using FPDF_ClosePage.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700500DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
501 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700502
503// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700504// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700505// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400506// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700507// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700508// Page width (excluding non-displayable area) measured in points.
509// One point is 1/72 inch (around 0.3528 mm).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700510DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
511
512// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700513// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700514// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400515// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700516// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700517// Page height (excluding non-displayable area) measured in points.
518// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700519DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
520
521// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400522// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700523// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400524// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700525// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400526// width - Pointer to a double to receive the page width
527// (in points).
528// height - Pointer to a double to receive the page height
529// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700530// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700531// Non-zero for success. 0 for error (document or page not found).
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700532DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
533 int page_index,
534 double* width,
535 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700536
Dan Sinclair49f88b72015-10-20 15:18:51 -0400537// Page rendering flags. They can be combined with bit-wise OR.
538//
539// Set if annotations are to be rendered.
540#define FPDF_ANNOT 0x01
541// Set if using text rendering optimized for LCD display.
542#define FPDF_LCD_TEXT 0x02
543// Don't use the native text output available on some platforms
544#define FPDF_NO_NATIVETEXT 0x04
545// Grayscale output.
546#define FPDF_GRAYSCALE 0x08
547// Set if you want to get some debug info.
548#define FPDF_DEBUG_INFO 0x80
549// Set if you don't want to catch exceptions.
550#define FPDF_NO_CATCH 0x100
551// Limit image cache size.
552#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
553// Always use halftone for image stretching.
554#define FPDF_RENDER_FORCEHALFTONE 0x400
555// Render for printing.
556#define FPDF_PRINTING 0x800
557// Set to disable anti-aliasing on text.
558#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
559// Set to disable anti-aliasing on images.
560#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
561// Set to disable anti-aliasing on paths.
562#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
563// Set whether to render in a reverse Byte order, this flag is only used when
564// rendering to a bitmap.
565#define FPDF_REVERSE_BYTE_ORDER 0x10
566
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700567#ifdef _WIN32
568// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400569// Render contents of a page to a device (screen, bitmap, or printer).
570// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700571// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400572// dc - Handle to the device context.
573// page - Handle to the page. Returned by FPDF_LoadPage.
574// start_x - Left pixel position of the display area in
575// device coordinates.
576// start_y - Top pixel position of the display area in device
577// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700578// size_x - Horizontal size (in pixels) for displaying the page.
579// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400580// rotate - Page orientation:
581// 0 (normal)
582// 1 (rotated 90 degrees clockwise)
583// 2 (rotated 180 degrees)
584// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700585// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400586// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700587// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700588// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700589DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
590 FPDF_PAGE page,
591 int start_x,
592 int start_y,
593 int size_x,
594 int size_y,
595 int rotate,
596 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700597#endif
598
599// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400600// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700601// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700602// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400603// output buffer). The bitmap handle can be created
604// by FPDFBitmap_Create.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700605// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400606// start_x - Left pixel position of the display area in
607// bitmap coordinates.
608// start_y - Top pixel position of the display area in bitmap
609// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700610// size_x - Horizontal size (in pixels) for displaying the page.
611// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400612// rotate - Page orientation:
613// 0 (normal)
614// 1 (rotated 90 degrees clockwise)
615// 2 (rotated 180 degrees)
616// 3 (rotated 90 degrees counter-clockwise)
thestiga78ba602016-11-23 15:25:48 -0800617// flags - 0 for normal display, or combination of the Page
618// Rendering flags defined above. With the FPDF_ANNOT
619// flag, it renders all annotations that do not require
620// user-interaction, which are all annotations except
621// widget and popup annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700622// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700623// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700624DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
625 FPDF_PAGE page,
626 int start_x,
627 int start_y,
628 int size_x,
629 int size_y,
630 int rotate,
631 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700632
thestiga78ba602016-11-23 15:25:48 -0800633// Function: FPDF_RenderPageBitmapWithMatrix
634// Render contents of a page to a device independent bitmap.
635// Parameters:
636// bitmap - Handle to the device independent bitmap (as the
637// output buffer). The bitmap handle can be created
638// by FPDFBitmap_Create.
639// page - Handle to the page. Returned by FPDF_LoadPage
640// matrix - The transform matrix.
641// clipping - The rect to clip to.
642// flags - 0 for normal display, or combination of the Page
643// Rendering flags defined above. With the FPDF_ANNOT
644// flag, it renders all annotations that do not require
645// user-interaction, which are all annotations except
646// widget and popup annotations.
647// Return value:
648// None.
649DLLEXPORT void STDCALL FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
650 FPDF_PAGE page,
651 const FS_MATRIX* matrix,
652 const FS_RECTF* clipping,
653 int flags);
654
Cary Clark399be5b2016-03-14 16:51:29 -0400655#ifdef _SKIA_SUPPORT_
656DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
657 int size_x,
658 int size_y);
659#endif
660
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700661// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700662// Close a loaded PDF page.
663// Parameters:
664// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700665// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700666// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700667DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
668
669// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700670// Close a loaded PDF document.
671// Parameters:
672// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700673// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700674// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700675DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
676
677// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400678// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700679// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400680// page - Handle to the page. Returned by FPDF_LoadPage.
681// start_x - Left pixel position of the display area in
682// device coordinates.
683// start_y - Top pixel position of the display area in device
684// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700685// size_x - Horizontal size (in pixels) for displaying the page.
686// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400687// rotate - Page orientation:
688// 0 (normal)
689// 1 (rotated 90 degrees clockwise)
690// 2 (rotated 180 degrees)
691// 3 (rotated 90 degrees counter-clockwise)
692// device_x - X value in device coordinates to be converted.
693// device_y - Y value in device coordinates to be converted.
694// page_x - A pointer to a double receiving the converted X
695// value in page coordinates.
696// page_y - A pointer to a double receiving the converted Y
697// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700698// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700699// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700700// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400701// The page coordinate system has its origin at the left-bottom corner
702// of the page, with the X-axis on the bottom going to the right, and
703// the Y-axis on the left side going up.
704//
705// NOTE: this coordinate system can be altered when you zoom, scroll,
706// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700707// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700708//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700709// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400710// its origin is at the left-top corner of the window. However this
711// origin can be altered by the Windows coordinate transformation
712// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700713//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400714// You must make sure the start_x, start_y, size_x, size_y
715// and rotate parameters have exactly same values as you used in
716// the FPDF_RenderPage() function call.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700717DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
718 int start_x,
719 int start_y,
720 int size_x,
721 int size_y,
722 int rotate,
723 int device_x,
724 int device_y,
725 double* page_x,
726 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700727
728// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400729// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700730// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400731// page - Handle to the page. Returned by FPDF_LoadPage.
732// start_x - Left pixel position of the display area in
733// device coordinates.
734// start_y - Top pixel position of the display area in device
735// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700736// size_x - Horizontal size (in pixels) for displaying the page.
737// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400738// rotate - Page orientation:
739// 0 (normal)
740// 1 (rotated 90 degrees clockwise)
741// 2 (rotated 180 degrees)
742// 3 (rotated 90 degrees counter-clockwise)
743// page_x - X value in page coordinates.
744// page_y - Y value in page coordinate.
745// device_x - A pointer to an integer receiving the result X
746// value in device coordinates.
747// device_y - A pointer to an integer receiving the result Y
748// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700749// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700750// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700751// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400752// See comments for FPDF_DeviceToPage().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700753DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
754 int start_x,
755 int start_y,
756 int size_x,
757 int size_y,
758 int rotate,
759 double page_x,
760 double page_y,
761 int* device_x,
762 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700763
764// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400765// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700766// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400767// width - The number of pixels in width for the bitmap.
768// Must be greater than 0.
769// height - The number of pixels in height for the bitmap.
770// Must be greater than 0.
771// alpha - A flag indicating whether the alpha channel is used.
772// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700773// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400774// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700775// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700776// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400777// The bitmap always uses 4 bytes per pixel. The first byte is always
778// double word aligned.
779//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700780// The byte order is BGRx (the last byte unused if no alpha channel) or
781// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700782//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400783// The pixels in a horizontal line are stored side by side, with the
784// left most pixel stored first (with lower memory address).
785// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700786//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400787// Lines are stored one after another, with the top most line stored
788// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700789//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700790// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400791// bitmap, but it doesn't initialize the buffer. Applications can use
792// FPDFBitmap_FillRect to fill the bitmap using any color.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700793DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
794 int height,
795 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700796
797// More DIB formats
Dan Sinclair49f88b72015-10-20 15:18:51 -0400798// Gray scale bitmap, one byte per pixel.
799#define FPDFBitmap_Gray 1
800// 3 bytes per pixel, byte order: blue, green, red.
801#define FPDFBitmap_BGR 2
802// 4 bytes per pixel, byte order: blue, green, red, unused.
803#define FPDFBitmap_BGRx 3
804// 4 bytes per pixel, byte order: blue, green, red, alpha.
805#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700806
807// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400808// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700809// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400810// width - The number of pixels in width for the bitmap.
811// Must be greater than 0.
812// height - The number of pixels in height for the bitmap.
813// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700814// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400815// above.
816// first_scan - A pointer to the first byte of the first line if
817// using an external buffer. If this parameter is NULL,
818// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700819// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400820// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700821// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400822// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700823// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400824// Similar to FPDFBitmap_Create function, but allows for more formats
825// and an external buffer is supported. The bitmap created by this
826// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700827// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700828//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400829// If an external buffer is used, then the application should destroy
830// the buffer by itself. FPDFBitmap_Destroy function will not destroy
831// the buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700832DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
833 int height,
834 int format,
835 void* first_scan,
836 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700837
838// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400839// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700840// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700841// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400842// FPDFBitmap_Create.
843// left - The left position. Starting from 0 at the
844// left-most pixel.
845// top - The top position. Starting from 0 at the
846// top-most line.
847// width - Width in pixels to be filled.
848// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700849// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400850// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700851// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700852// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700853// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400854// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700855// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700856//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400857// NOTE: If the alpha channel is used, this function does NOT
858// composite the background with the source color, instead the
859// background will be replaced by the source color and the alpha.
860//
861// If the alpha channel is not used, the alpha parameter is ignored.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700862DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
863 int left,
864 int top,
865 int width,
866 int height,
867 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700868
869// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400870// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700871// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400872// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700873// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700874// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700875// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700876// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400877//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700878// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400879// then manipulate any color and/or alpha values for any pixels in the
880// bitmap.
881//
882// The data is in BGRA format. Where the A maybe unused if alpha was
883// not specified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700884DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
885
886// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400887// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700888// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400889// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700890// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400891// The width of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700892DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
893
894// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400895// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700896// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400897// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700898// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400899// The height of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700900DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
901
902// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400903// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700904// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400905// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700906// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400907// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700908// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400909// The stride may be more than width * number of bytes per pixel.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700910DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
911
912// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400913// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700914// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400915// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700916// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700917// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700918// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400919// This function will not destroy any external buffers provided when
920// the bitmap was created.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700921DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
922
923// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700924// Whether the PDF document prefers to be scaled or not.
925// Parameters:
926// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700927// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700928// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700929DLLEXPORT FPDF_BOOL STDCALL
930FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700931
Bo Xu9114e832014-07-14 13:22:47 -0700932// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700933// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700934// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700935// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700936// Return value:
937// The number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700938DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
939
940// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700941// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700942// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700943// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700944// Return value:
945// The print page range to be used for printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700946DLLEXPORT FPDF_PAGERANGE STDCALL
947FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700948
949// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700950// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -0400951// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700952// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700953// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700954// Return value:
955// The paper handling option to be used when printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700956DLLEXPORT FPDF_DUPLEXTYPE STDCALL
957FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700958
thestig04bebfe2016-11-04 16:07:25 -0700959// Function: FPDF_VIEWERREF_GetName
960// Gets the contents for a viewer ref, with a given key. The value must
961// be of type "name".
962// Parameters:
963// document - Handle to the loaded document.
964// key - Name of the key in the viewer pref dictionary.
965// buffer - A string to write the contents of the key to.
966// length - Length of the buffer.
967// Return value:
968// The number of bytes in the contents, including the NULL terminator.
969// Thus if the return value is 0, then that indicates an error, such
970// as when |document| is invalid or |buffer| is NULL. If |length| is
971// less than the returned length, or |buffer| is NULL, |buffer| will
972// not be modified.
973DLLEXPORT unsigned long STDCALL FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
974 FPDF_BYTESTRING key,
975 char* buffer,
976 unsigned long length);
977
Bo Xu4d62b6b2015-01-10 22:52:59 -0800978// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700979// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800980// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700981// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800982// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700983// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800984DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
985
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700986// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -0400987// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -0700988// Parameters:
989// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400990// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700991// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400992// The handle to the destination.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700993DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
994 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700995
Bo Xu4d62b6b2015-01-10 22:52:59 -0800996// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -0400997// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800998// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700999// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -04001000// index - The index of a named destination.
1001// buffer - The buffer to store the destination name,
1002// used as wchar_t*.
1003// buflen [in/out] - Size of the buffer in bytes on input,
1004// length of the result in bytes on output
1005// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001006// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001007// The destination handle for a given index, or NULL if there is no
1008// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001009// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -07001010// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001011// 1) First time pass in |buffer| as NULL and get buflen.
1012// 2) Second time pass in allocated |buffer| and buflen to retrieve
1013// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001014//
Dan Sinclair49f88b72015-10-20 15:18:51 -04001015// If buflen is not sufficiently large, it will be set to -1 upon
1016// return.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001017DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
1018 int index,
1019 void* buffer,
1020 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001021
Tom Sepezc46d0002015-11-30 15:46:36 -08001022#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -07001023// Function: FPDF_BStr_Init
1024// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -07001025DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
1026
Tom Sepez9857e202015-05-13 17:09:26 -07001027// Function: FPDF_BStr_Set
1028// Helper function to set string data.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001029DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
1030 FPDF_LPCSTR bstr,
1031 int length);
Bo Xufdc00a72014-10-28 23:03:33 -07001032
Tom Sepez9857e202015-05-13 17:09:26 -07001033// Function: FPDF_BStr_Clear
1034// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -07001035DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -08001036#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -07001037
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001038#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -07001039}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001040#endif
1041
Tom Sepez9857e202015-05-13 17:09:26 -07001042#endif // PUBLIC_FPDFVIEW_H_