blob: 95900f3848d83a0b787a12f9449941096b921b5f [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
rbpotter38a01b92017-07-13 11:58:01 -0700248// Function: FPDF_SetPrintPostscriptLevel
249// Set postscript printing level when printing on Windows.
250// Experimental API.
251// Parameters:
252// postscript_level- 0 to disable postscript printing,
253// 2 to print with postscript level 2,
254// 3 to print with postscript level 3.
255// All other values are invalid.
256// Return value:
257// True if successful, false if unsuccessful (typically invalid input).
258DLLEXPORT FPDF_BOOL STDCALL FPDF_SetPrintPostscriptLevel(int postscript_level);
259
rbpottere8468c42017-07-11 10:04:29 -0700260// Function: FPDF_SetPrintMode
261// Set printing mode when printing on Windows.
rbpotterdb764702017-01-12 10:31:43 -0800262// Experimental API.
263// Parameters:
rbpottere8468c42017-07-11 10:04:29 -0700264// mode - FPDF_PRINTMODE_EMF to output EMF (default)
265// FPDF_PRINTMODE_TEXTONLY to output text only (for charstream
266// devices)
267// FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 postscript
268// FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 postscript
rbpotterdb764702017-01-12 10:31:43 -0800269// Return value:
rbpottere8468c42017-07-11 10:04:29 -0700270// True if successful, false if unsuccessful (typically invalid input).
271DLLEXPORT FPDF_BOOL STDCALL FPDF_SetPrintMode(int mode);
rbpotterdb764702017-01-12 10:31:43 -0800272#endif // defined(_WIN32)
thestigfdb35ff2016-07-18 13:45:44 -0700273
Tom Sepez3c3201f2015-05-20 10:20:35 -0700274// Function: FPDF_LoadDocument
275// Open and load a PDF document.
276// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400277// file_path - Path to the PDF file (including extension).
278// password - A string used as the password for the PDF file.
279// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700280// Return value:
281// A handle to the loaded document, or NULL on failure.
282// Comments:
283// Loaded document can be closed by FPDF_CloseDocument().
284// If this function fails, you can use FPDF_GetLastError() to retrieve
285// the reason why it failed.
Tom Sepez9857e202015-05-13 17:09:26 -0700286DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700287 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700288
289// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700290// Open and load a PDF document from memory.
291// Parameters:
292// data_buf - Pointer to a buffer containing the PDF document.
293// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400294// password - A string used as the password for the PDF file.
295// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700296// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400297// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700298// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700299// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400300// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700301// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400302// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700303// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800304// If PDFium is built with the XFA module, the application should call
305// FPDF_LoadXFA() function after the PDF document loaded to support XFA
306// fields defined in the fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700307DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700308 int size,
309 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700310
311// Structure for custom file access.
312typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700313 // File length, in bytes.
314 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700315
Dan Sinclair49f88b72015-10-20 15:18:51 -0400316 // A function pointer for getting a block of data from a specific position.
317 // Position is specified by byte offset from the beginning of the file.
318 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700319 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400320 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700321 // Return value: should be non-zero if successful, zero for error.
322 int (*m_GetBlock)(void* param,
323 unsigned long position,
324 unsigned char* pBuf,
325 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700326
Dan Sinclair49f88b72015-10-20 15:18:51 -0400327 // A custom pointer for all implementation specific data. This pointer will
328 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700329 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700330} FPDF_FILEACCESS;
331
Tom Sepezc46d0002015-11-30 15:46:36 -0800332#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700333/**
334 * @brief Structure for file reading or writing (I/O).
335 *
336 * @note This is a handler and should be implemented by callers.
337 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700338typedef struct _FPDF_FILEHANDLER {
339 /**
340 * @brief User-defined data.
341 * @note Callers can use this field to track controls.
342 */
343 FPDF_LPVOID clientData;
344 /**
345 * @brief Callback function to release the current file stream object.
346 *
347 * @param[in] clientData Pointer to user-defined data.
348 *
349 * @return None.
350 */
351 void (*Release)(FPDF_LPVOID clientData);
352 /**
353 * @brief Callback function to retrieve the current file stream size.
354 *
355 * @param[in] clientData Pointer to user-defined data.
356 *
357 * @return Size of file stream.
358 */
359 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
360 /**
361 * @brief Callback function to read data from the current file stream.
362 *
363 * @param[in] clientData Pointer to user-defined data.
364 * @param[in] offset Offset position starts from the beginning of file
365 * stream. This parameter indicates reading position.
366 * @param[in] buffer Memory buffer to store data which are read from
367 * file stream. This parameter should not be <b>NULL</b>.
368 * @param[in] size Size of data which should be read from file
369 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
370 * should be enough to store specified data.
371 *
372 * @return 0 for success, other value for failure.
373 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500374 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
375 FPDF_DWORD offset,
376 FPDF_LPVOID buffer,
377 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700378 /**
379 * @brief Callback function to write data into the current file stream.
380 *
381 * @param[in] clientData Pointer to user-defined data.
382 * @param[in] offset Offset position starts from the beginning of file
383 * stream. This parameter indicates writing position.
384 * @param[in] buffer Memory buffer contains data which is written into
385 * file stream. This parameter should not be <b>NULL</b>.
386 * @param[in] size Size of data which should be written into file
387 * stream, in bytes.
388 *
389 * @return 0 for success, other value for failure.
390 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500391 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
392 FPDF_DWORD offset,
393 FPDF_LPCVOID buffer,
394 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700395 /**
396 * @brief Callback function to flush all internal accessing buffers.
397 *
398 * @param[in] clientData Pointer to user-defined data.
399 *
400 * @return 0 for success, other value for failure.
401 */
402 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
403 /**
404 * @brief Callback function to change file size.
405 *
406 * @details This function is called under writing mode usually. Implementer
407 * can determine whether to realize it based on application requests.
408 *
409 * @param[in] clientData Pointer to user-defined data.
410 * @param[in] size New size of file stream, in bytes.
411 *
412 * @return 0 for success, other value for failure.
413 */
414 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700415} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
416
Tom Sepezc46d0002015-11-30 15:46:36 -0800417#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700418// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700419// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700420// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400421// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700422// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700423// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400424// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700425// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400426// The application must keep the file resources valid until the PDF
427// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700428//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400429// The loaded document can be closed with FPDF_CloseDocument.
430// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800431// If PDFium is built with the XFA module, the application should call
432// FPDF_LoadXFA() function after the PDF document loaded to support XFA
433// fields defined in the fpdfformfill.h file.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700434DLLEXPORT FPDF_DOCUMENT STDCALL
435FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700436
437// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400438// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700439// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400440// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700441// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400442// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700443// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400444// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700445// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400446// If the document was created by FPDF_CreateNewDocument,
447// then this function will always fail.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700448DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
449 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700450
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700451#define FPDF_ERR_SUCCESS 0 // No error.
452#define FPDF_ERR_UNKNOWN 1 // Unknown error.
453#define FPDF_ERR_FILE 2 // File not found or could not be opened.
454#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
455#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
456#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
457#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800458#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700459#define FPDF_ERR_XFALOAD 7 // Load XFA error.
460#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800461#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700462
463// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400464// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700465// Parameters:
466// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700467// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400468// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700469// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700470// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400471// function is not defined.
Tom Sepez9857e202015-05-13 17:09:26 -0700472DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700473
474// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700475// Get file permission flags of the document.
476// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400477// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700478// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400479// A 32-bit integer indicating permission flags. Please refer to the
480// PDF Reference for detailed descriptions. If the document is not
481// protected, 0xffffffff will be returned.
Tom Sepez9857e202015-05-13 17:09:26 -0700482DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700483
Bo Xuc5cab022014-09-19 19:16:31 -0700484// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400485// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700486// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400487// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700488// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400489// The security handler revision number. Please refer to the PDF
490// Reference for a detailed description. If the document is not
491// protected, -1 will be returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700492DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
493
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700494// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400495// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700496// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400497// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700498// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700499// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700500DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
501
502// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400503// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700504// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700505// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700506// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700507// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400508// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700509// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400510// The loaded page can be rendered to devices using FPDF_RenderPage.
511// The loaded page can be closed using FPDF_ClosePage.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700512DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
513 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700514
515// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700516// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700517// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400518// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700519// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700520// Page width (excluding non-displayable area) measured in points.
521// One point is 1/72 inch (around 0.3528 mm).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700522DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
523
524// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700525// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700526// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400527// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700528// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700529// Page height (excluding non-displayable area) measured in points.
530// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700531DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
532
533// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400534// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700535// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400536// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700537// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400538// width - Pointer to a double to receive the page width
539// (in points).
540// height - Pointer to a double to receive the page height
541// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700542// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700543// Non-zero for success. 0 for error (document or page not found).
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700544DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
545 int page_index,
546 double* width,
547 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700548
Dan Sinclair49f88b72015-10-20 15:18:51 -0400549// Page rendering flags. They can be combined with bit-wise OR.
550//
551// Set if annotations are to be rendered.
552#define FPDF_ANNOT 0x01
553// Set if using text rendering optimized for LCD display.
554#define FPDF_LCD_TEXT 0x02
555// Don't use the native text output available on some platforms
556#define FPDF_NO_NATIVETEXT 0x04
557// Grayscale output.
558#define FPDF_GRAYSCALE 0x08
559// Set if you want to get some debug info.
560#define FPDF_DEBUG_INFO 0x80
561// Set if you don't want to catch exceptions.
562#define FPDF_NO_CATCH 0x100
563// Limit image cache size.
564#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
565// Always use halftone for image stretching.
566#define FPDF_RENDER_FORCEHALFTONE 0x400
567// Render for printing.
568#define FPDF_PRINTING 0x800
569// Set to disable anti-aliasing on text.
570#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
571// Set to disable anti-aliasing on images.
572#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
573// Set to disable anti-aliasing on paths.
574#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
575// Set whether to render in a reverse Byte order, this flag is only used when
576// rendering to a bitmap.
577#define FPDF_REVERSE_BYTE_ORDER 0x10
578
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700579#ifdef _WIN32
580// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400581// Render contents of a page to a device (screen, bitmap, or printer).
582// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700583// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400584// dc - Handle to the device context.
585// page - Handle to the page. Returned by FPDF_LoadPage.
586// start_x - Left pixel position of the display area in
587// device coordinates.
588// start_y - Top pixel position of the display area in device
589// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700590// size_x - Horizontal size (in pixels) for displaying the page.
591// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400592// rotate - Page orientation:
593// 0 (normal)
594// 1 (rotated 90 degrees clockwise)
595// 2 (rotated 180 degrees)
596// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700597// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400598// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700599// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700600// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700601DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
602 FPDF_PAGE page,
603 int start_x,
604 int start_y,
605 int size_x,
606 int size_y,
607 int rotate,
608 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700609#endif
610
611// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400612// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700613// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700614// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400615// output buffer). The bitmap handle can be created
616// by FPDFBitmap_Create.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700617// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400618// start_x - Left pixel position of the display area in
619// bitmap coordinates.
620// start_y - Top pixel position of the display area in bitmap
621// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700622// size_x - Horizontal size (in pixels) for displaying the page.
623// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400624// rotate - Page orientation:
625// 0 (normal)
626// 1 (rotated 90 degrees clockwise)
627// 2 (rotated 180 degrees)
628// 3 (rotated 90 degrees counter-clockwise)
thestiga78ba602016-11-23 15:25:48 -0800629// flags - 0 for normal display, or combination of the Page
630// Rendering flags defined above. With the FPDF_ANNOT
631// flag, it renders all annotations that do not require
632// user-interaction, which are all annotations except
633// widget and popup annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700634// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700635// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700636DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
637 FPDF_PAGE page,
638 int start_x,
639 int start_y,
640 int size_x,
641 int size_y,
642 int rotate,
643 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700644
thestiga78ba602016-11-23 15:25:48 -0800645// Function: FPDF_RenderPageBitmapWithMatrix
646// Render contents of a page to a device independent bitmap.
647// Parameters:
648// bitmap - Handle to the device independent bitmap (as the
649// output buffer). The bitmap handle can be created
650// by FPDFBitmap_Create.
651// page - Handle to the page. Returned by FPDF_LoadPage
652// matrix - The transform matrix.
653// clipping - The rect to clip to.
654// flags - 0 for normal display, or combination of the Page
655// Rendering flags defined above. With the FPDF_ANNOT
656// flag, it renders all annotations that do not require
657// user-interaction, which are all annotations except
658// widget and popup annotations.
659// Return value:
660// None.
661DLLEXPORT void STDCALL FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
662 FPDF_PAGE page,
663 const FS_MATRIX* matrix,
664 const FS_RECTF* clipping,
665 int flags);
666
Cary Clark399be5b2016-03-14 16:51:29 -0400667#ifdef _SKIA_SUPPORT_
668DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
669 int size_x,
670 int size_y);
671#endif
672
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700673// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700674// Close a loaded PDF page.
675// Parameters:
676// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700677// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700678// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700679DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
680
681// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700682// Close a loaded PDF document.
683// Parameters:
684// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700685// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700686// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700687DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
688
689// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400690// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700691// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400692// page - Handle to the page. Returned by FPDF_LoadPage.
693// start_x - Left pixel position of the display area in
694// device coordinates.
695// start_y - Top pixel position of the display area in device
696// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700697// size_x - Horizontal size (in pixels) for displaying the page.
698// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400699// rotate - Page orientation:
700// 0 (normal)
701// 1 (rotated 90 degrees clockwise)
702// 2 (rotated 180 degrees)
703// 3 (rotated 90 degrees counter-clockwise)
704// device_x - X value in device coordinates to be converted.
705// device_y - Y value in device coordinates to be converted.
706// page_x - A pointer to a double receiving the converted X
707// value in page coordinates.
708// page_y - A pointer to a double receiving the converted Y
709// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700710// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700711// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700712// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400713// The page coordinate system has its origin at the left-bottom corner
714// of the page, with the X-axis on the bottom going to the right, and
715// the Y-axis on the left side going up.
716//
717// NOTE: this coordinate system can be altered when you zoom, scroll,
718// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700719// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700720//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700721// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400722// its origin is at the left-top corner of the window. However this
723// origin can be altered by the Windows coordinate transformation
724// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700725//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400726// You must make sure the start_x, start_y, size_x, size_y
727// and rotate parameters have exactly same values as you used in
728// the FPDF_RenderPage() function call.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700729DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
730 int start_x,
731 int start_y,
732 int size_x,
733 int size_y,
734 int rotate,
735 int device_x,
736 int device_y,
737 double* page_x,
738 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700739
740// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400741// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700742// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400743// page - Handle to the page. Returned by FPDF_LoadPage.
744// start_x - Left pixel position of the display area in
745// device coordinates.
746// start_y - Top pixel position of the display area in device
747// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700748// size_x - Horizontal size (in pixels) for displaying the page.
749// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400750// rotate - Page orientation:
751// 0 (normal)
752// 1 (rotated 90 degrees clockwise)
753// 2 (rotated 180 degrees)
754// 3 (rotated 90 degrees counter-clockwise)
755// page_x - X value in page coordinates.
756// page_y - Y value in page coordinate.
757// device_x - A pointer to an integer receiving the result X
758// value in device coordinates.
759// device_y - A pointer to an integer receiving the result Y
760// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700761// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700762// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700763// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400764// See comments for FPDF_DeviceToPage().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700765DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
766 int start_x,
767 int start_y,
768 int size_x,
769 int size_y,
770 int rotate,
771 double page_x,
772 double page_y,
773 int* device_x,
774 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700775
776// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400777// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700778// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400779// width - The number of pixels in width for the bitmap.
780// Must be greater than 0.
781// height - The number of pixels in height for the bitmap.
782// Must be greater than 0.
783// alpha - A flag indicating whether the alpha channel is used.
784// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700785// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400786// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700787// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700788// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400789// The bitmap always uses 4 bytes per pixel. The first byte is always
790// double word aligned.
791//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700792// The byte order is BGRx (the last byte unused if no alpha channel) or
793// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700794//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400795// The pixels in a horizontal line are stored side by side, with the
796// left most pixel stored first (with lower memory address).
797// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700798//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400799// Lines are stored one after another, with the top most line stored
800// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700801//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700802// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400803// bitmap, but it doesn't initialize the buffer. Applications can use
804// FPDFBitmap_FillRect to fill the bitmap using any color.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700805DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
806 int height,
807 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700808
809// More DIB formats
Dan Sinclair49f88b72015-10-20 15:18:51 -0400810// Gray scale bitmap, one byte per pixel.
811#define FPDFBitmap_Gray 1
812// 3 bytes per pixel, byte order: blue, green, red.
813#define FPDFBitmap_BGR 2
814// 4 bytes per pixel, byte order: blue, green, red, unused.
815#define FPDFBitmap_BGRx 3
816// 4 bytes per pixel, byte order: blue, green, red, alpha.
817#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700818
819// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400820// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700821// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400822// width - The number of pixels in width for the bitmap.
823// Must be greater than 0.
824// height - The number of pixels in height for the bitmap.
825// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700826// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400827// above.
828// first_scan - A pointer to the first byte of the first line if
829// using an external buffer. If this parameter is NULL,
830// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700831// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400832// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700833// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400834// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700835// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400836// Similar to FPDFBitmap_Create function, but allows for more formats
837// and an external buffer is supported. The bitmap created by this
838// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700839// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700840//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400841// If an external buffer is used, then the application should destroy
842// the buffer by itself. FPDFBitmap_Destroy function will not destroy
843// the buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700844DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
845 int height,
846 int format,
847 void* first_scan,
848 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700849
850// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400851// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700852// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700853// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400854// FPDFBitmap_Create.
855// left - The left position. Starting from 0 at the
856// left-most pixel.
857// top - The top position. Starting from 0 at the
858// top-most line.
859// width - Width in pixels to be filled.
860// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700861// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400862// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700863// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700864// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700865// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400866// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700867// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700868//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400869// NOTE: If the alpha channel is used, this function does NOT
870// composite the background with the source color, instead the
871// background will be replaced by the source color and the alpha.
872//
873// If the alpha channel is not used, the alpha parameter is ignored.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700874DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
875 int left,
876 int top,
877 int width,
878 int height,
879 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700880
881// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400882// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700883// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400884// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700885// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700886// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700887// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700888// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400889//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700890// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400891// then manipulate any color and/or alpha values for any pixels in the
892// bitmap.
893//
894// The data is in BGRA format. Where the A maybe unused if alpha was
895// not specified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700896DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
897
898// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400899// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700900// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400901// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700902// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400903// The width of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700904DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
905
906// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400907// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700908// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400909// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700910// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400911// The height of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700912DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
913
914// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400915// Get number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700916// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400917// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700918// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400919// The number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700920// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400921// The stride may be more than width * number of bytes per pixel.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700922DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
923
924// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400925// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700926// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400927// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700928// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700929// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700930// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400931// This function will not destroy any external buffers provided when
932// the bitmap was created.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700933DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
934
935// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700936// Whether the PDF document prefers to be scaled or not.
937// Parameters:
938// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700939// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700940// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700941DLLEXPORT FPDF_BOOL STDCALL
942FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700943
Bo Xu9114e832014-07-14 13:22:47 -0700944// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700945// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700946// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700947// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700948// Return value:
949// The number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700950DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
951
952// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700953// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700954// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700955// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700956// Return value:
957// The print page range to be used for printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700958DLLEXPORT FPDF_PAGERANGE STDCALL
959FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700960
961// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700962// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -0400963// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700964// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700965// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700966// Return value:
967// The paper handling option to be used when printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700968DLLEXPORT FPDF_DUPLEXTYPE STDCALL
969FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700970
thestig04bebfe2016-11-04 16:07:25 -0700971// Function: FPDF_VIEWERREF_GetName
972// Gets the contents for a viewer ref, with a given key. The value must
973// be of type "name".
974// Parameters:
975// document - Handle to the loaded document.
976// key - Name of the key in the viewer pref dictionary.
977// buffer - A string to write the contents of the key to.
978// length - Length of the buffer.
979// Return value:
980// The number of bytes in the contents, including the NULL terminator.
981// Thus if the return value is 0, then that indicates an error, such
982// as when |document| is invalid or |buffer| is NULL. If |length| is
983// less than the returned length, or |buffer| is NULL, |buffer| will
984// not be modified.
985DLLEXPORT unsigned long STDCALL FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
986 FPDF_BYTESTRING key,
987 char* buffer,
988 unsigned long length);
989
Bo Xu4d62b6b2015-01-10 22:52:59 -0800990// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700991// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800992// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700993// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800994// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700995// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800996DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
997
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700998// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -0400999// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -07001000// Parameters:
1001// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -04001002// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001003// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001004// The handle to the destination.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001005DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
1006 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001007
Bo Xu4d62b6b2015-01-10 22:52:59 -08001008// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -04001009// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001010// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -07001011// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -04001012// index - The index of a named destination.
1013// buffer - The buffer to store the destination name,
1014// used as wchar_t*.
1015// buflen [in/out] - Size of the buffer in bytes on input,
1016// length of the result in bytes on output
1017// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001018// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001019// The destination handle for a given index, or NULL if there is no
1020// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001021// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -07001022// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001023// 1) First time pass in |buffer| as NULL and get buflen.
1024// 2) Second time pass in allocated |buffer| and buflen to retrieve
1025// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001026//
Dan Sinclair49f88b72015-10-20 15:18:51 -04001027// If buflen is not sufficiently large, it will be set to -1 upon
1028// return.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001029DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
1030 int index,
1031 void* buffer,
1032 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001033
Tom Sepezc46d0002015-11-30 15:46:36 -08001034#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -07001035// Function: FPDF_BStr_Init
1036// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -07001037DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
1038
Tom Sepez9857e202015-05-13 17:09:26 -07001039// Function: FPDF_BStr_Set
1040// Helper function to set string data.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001041DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
1042 FPDF_LPCSTR bstr,
1043 int length);
Bo Xufdc00a72014-10-28 23:03:33 -07001044
Tom Sepez9857e202015-05-13 17:09:26 -07001045// Function: FPDF_BStr_Clear
1046// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -07001047DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -08001048#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -07001049
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001050#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -07001051}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001052#endif
1053
Tom Sepez9857e202015-05-13 17:09:26 -07001054#endif // PUBLIC_FPDFVIEW_H_