blob: 7378d5f9b114812465544064fb5887379fead5aa [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;
Tom Sepezc46d0002015-11-30 15:46:36 -080025typedef void* FPDF_BITMAP;
26typedef void* FPDF_BOOKMARK;
27typedef void* FPDF_CLIPPATH;
28typedef void* FPDF_DEST;
29typedef void* FPDF_DOCSCHHANDLE;
30typedef void* FPDF_DOCUMENT;
31typedef void* FPDF_FONT;
32typedef void* FPDF_HMODULE;
Tom Sepez9857e202015-05-13 17:09:26 -070033typedef void* FPDF_LINK;
Tom Sepezc46d0002015-11-30 15:46:36 -080034typedef void* FPDF_MODULEMGR;
35typedef void* FPDF_PAGE;
36typedef void* FPDF_PAGELINK;
37typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
Tom Sepez9857e202015-05-13 17:09:26 -070038typedef void* FPDF_PAGERANGE;
Tom Sepezc46d0002015-11-30 15:46:36 -080039typedef void* FPDF_PATH;
Cary Clark399be5b2016-03-14 16:51:29 -040040typedef void* FPDF_RECORDER;
Tom Sepezc46d0002015-11-30 15:46:36 -080041typedef void* FPDF_SCHHANDLE;
thestig9067fd62016-11-23 14:10:06 -080042typedef void* FPDF_STRUCTELEMENT;
43typedef void* FPDF_STRUCTTREE;
Tom Sepezc46d0002015-11-30 15:46:36 -080044typedef void* FPDF_TEXTPAGE;
45
46#ifdef PDF_ENABLE_XFA
47typedef void* FPDF_STRINGHANDLE;
48typedef void* FPDF_WIDGET;
49#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070050
51// Basic data types
Tom Sepez9857e202015-05-13 17:09:26 -070052typedef int FPDF_BOOL;
53typedef int FPDF_ERROR;
54typedef unsigned long FPDF_DWORD;
55typedef float FS_FLOAT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070056
Tom Sepezc46d0002015-11-30 15:46:36 -080057#ifdef PDF_ENABLE_XFA
58typedef void* FPDF_LPVOID;
59typedef void const* FPDF_LPCVOID;
60typedef char const* FPDF_LPCSTR;
61typedef int FPDF_RESULT;
62#endif
63
Bo Xu9114e832014-07-14 13:22:47 -070064// Duplex types
65typedef enum _FPDF_DUPLEXTYPE_ {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070066 DuplexUndefined = 0,
67 Simplex,
68 DuplexFlipShortEdge,
69 DuplexFlipLongEdge
Bo Xu9114e832014-07-14 13:22:47 -070070} FPDF_DUPLEXTYPE;
71
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070072// String types
Tom Sepez9857e202015-05-13 17:09:26 -070073typedef unsigned short FPDF_WCHAR;
74typedef unsigned char const* FPDF_LPCBYTE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070075
Nico Weber9d8ec5a2015-08-04 13:00:21 -070076// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
77// encoded), and platform dependent string
Tom Sepez9857e202015-05-13 17:09:26 -070078typedef const char* FPDF_BYTESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070079
Dan Sinclair49f88b72015-10-20 15:18:51 -040080// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
81// bytes (except surrogation), with the low byte first.
82typedef const unsigned short* FPDF_WIDESTRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070083
Tom Sepezc46d0002015-11-30 15:46:36 -080084#ifdef PDF_ENABLE_XFA
Dan Sinclair49f88b72015-10-20 15:18:51 -040085// Structure for a byte string.
86// Note, a byte string commonly means a UTF-16LE formated string.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070087typedef struct _FPDF_BSTR {
Dan Sinclair49f88b72015-10-20 15:18:51 -040088 // String buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070089 char* str;
Dan Sinclair49f88b72015-10-20 15:18:51 -040090 // Length of the string, in bytes.
Nico Weber9d8ec5a2015-08-04 13:00:21 -070091 int len;
Bo Xufdc00a72014-10-28 23:03:33 -070092} FPDF_BSTR;
Tom Sepezc46d0002015-11-30 15:46:36 -080093#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -070094
Dan Sinclair49f88b72015-10-20 15:18:51 -040095// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
96// Windows unicode string, however, special care needs to be taken if you
97// expect to process Unicode larger than 0xffff.
98//
99// For Linux/Unix programmers: most compiler/library environments use 4 bytes
100// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
101// system wide string by yourself.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700102typedef const char* FPDF_STRING;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700103
Dan Sinclair49f88b72015-10-20 15:18:51 -0400104// Matrix for transformation.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700105typedef struct _FS_MATRIX_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400106 float a;
107 float b;
108 float c;
109 float d;
110 float e;
111 float f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700112} FS_MATRIX;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113
Dan Sinclair49f88b72015-10-20 15:18:51 -0400114// Rectangle area(float) in device or page coordinate system.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700115typedef struct _FS_RECTF_ {
Dan Sinclair49f88b72015-10-20 15:18:51 -0400116 // The x-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700117 float left;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400118 // The y-coordinate of the left-top corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700119 float top;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400120 // The x-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121 float right;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400122 // The y-coordinate of the right-bottom corner.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700123 float bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700124} * FS_LPRECTF, FS_RECTF;
Dan Sinclair49f88b72015-10-20 15:18:51 -0400125
126// Const Pointer to FS_RECTF structure.
Tom Sepez9857e202015-05-13 17:09:26 -0700127typedef const FS_RECTF* FS_LPCRECTF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700128
129#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
130// On Windows system, functions are exported in a DLL
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700131#define DLLEXPORT __declspec(dllexport)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700132#define STDCALL __stdcall
133#else
134#define DLLEXPORT
135#define STDCALL
136#endif
137
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700138// Exported Functions
139#ifdef __cplusplus
140extern "C" {
141#endif
142
143// Function: FPDF_InitLibrary
Tom Sepez9857e202015-05-13 17:09:26 -0700144// Initialize the FPDFSDK library
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700145// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700146// None
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700147// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700148// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700149// Comments:
Lei Zhang6f62d532015-09-23 15:31:44 -0700150// Convenience function to call FPDF_InitLibraryWithConfig() for
151// backwards comatibility purposes.
152DLLEXPORT void STDCALL FPDF_InitLibrary();
153
Dan Sinclair49f88b72015-10-20 15:18:51 -0400154// Process-wide options for initializing the library.
Lei Zhang6f62d532015-09-23 15:31:44 -0700155typedef struct FPDF_LIBRARY_CONFIG_ {
Tom Sepeza72e8e22015-10-07 10:17:53 -0700156 // Version number of the interface. Currently must be 2.
Lei Zhang6f62d532015-09-23 15:31:44 -0700157 int version;
158
159 // Array of paths to scan in place of the defaults when using built-in
160 // FXGE font loading code. The array is terminated by a NULL pointer.
161 // The Array may be NULL itself to use the default paths. May be ignored
162 // entirely depending upon the platform.
163 const char** m_pUserFontPaths;
Tom Sepeza72e8e22015-10-07 10:17:53 -0700164
165 // Version 2.
166
167 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
168 void* m_pIsolate;
169
170 // The embedder data slot to use in the v8::Isolate to store PDFium's
171 // per-isolate data. The value needs to be between 0 and
172 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine
173 // for most embedders.
174 unsigned int m_v8EmbedderSlot;
Lei Zhang6f62d532015-09-23 15:31:44 -0700175} FPDF_LIBRARY_CONFIG;
176
177// Function: FPDF_InitLibraryWithConfig
178// Initialize the FPDFSDK library
179// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400180// config - configuration information as above.
Lei Zhang6f62d532015-09-23 15:31:44 -0700181// Return value:
182// None.
183// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700184// You have to call this function before you can call any PDF
185// processing functions.
Tom Sepez326a2a72015-11-20 10:47:32 -0800186DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
187 const FPDF_LIBRARY_CONFIG* config);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700188
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189// Function: FPDF_DestroyLibary
Tom Sepez9857e202015-05-13 17:09:26 -0700190// Release all resources allocated by the FPDFSDK library.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700191// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700192// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700193// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700194// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700195// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700196// You can call this function to release all memory blocks allocated by
197// the library.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400198// After this function is called, you should not call any PDF
199// processing functions.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700200DLLEXPORT void STDCALL FPDF_DestroyLibrary();
201
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700202// Policy for accessing the local machine time.
203#define FPDF_POLICY_MACHINETIME_ACCESS 0
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700204
205// Function: FPDF_SetSandBoxPolicy
Tom Sepez9857e202015-05-13 17:09:26 -0700206// Set the policy for the sandbox environment.
207// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400208// policy - The specified policy for setting, for example:
209// FPDF_POLICY_MACHINETIME_ACCESS.
210// enable - True to enable, false to disable the policy.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700211// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700212// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700213DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
214 FPDF_BOOL enable);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700215
rbpotterdb764702017-01-12 10:31:43 -0800216#if defined(_WIN32)
217#if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
thestigfdb35ff2016-07-18 13:45:44 -0700218// Pointer to a helper function to make |font| with |text| of |text_length|
219// accessible when printing text with GDI. This is useful in sandboxed
220// environments where PDFium's access to GDI may be restricted.
221typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
222 const wchar_t* text,
223 size_t text_length);
224
225// Function: FPDF_SetTypefaceAccessibleFunc
226// Set the function pointer that makes GDI fonts available in sandboxed
227// environments. Experimental API.
228// Parameters:
229// func - A function pointer. See description above.
230// Return value:
231// None.
232DLLEXPORT void STDCALL
233FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func);
234
235// Function: FPDF_SetPrintTextWithGDI
236// Set whether to use GDI to draw fonts when printing on Windows.
237// Experimental API.
238// Parameters:
239// use_gdi - Set to true to enable printing text with GDI.
240// Return value:
241// None.
242DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi);
rbpotterdb764702017-01-12 10:31:43 -0800243#endif // PDFIUM_PRINT_TEXT_WITH_GDI
244
245// Function: FPDF_SetPrintPostscriptLevel
246// Set postscript printing level when printing on Windows.
247// Experimental API.
248// Parameters:
249// postscript_level - 0 to disable postscript printing,
250// 2 to print with postscript level 2,
251// 3 to print with postscript level 3.
252// All other values are invalid.
253// Return value:
254// True if successful, false if unsucessful (typically invalid input).
255DLLEXPORT FPDF_BOOL STDCALL FPDF_SetPrintPostscriptLevel(FPDF_BOOL use_gdi);
256#endif // defined(_WIN32)
thestigfdb35ff2016-07-18 13:45:44 -0700257
Tom Sepez3c3201f2015-05-20 10:20:35 -0700258// Function: FPDF_LoadDocument
259// Open and load a PDF document.
260// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400261// file_path - Path to the PDF file (including extension).
262// password - A string used as the password for the PDF file.
263// If no password is needed, empty or NULL can be used.
Tom Sepez3c3201f2015-05-20 10:20:35 -0700264// Return value:
265// A handle to the loaded document, or NULL on failure.
266// Comments:
267// Loaded document can be closed by FPDF_CloseDocument().
268// If this function fails, you can use FPDF_GetLastError() to retrieve
269// the reason why it failed.
Tom Sepez9857e202015-05-13 17:09:26 -0700270DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700271 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700272
273// Function: FPDF_LoadMemDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700274// Open and load a PDF document from memory.
275// Parameters:
276// data_buf - Pointer to a buffer containing the PDF document.
277// size - Number of bytes in the PDF document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400278// password - A string used as the password for the PDF file.
279// If no password is needed, empty or NULL can be used.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700280// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400281// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700282// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700283// The memory buffer must remain valid when the document is open.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400284// The loaded document can be closed by FPDF_CloseDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700285// If this function fails, you can use FPDF_GetLastError() to retrieve
Dan Sinclair49f88b72015-10-20 15:18:51 -0400286// the reason why it failed.
Bo Xufdc00a72014-10-28 23:03:33 -0700287// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800288// If PDFium is built with the XFA module, the application should call
289// FPDF_LoadXFA() function after the PDF document loaded to support XFA
290// fields defined in the fpdfformfill.h file.
Tom Sepez9857e202015-05-13 17:09:26 -0700291DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700292 int size,
293 FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700294
295// Structure for custom file access.
296typedef struct {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700297 // File length, in bytes.
298 unsigned long m_FileLen;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700299
Dan Sinclair49f88b72015-10-20 15:18:51 -0400300 // A function pointer for getting a block of data from a specific position.
301 // Position is specified by byte offset from the beginning of the file.
302 // The position and size will never go out of range of the file length.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700303 // It may be possible for FPDFSDK to call this function multiple times for
Dan Sinclair49f88b72015-10-20 15:18:51 -0400304 // the same position.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700305 // Return value: should be non-zero if successful, zero for error.
306 int (*m_GetBlock)(void* param,
307 unsigned long position,
308 unsigned char* pBuf,
309 unsigned long size);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700310
Dan Sinclair49f88b72015-10-20 15:18:51 -0400311 // A custom pointer for all implementation specific data. This pointer will
312 // be used as the first parameter to the m_GetBlock callback.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700313 void* m_Param;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700314} FPDF_FILEACCESS;
315
Tom Sepezc46d0002015-11-30 15:46:36 -0800316#ifdef PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -0700317/**
318 * @brief Structure for file reading or writing (I/O).
319 *
320 * @note This is a handler and should be implemented by callers.
321 */
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700322typedef struct _FPDF_FILEHANDLER {
323 /**
324 * @brief User-defined data.
325 * @note Callers can use this field to track controls.
326 */
327 FPDF_LPVOID clientData;
328 /**
329 * @brief Callback function to release the current file stream object.
330 *
331 * @param[in] clientData Pointer to user-defined data.
332 *
333 * @return None.
334 */
335 void (*Release)(FPDF_LPVOID clientData);
336 /**
337 * @brief Callback function to retrieve the current file stream size.
338 *
339 * @param[in] clientData Pointer to user-defined data.
340 *
341 * @return Size of file stream.
342 */
343 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
344 /**
345 * @brief Callback function to read data from the current file stream.
346 *
347 * @param[in] clientData Pointer to user-defined data.
348 * @param[in] offset Offset position starts from the beginning of file
349 * stream. This parameter indicates reading position.
350 * @param[in] buffer Memory buffer to store data which are read from
351 * file stream. This parameter should not be <b>NULL</b>.
352 * @param[in] size Size of data which should be read from file
353 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i>
354 * should be enough to store specified data.
355 *
356 * @return 0 for success, other value for failure.
357 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500358 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData,
359 FPDF_DWORD offset,
360 FPDF_LPVOID buffer,
361 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700362 /**
363 * @brief Callback function to write data into the current file stream.
364 *
365 * @param[in] clientData Pointer to user-defined data.
366 * @param[in] offset Offset position starts from the beginning of file
367 * stream. This parameter indicates writing position.
368 * @param[in] buffer Memory buffer contains data which is written into
369 * file stream. This parameter should not be <b>NULL</b>.
370 * @param[in] size Size of data which should be written into file
371 * stream, in bytes.
372 *
373 * @return 0 for success, other value for failure.
374 */
Dan Sinclair3ebd1212016-03-09 09:59:23 -0500375 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData,
376 FPDF_DWORD offset,
377 FPDF_LPCVOID buffer,
378 FPDF_DWORD size);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700379 /**
380 * @brief Callback function to flush all internal accessing buffers.
381 *
382 * @param[in] clientData Pointer to user-defined data.
383 *
384 * @return 0 for success, other value for failure.
385 */
386 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
387 /**
388 * @brief Callback function to change file size.
389 *
390 * @details This function is called under writing mode usually. Implementer
391 * can determine whether to realize it based on application requests.
392 *
393 * @param[in] clientData Pointer to user-defined data.
394 * @param[in] size New size of file stream, in bytes.
395 *
396 * @return 0 for success, other value for failure.
397 */
398 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
Bo Xufdc00a72014-10-28 23:03:33 -0700399} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
400
Tom Sepezc46d0002015-11-30 15:46:36 -0800401#endif
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700402// Function: FPDF_LoadCustomDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700403// Load PDF document from a custom access descriptor.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700404// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400405// pFileAccess - A structure for accessing the file.
Tom Sepez9857e202015-05-13 17:09:26 -0700406// password - Optional password for decrypting the PDF file.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700407// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400408// A handle to the loaded document, or NULL on failure.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700409// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400410// The application must keep the file resources valid until the PDF
411// document is closed.
Bo Xufdc00a72014-10-28 23:03:33 -0700412//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400413// The loaded document can be closed with FPDF_CloseDocument.
414// Notes:
Tom Sepezc46d0002015-11-30 15:46:36 -0800415// If PDFium is built with the XFA module, the application should call
416// FPDF_LoadXFA() function after the PDF document loaded to support XFA
417// fields defined in the fpdfformfill.h file.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700418DLLEXPORT FPDF_DOCUMENT STDCALL
419FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700420
421// Function: FPDF_GetFileVersion
Dan Sinclair49f88b72015-10-20 15:18:51 -0400422// Get the file version of the given PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700423// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400424// doc - Handle to a document.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700425// fileVersion - The PDF file version. File version: 14 for 1.4, 15
Dan Sinclair49f88b72015-10-20 15:18:51 -0400426// for 1.5, ...
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700427// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400428// True if succeeds, false otherwise.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700429// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400430// If the document was created by FPDF_CreateNewDocument,
431// then this function will always fail.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700432DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
433 int* fileVersion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700434
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700435#define FPDF_ERR_SUCCESS 0 // No error.
436#define FPDF_ERR_UNKNOWN 1 // Unknown error.
437#define FPDF_ERR_FILE 2 // File not found or could not be opened.
438#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
439#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
440#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
441#define FPDF_ERR_PAGE 6 // Page not found or content error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800442#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700443#define FPDF_ERR_XFALOAD 7 // Load XFA error.
444#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
Tom Sepezc46d0002015-11-30 15:46:36 -0800445#endif // PDF_ENABLE_XFA
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700446
447// Function: FPDF_GetLastError
Dan Sinclair49f88b72015-10-20 15:18:51 -0400448// Get last error code when a function fails.
Tom Sepez9857e202015-05-13 17:09:26 -0700449// Parameters:
450// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700451// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400452// A 32-bit integer indicating error code as defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700453// Comments:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700454// If the previous SDK call succeeded, the return value of this
Dan Sinclair49f88b72015-10-20 15:18:51 -0400455// function is not defined.
Tom Sepez9857e202015-05-13 17:09:26 -0700456DLLEXPORT unsigned long STDCALL FPDF_GetLastError();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700457
458// Function: FPDF_GetDocPermission
Tom Sepez9857e202015-05-13 17:09:26 -0700459// Get file permission flags of the document.
460// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400461// document - Handle to a document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700462// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400463// A 32-bit integer indicating permission flags. Please refer to the
464// PDF Reference for detailed descriptions. If the document is not
465// protected, 0xffffffff will be returned.
Tom Sepez9857e202015-05-13 17:09:26 -0700466DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700467
Bo Xuc5cab022014-09-19 19:16:31 -0700468// Function: FPDF_GetSecurityHandlerRevision
Dan Sinclair49f88b72015-10-20 15:18:51 -0400469// Get the revision for the security handler.
Bo Xuc5cab022014-09-19 19:16:31 -0700470// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400471// document - Handle to a document. Returned by FPDF_LoadDocument.
Bo Xuc5cab022014-09-19 19:16:31 -0700472// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400473// The security handler revision number. Please refer to the PDF
474// Reference for a detailed description. If the document is not
475// protected, -1 will be returned.
Bo Xuc5cab022014-09-19 19:16:31 -0700476DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
477
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700478// Function: FPDF_GetPageCount
Dan Sinclair49f88b72015-10-20 15:18:51 -0400479// Get total number of pages in the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700480// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400481// document - Handle to document. Returned by FPDF_LoadDocument.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700482// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700483// Total number of pages in the document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700484DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);
485
486// Function: FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400487// Load a page inside the document.
Tom Sepez9857e202015-05-13 17:09:26 -0700488// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700489// document - Handle to document. Returned by FPDF_LoadDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700490// page_index - Index number of the page. 0 for the first page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700491// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400492// A handle to the loaded page, or NULL if page load fails.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700493// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400494// The loaded page can be rendered to devices using FPDF_RenderPage.
495// The loaded page can be closed using FPDF_ClosePage.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700496DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
497 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700498
499// Function: FPDF_GetPageWidth
Tom Sepez9857e202015-05-13 17:09:26 -0700500// Get page width.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700501// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400502// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700503// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700504// Page width (excluding non-displayable area) measured in points.
505// One point is 1/72 inch (around 0.3528 mm).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700506DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);
507
508// Function: FPDF_GetPageHeight
Tom Sepez9857e202015-05-13 17:09:26 -0700509// Get page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700510// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400511// page - Handle to the page. Returned by FPDF_LoadPage.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700512// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700513// Page height (excluding non-displayable area) measured in points.
514// One point is 1/72 inch (around 0.3528 mm)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700515DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);
516
517// Function: FPDF_GetPageSizeByIndex
Dan Sinclair49f88b72015-10-20 15:18:51 -0400518// Get the size of the page at the given index.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700519// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400520// document - Handle to document. Returned by FPDF_LoadDocument.
Tom Sepez9857e202015-05-13 17:09:26 -0700521// page_index - Page index, zero for the first page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400522// width - Pointer to a double to receive the page width
523// (in points).
524// height - Pointer to a double to receive the page height
525// (in points).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700526// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700527// Non-zero for success. 0 for error (document or page not found).
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700528DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
529 int page_index,
530 double* width,
531 double* height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700532
Dan Sinclair49f88b72015-10-20 15:18:51 -0400533// Page rendering flags. They can be combined with bit-wise OR.
534//
535// Set if annotations are to be rendered.
536#define FPDF_ANNOT 0x01
537// Set if using text rendering optimized for LCD display.
538#define FPDF_LCD_TEXT 0x02
539// Don't use the native text output available on some platforms
540#define FPDF_NO_NATIVETEXT 0x04
541// Grayscale output.
542#define FPDF_GRAYSCALE 0x08
543// Set if you want to get some debug info.
544#define FPDF_DEBUG_INFO 0x80
545// Set if you don't want to catch exceptions.
546#define FPDF_NO_CATCH 0x100
547// Limit image cache size.
548#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
549// Always use halftone for image stretching.
550#define FPDF_RENDER_FORCEHALFTONE 0x400
551// Render for printing.
552#define FPDF_PRINTING 0x800
553// Set to disable anti-aliasing on text.
554#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
555// Set to disable anti-aliasing on images.
556#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
557// Set to disable anti-aliasing on paths.
558#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
559// Set whether to render in a reverse Byte order, this flag is only used when
560// rendering to a bitmap.
561#define FPDF_REVERSE_BYTE_ORDER 0x10
562
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700563#ifdef _WIN32
564// Function: FPDF_RenderPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400565// Render contents of a page to a device (screen, bitmap, or printer).
566// This function is only supported on Windows.
Tom Sepez9857e202015-05-13 17:09:26 -0700567// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400568// dc - Handle to the device context.
569// page - Handle to the page. Returned by FPDF_LoadPage.
570// start_x - Left pixel position of the display area in
571// device coordinates.
572// start_y - Top pixel position of the display area in device
573// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700574// size_x - Horizontal size (in pixels) for displaying the page.
575// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400576// rotate - Page orientation:
577// 0 (normal)
578// 1 (rotated 90 degrees clockwise)
579// 2 (rotated 180 degrees)
580// 3 (rotated 90 degrees counter-clockwise)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700581// flags - 0 for normal display, or combination of flags
Dan Sinclair49f88b72015-10-20 15:18:51 -0400582// defined above.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700583// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700584// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700585DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
586 FPDF_PAGE page,
587 int start_x,
588 int start_y,
589 int size_x,
590 int size_y,
591 int rotate,
592 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700593#endif
594
595// Function: FPDF_RenderPageBitmap
Dan Sinclair49f88b72015-10-20 15:18:51 -0400596// Render contents of a page to a device independent bitmap.
Tom Sepez9857e202015-05-13 17:09:26 -0700597// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700598// bitmap - Handle to the device independent bitmap (as the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400599// output buffer). The bitmap handle can be created
600// by FPDFBitmap_Create.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700601// page - Handle to the page. Returned by FPDF_LoadPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400602// start_x - Left pixel position of the display area in
603// bitmap coordinates.
604// start_y - Top pixel position of the display area in bitmap
605// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700606// size_x - Horizontal size (in pixels) for displaying the page.
607// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400608// rotate - Page orientation:
609// 0 (normal)
610// 1 (rotated 90 degrees clockwise)
611// 2 (rotated 180 degrees)
612// 3 (rotated 90 degrees counter-clockwise)
thestiga78ba602016-11-23 15:25:48 -0800613// flags - 0 for normal display, or combination of the Page
614// Rendering flags defined above. With the FPDF_ANNOT
615// flag, it renders all annotations that do not require
616// user-interaction, which are all annotations except
617// widget and popup annotations.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700618// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700619// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700620DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
621 FPDF_PAGE page,
622 int start_x,
623 int start_y,
624 int size_x,
625 int size_y,
626 int rotate,
627 int flags);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700628
thestiga78ba602016-11-23 15:25:48 -0800629// Function: FPDF_RenderPageBitmapWithMatrix
630// Render contents of a page to a device independent bitmap.
631// Parameters:
632// bitmap - Handle to the device independent bitmap (as the
633// output buffer). The bitmap handle can be created
634// by FPDFBitmap_Create.
635// page - Handle to the page. Returned by FPDF_LoadPage
636// matrix - The transform matrix.
637// clipping - The rect to clip to.
638// flags - 0 for normal display, or combination of the Page
639// Rendering flags defined above. With the FPDF_ANNOT
640// flag, it renders all annotations that do not require
641// user-interaction, which are all annotations except
642// widget and popup annotations.
643// Return value:
644// None.
645DLLEXPORT void STDCALL FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
646 FPDF_PAGE page,
647 const FS_MATRIX* matrix,
648 const FS_RECTF* clipping,
649 int flags);
650
Cary Clark399be5b2016-03-14 16:51:29 -0400651#ifdef _SKIA_SUPPORT_
652DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
653 int size_x,
654 int size_y);
655#endif
656
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700657// Function: FPDF_ClosePage
Tom Sepez9857e202015-05-13 17:09:26 -0700658// Close a loaded PDF page.
659// Parameters:
660// page - Handle to the loaded page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700661// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700662// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700663DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page);
664
665// Function: FPDF_CloseDocument
Tom Sepez9857e202015-05-13 17:09:26 -0700666// Close a loaded PDF document.
667// Parameters:
668// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700669// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700670// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700671DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document);
672
673// Function: FPDF_DeviceToPage
Dan Sinclair49f88b72015-10-20 15:18:51 -0400674// Convert the screen coordinates of a point to page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700675// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400676// page - Handle to the page. Returned by FPDF_LoadPage.
677// start_x - Left pixel position of the display area in
678// device coordinates.
679// start_y - Top pixel position of the display area in device
680// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700681// size_x - Horizontal size (in pixels) for displaying the page.
682// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400683// rotate - Page orientation:
684// 0 (normal)
685// 1 (rotated 90 degrees clockwise)
686// 2 (rotated 180 degrees)
687// 3 (rotated 90 degrees counter-clockwise)
688// device_x - X value in device coordinates to be converted.
689// device_y - Y value in device coordinates to be converted.
690// page_x - A pointer to a double receiving the converted X
691// value in page coordinates.
692// page_y - A pointer to a double receiving the converted Y
693// value in page coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700694// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700695// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700696// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400697// The page coordinate system has its origin at the left-bottom corner
698// of the page, with the X-axis on the bottom going to the right, and
699// the Y-axis on the left side going up.
700//
701// NOTE: this coordinate system can be altered when you zoom, scroll,
702// or rotate a page, however, a point on the page should always have
Tom Sepez9857e202015-05-13 17:09:26 -0700703// the same coordinate values in the page coordinate system.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700704//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700705// The device coordinate system is device dependent. For screen device,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400706// its origin is at the left-top corner of the window. However this
707// origin can be altered by the Windows coordinate transformation
708// utilities.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700709//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400710// You must make sure the start_x, start_y, size_x, size_y
711// and rotate parameters have exactly same values as you used in
712// the FPDF_RenderPage() function call.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700713DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
714 int start_x,
715 int start_y,
716 int size_x,
717 int size_y,
718 int rotate,
719 int device_x,
720 int device_y,
721 double* page_x,
722 double* page_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700723
724// Function: FPDF_PageToDevice
Dan Sinclair49f88b72015-10-20 15:18:51 -0400725// Convert the page coordinates of a point to screen coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700726// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400727// page - Handle to the page. Returned by FPDF_LoadPage.
728// start_x - Left pixel position of the display area in
729// device coordinates.
730// start_y - Top pixel position of the display area in device
731// coordinates.
Tom Sepez9857e202015-05-13 17:09:26 -0700732// size_x - Horizontal size (in pixels) for displaying the page.
733// size_y - Vertical size (in pixels) for displaying the page.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400734// rotate - Page orientation:
735// 0 (normal)
736// 1 (rotated 90 degrees clockwise)
737// 2 (rotated 180 degrees)
738// 3 (rotated 90 degrees counter-clockwise)
739// page_x - X value in page coordinates.
740// page_y - Y value in page coordinate.
741// device_x - A pointer to an integer receiving the result X
742// value in device coordinates.
743// device_y - A pointer to an integer receiving the result Y
744// value in device coordinates.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700745// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700746// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700747// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400748// See comments for FPDF_DeviceToPage().
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700749DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
750 int start_x,
751 int start_y,
752 int size_x,
753 int size_y,
754 int rotate,
755 double page_x,
756 double page_y,
757 int* device_x,
758 int* device_y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700759
760// Function: FPDFBitmap_Create
Dan Sinclair49f88b72015-10-20 15:18:51 -0400761// Create a device independent bitmap (FXDIB).
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700762// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400763// width - The number of pixels in width for the bitmap.
764// Must be greater than 0.
765// height - The number of pixels in height for the bitmap.
766// Must be greater than 0.
767// alpha - A flag indicating whether the alpha channel is used.
768// Non-zero for using alpha, zero for not using.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700769// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400770// The created bitmap handle, or NULL if a parameter error or out of
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700771// memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700772// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400773// The bitmap always uses 4 bytes per pixel. The first byte is always
774// double word aligned.
775//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700776// The byte order is BGRx (the last byte unused if no alpha channel) or
777// BGRA.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700778//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400779// The pixels in a horizontal line are stored side by side, with the
780// left most pixel stored first (with lower memory address).
781// Each line uses width * 4 bytes.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700782//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400783// Lines are stored one after another, with the top most line stored
784// first. There is no gap between adjacent lines.
Tom Sepez9857e202015-05-13 17:09:26 -0700785//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700786// This function allocates enough memory for holding all pixels in the
Dan Sinclair49f88b72015-10-20 15:18:51 -0400787// bitmap, but it doesn't initialize the buffer. Applications can use
788// FPDFBitmap_FillRect to fill the bitmap using any color.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700789DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
790 int height,
791 int alpha);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700792
793// More DIB formats
Dan Sinclair49f88b72015-10-20 15:18:51 -0400794// Gray scale bitmap, one byte per pixel.
795#define FPDFBitmap_Gray 1
796// 3 bytes per pixel, byte order: blue, green, red.
797#define FPDFBitmap_BGR 2
798// 4 bytes per pixel, byte order: blue, green, red, unused.
799#define FPDFBitmap_BGRx 3
800// 4 bytes per pixel, byte order: blue, green, red, alpha.
801#define FPDFBitmap_BGRA 4
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700802
803// Function: FPDFBitmap_CreateEx
Dan Sinclair49f88b72015-10-20 15:18:51 -0400804// Create a device independent bitmap (FXDIB)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700805// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400806// width - The number of pixels in width for the bitmap.
807// Must be greater than 0.
808// height - The number of pixels in height for the bitmap.
809// Must be greater than 0.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700810// format - A number indicating for bitmap format, as defined
Dan Sinclair49f88b72015-10-20 15:18:51 -0400811// above.
812// first_scan - A pointer to the first byte of the first line if
813// using an external buffer. If this parameter is NULL,
814// then the a new buffer will be created.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700815// stride - Number of bytes for each scan line, for external
Dan Sinclair49f88b72015-10-20 15:18:51 -0400816// buffer only.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700817// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400818// The bitmap handle, or NULL if parameter error or out of memory.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700819// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400820// Similar to FPDFBitmap_Create function, but allows for more formats
821// and an external buffer is supported. The bitmap created by this
822// function can be used in any place that a FPDF_BITMAP handle is
Tom Sepez9857e202015-05-13 17:09:26 -0700823// required.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700824//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400825// If an external buffer is used, then the application should destroy
826// the buffer by itself. FPDFBitmap_Destroy function will not destroy
827// the buffer.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700828DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width,
829 int height,
830 int format,
831 void* first_scan,
832 int stride);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700833
834// Function: FPDFBitmap_FillRect
Dan Sinclair49f88b72015-10-20 15:18:51 -0400835// Fill a rectangle in a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700836// Parameters:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700837// bitmap - The handle to the bitmap. Returned by
Dan Sinclair49f88b72015-10-20 15:18:51 -0400838// FPDFBitmap_Create.
839// left - The left position. Starting from 0 at the
840// left-most pixel.
841// top - The top position. Starting from 0 at the
842// top-most line.
843// width - Width in pixels to be filled.
844// height - Height in pixels to be filled.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700845// color - A 32-bit value specifing the color, in 8888 ARGB
Dan Sinclair49f88b72015-10-20 15:18:51 -0400846// format.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700847// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700848// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700849// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400850// This function sets the color and (optionally) alpha value in the
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700851// specified region of the bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700852//
Dan Sinclair49f88b72015-10-20 15:18:51 -0400853// NOTE: If the alpha channel is used, this function does NOT
854// composite the background with the source color, instead the
855// background will be replaced by the source color and the alpha.
856//
857// If the alpha channel is not used, the alpha parameter is ignored.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700858DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
859 int left,
860 int top,
861 int width,
862 int height,
863 FPDF_DWORD color);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700864
865// Function: FPDFBitmap_GetBuffer
Dan Sinclair49f88b72015-10-20 15:18:51 -0400866// Get data buffer of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700867// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400868// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700869// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700870// The pointer to the first byte of the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700871// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -0700872// The stride may be more than width * number of bytes per pixel
Dan Sinclair49f88b72015-10-20 15:18:51 -0400873//
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700874// Applications can use this function to get the bitmap buffer pointer,
Dan Sinclair49f88b72015-10-20 15:18:51 -0400875// then manipulate any color and/or alpha values for any pixels in the
876// bitmap.
877//
878// The data is in BGRA format. Where the A maybe unused if alpha was
879// not specified.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700880DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
881
882// Function: FPDFBitmap_GetWidth
Dan Sinclair49f88b72015-10-20 15:18:51 -0400883// Get width of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700884// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400885// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700886// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400887// The width of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700888DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
889
890// Function: FPDFBitmap_GetHeight
Dan Sinclair49f88b72015-10-20 15:18:51 -0400891// Get height of a bitmap.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700892// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400893// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700894// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400895// The height of the bitmap in pixels.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700896DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
897
898// Function: FPDFBitmap_GetStride
Dan Sinclair49f88b72015-10-20 15:18:51 -0400899// Get number of bytes for each line in the bitmap buffer.
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 number of bytes for each line in the bitmap buffer.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700904// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400905// The stride may be more than width * number of bytes per pixel.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700906DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
907
908// Function: FPDFBitmap_Destroy
Dan Sinclair49f88b72015-10-20 15:18:51 -0400909// Destroy a bitmap and release all related buffers.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700910// Parameters:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400911// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700912// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700913// None.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700914// Comments:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400915// This function will not destroy any external buffers provided when
916// the bitmap was created.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700917DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
918
919// Function: FPDF_VIEWERREF_GetPrintScaling
Tom Sepez9857e202015-05-13 17:09:26 -0700920// Whether the PDF document prefers to be scaled or not.
921// Parameters:
922// document - Handle to the loaded document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700923// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700924// None.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700925DLLEXPORT FPDF_BOOL STDCALL
926FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700927
Bo Xu9114e832014-07-14 13:22:47 -0700928// Function: FPDF_VIEWERREF_GetNumCopies
Tom Sepez9857e202015-05-13 17:09:26 -0700929// Returns the number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700930// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700931// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700932// Return value:
933// The number of copies to be printed.
Bo Xu9114e832014-07-14 13:22:47 -0700934DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
935
936// Function: FPDF_VIEWERREF_GetPrintPageRange
Tom Sepez9857e202015-05-13 17:09:26 -0700937// Page numbers to initialize print dialog box when file is printed.
Bo Xu9114e832014-07-14 13:22:47 -0700938// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700939// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700940// Return value:
941// The print page range to be used for printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700942DLLEXPORT FPDF_PAGERANGE STDCALL
943FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700944
945// Function: FPDF_VIEWERREF_GetDuplex
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700946// Returns the paper handling option to be used when printing from
Dan Sinclair49f88b72015-10-20 15:18:51 -0400947// the print dialog.
Bo Xu9114e832014-07-14 13:22:47 -0700948// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700949// document - Handle to the loaded document.
Bo Xu9114e832014-07-14 13:22:47 -0700950// Return value:
951// The paper handling option to be used when printing.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700952DLLEXPORT FPDF_DUPLEXTYPE STDCALL
953FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
Bo Xu9114e832014-07-14 13:22:47 -0700954
thestig04bebfe2016-11-04 16:07:25 -0700955// Function: FPDF_VIEWERREF_GetName
956// Gets the contents for a viewer ref, with a given key. The value must
957// be of type "name".
958// Parameters:
959// document - Handle to the loaded document.
960// key - Name of the key in the viewer pref dictionary.
961// buffer - A string to write the contents of the key to.
962// length - Length of the buffer.
963// Return value:
964// The number of bytes in the contents, including the NULL terminator.
965// Thus if the return value is 0, then that indicates an error, such
966// as when |document| is invalid or |buffer| is NULL. If |length| is
967// less than the returned length, or |buffer| is NULL, |buffer| will
968// not be modified.
969DLLEXPORT unsigned long STDCALL FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
970 FPDF_BYTESTRING key,
971 char* buffer,
972 unsigned long length);
973
Bo Xu4d62b6b2015-01-10 22:52:59 -0800974// Function: FPDF_CountNamedDests
Tom Sepez9857e202015-05-13 17:09:26 -0700975// Get the count of named destinations in the PDF document.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800976// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700977// document - Handle to a document
Bo Xu4d62b6b2015-01-10 22:52:59 -0800978// Return value:
Tom Sepez9857e202015-05-13 17:09:26 -0700979// The count of named destinations.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800980DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document);
981
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700982// Function: FPDF_GetNamedDestByName
Dan Sinclair49f88b72015-10-20 15:18:51 -0400983// Get a the destination handle for the given name.
Tom Sepez9857e202015-05-13 17:09:26 -0700984// Parameters:
985// document - Handle to the loaded document.
Dan Sinclair49f88b72015-10-20 15:18:51 -0400986// name - The name of a destination.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700987// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -0400988// The handle to the destination.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700989DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
990 FPDF_BYTESTRING name);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700991
Bo Xu4d62b6b2015-01-10 22:52:59 -0800992// Function: FPDF_GetNamedDest
Dan Sinclair49f88b72015-10-20 15:18:51 -0400993// Get the named destination by index.
Bo Xu4d62b6b2015-01-10 22:52:59 -0800994// Parameters:
Tom Sepez9857e202015-05-13 17:09:26 -0700995// document - Handle to a document
Dan Sinclair49f88b72015-10-20 15:18:51 -0400996// index - The index of a named destination.
997// buffer - The buffer to store the destination name,
998// used as wchar_t*.
999// buflen [in/out] - Size of the buffer in bytes on input,
1000// length of the result in bytes on output
1001// or -1 if the buffer is too small.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001002// Return value:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001003// The destination handle for a given index, or NULL if there is no
1004// named destination corresponding to |index|.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001005// Comments:
Tom Sepez9857e202015-05-13 17:09:26 -07001006// Call this function twice to get the name of the named destination:
Dan Sinclair49f88b72015-10-20 15:18:51 -04001007// 1) First time pass in |buffer| as NULL and get buflen.
1008// 2) Second time pass in allocated |buffer| and buflen to retrieve
1009// |buffer|, which should be used as wchar_t*.
Bo Xu4d62b6b2015-01-10 22:52:59 -08001010//
Dan Sinclair49f88b72015-10-20 15:18:51 -04001011// If buflen is not sufficiently large, it will be set to -1 upon
1012// return.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001013DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
1014 int index,
1015 void* buffer,
1016 long* buflen);
Bo Xu4d62b6b2015-01-10 22:52:59 -08001017
Tom Sepezc46d0002015-11-30 15:46:36 -08001018#ifdef PDF_ENABLE_XFA
Tom Sepez9857e202015-05-13 17:09:26 -07001019// Function: FPDF_BStr_Init
1020// Helper function to initialize a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -07001021DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
1022
Tom Sepez9857e202015-05-13 17:09:26 -07001023// Function: FPDF_BStr_Set
1024// Helper function to set string data.
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001025DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
1026 FPDF_LPCSTR bstr,
1027 int length);
Bo Xufdc00a72014-10-28 23:03:33 -07001028
Tom Sepez9857e202015-05-13 17:09:26 -07001029// Function: FPDF_BStr_Clear
1030// Helper function to clear a byte string.
Bo Xufdc00a72014-10-28 23:03:33 -07001031DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
Tom Sepezc46d0002015-11-30 15:46:36 -08001032#endif // PDF_ENABLE_XFA
Bo Xufdc00a72014-10-28 23:03:33 -07001033
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001034#ifdef __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -07001035}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001036#endif
1037
Tom Sepez9857e202015-05-13 17:09:26 -07001038#endif // PUBLIC_FPDFVIEW_H_