1 // Copyright 2014 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 // This is the main header file for embedders of PDFium. It provides APIs to 8 // initialize the library, load documents, and render pages, amongst other 9 // things. 10 // 11 // NOTE: None of the PDFium APIs are thread-safe. They expect to be called 12 // from a single thread. Barring that, embedders are required to ensure (via 13 // a mutex or similar) that only a single PDFium call can be made at a time. 14 // 15 // NOTE: External docs refer to this file as "fpdfview.h", so do not rename 16 // despite lack of consistency with other public files. 17 18 #ifndef PUBLIC_FPDFVIEW_H_ 19 #define PUBLIC_FPDFVIEW_H_ 20 21 // clang-format off 22 23 #include <stddef.h> 24 25 typedef __SIZE_TYPE__ size_t; 26 27 #if defined(_WIN32) && !defined(__WINDOWS__) 28 #include <windows.h> 29 #endif 30 31 #ifdef PDF_ENABLE_XFA 32 // PDF_USE_XFA is set in confirmation that this version of PDFium can support 33 // XFA forms as requested by the PDF_ENABLE_XFA setting. 34 #define PDF_USE_XFA 35 #endif // PDF_ENABLE_XFA 36 37 // PDF object types 38 #define FPDF_OBJECT_UNKNOWN 0 39 #define FPDF_OBJECT_BOOLEAN 1 40 #define FPDF_OBJECT_NUMBER 2 41 #define FPDF_OBJECT_STRING 3 42 #define FPDF_OBJECT_NAME 4 43 #define FPDF_OBJECT_ARRAY 5 44 #define FPDF_OBJECT_DICTIONARY 6 45 #define FPDF_OBJECT_STREAM 7 46 #define FPDF_OBJECT_NULLOBJ 8 47 #define FPDF_OBJECT_REFERENCE 9 48 49 // PDF text rendering modes 50 typedef enum { 51 FPDF_TEXTRENDERMODE_UNKNOWN = -1, 52 FPDF_TEXTRENDERMODE_FILL = 0, 53 FPDF_TEXTRENDERMODE_STROKE = 1, 54 FPDF_TEXTRENDERMODE_FILL_STROKE = 2, 55 FPDF_TEXTRENDERMODE_INVISIBLE = 3, 56 FPDF_TEXTRENDERMODE_FILL_CLIP = 4, 57 FPDF_TEXTRENDERMODE_STROKE_CLIP = 5, 58 FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP = 6, 59 FPDF_TEXTRENDERMODE_CLIP = 7, 60 FPDF_TEXTRENDERMODE_LAST = FPDF_TEXTRENDERMODE_CLIP, 61 } FPDF_TEXT_RENDERMODE; 62 63 // PDF types - use incomplete types (never completed) to force API type safety. 64 typedef struct fpdf_action_t__* FPDF_ACTION; 65 typedef struct fpdf_annotation_t__* FPDF_ANNOTATION; 66 typedef struct fpdf_attachment_t__* FPDF_ATTACHMENT; 67 typedef struct fpdf_avail_t__* FPDF_AVAIL; 68 typedef struct fpdf_bitmap_t__* FPDF_BITMAP; 69 typedef struct fpdf_bookmark_t__* FPDF_BOOKMARK; 70 typedef struct fpdf_clippath_t__* FPDF_CLIPPATH; 71 typedef struct fpdf_dest_t__* FPDF_DEST; 72 typedef struct fpdf_document_t__* FPDF_DOCUMENT; 73 typedef struct fpdf_font_t__* FPDF_FONT; 74 typedef struct fpdf_form_handle_t__* FPDF_FORMHANDLE; 75 typedef const struct fpdf_glyphpath_t__* FPDF_GLYPHPATH; 76 typedef struct fpdf_javascript_action_t* FPDF_JAVASCRIPT_ACTION; 77 typedef struct fpdf_link_t__* FPDF_LINK; 78 typedef struct fpdf_page_t__* FPDF_PAGE; 79 typedef struct fpdf_pagelink_t__* FPDF_PAGELINK; 80 typedef struct fpdf_pageobject_t__* FPDF_PAGEOBJECT; // (text, path, etc.) 81 typedef struct fpdf_pageobjectmark_t__* FPDF_PAGEOBJECTMARK; 82 typedef const struct fpdf_pagerange_t__* FPDF_PAGERANGE; 83 typedef const struct fpdf_pathsegment_t* FPDF_PATHSEGMENT; 84 typedef struct fpdf_schhandle_t__* FPDF_SCHHANDLE; 85 typedef const struct fpdf_signature_t__* FPDF_SIGNATURE; 86 typedef void* FPDF_SKIA_CANVAS; // Passed into Skia as an SkCanvas. 87 typedef struct fpdf_structelement_t__* FPDF_STRUCTELEMENT; 88 typedef const struct fpdf_structelement_attr_t__* FPDF_STRUCTELEMENT_ATTR; 89 typedef struct fpdf_structtree_t__* FPDF_STRUCTTREE; 90 typedef struct fpdf_textpage_t__* FPDF_TEXTPAGE; 91 typedef struct fpdf_widget_t__* FPDF_WIDGET; 92 typedef struct fpdf_xobject_t__* FPDF_XOBJECT; 93 94 // Basic data types 95 typedef int FPDF_BOOL; 96 typedef int FPDF_RESULT; 97 typedef unsigned long FPDF_DWORD; 98 typedef float FS_FLOAT; 99 100 // Duplex types 101 typedef enum _FPDF_DUPLEXTYPE_ { 102 DuplexUndefined = 0, 103 Simplex, 104 DuplexFlipShortEdge, 105 DuplexFlipLongEdge 106 } FPDF_DUPLEXTYPE; 107 108 // String types 109 typedef unsigned short FPDF_WCHAR; 110 111 // The public PDFium API uses three types of strings: byte string, wide string 112 // (UTF-16LE encoded), and platform dependent string. 113 114 // Public PDFium API type for byte strings. 115 typedef const char* FPDF_BYTESTRING; 116 117 // The public PDFium API always uses UTF-16LE encoded wide strings, each 118 // character uses 2 bytes (except surrogation), with the low byte first. 119 typedef const FPDF_WCHAR* FPDF_WIDESTRING; 120 121 // Structure for persisting a string beyond the duration of a callback. 122 // Note: although represented as a char*, string may be interpreted as 123 // a UTF-16LE formated string. Used only by XFA callbacks. 124 typedef struct FPDF_BSTR_ { 125 char* str; // String buffer, manipulate only with FPDF_BStr_* methods. 126 int len; // Length of the string, in bytes. 127 } FPDF_BSTR; 128 129 // For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a 130 // Windows unicode string, however, special care needs to be taken if you 131 // expect to process Unicode larger than 0xffff. 132 // 133 // For Linux/Unix programmers: most compiler/library environments use 4 bytes 134 // for a Unicode character, and you have to convert between FPDF_WIDESTRING and 135 // system wide string by yourself. 136 typedef const char* FPDF_STRING; 137 138 // Matrix for transformation, in the form [a b c d e f], equivalent to: 139 // | a b 0 | 140 // | c d 0 | 141 // | e f 1 | 142 // 143 // Translation is performed with [1 0 0 1 tx ty]. 144 // Scaling is performed with [sx 0 0 sy 0 0]. 145 // See PDF Reference 1.7, 4.2.2 Common Transformations for more. 146 typedef struct _FS_MATRIX_ { 147 float a; 148 float b; 149 float c; 150 float d; 151 float e; 152 float f; 153 } FS_MATRIX; 154 155 // Rectangle area(float) in device or page coordinate system. 156 typedef struct _FS_RECTF_ { 157 // The x-coordinate of the left-top corner. 158 float left; 159 // The y-coordinate of the left-top corner. 160 float top; 161 // The x-coordinate of the right-bottom corner. 162 float right; 163 // The y-coordinate of the right-bottom corner. 164 float bottom; 165 } * FS_LPRECTF, FS_RECTF; 166 167 // Const Pointer to FS_RECTF structure. 168 typedef const FS_RECTF* FS_LPCRECTF; 169 170 // Rectangle size. Coordinate system agnostic. 171 typedef struct FS_SIZEF_ { 172 float width; 173 float height; 174 } * FS_LPSIZEF, FS_SIZEF; 175 176 // Const Pointer to FS_SIZEF structure. 177 typedef const FS_SIZEF* FS_LPCSIZEF; 178 179 // 2D Point. Coordinate system agnostic. 180 typedef struct FS_POINTF_ { 181 float x; 182 float y; 183 } * FS_LPPOINTF, FS_POINTF; 184 185 // Const Pointer to FS_POINTF structure. 186 typedef const FS_POINTF* FS_LPCPOINTF; 187 188 typedef struct _FS_QUADPOINTSF { 189 FS_FLOAT x1; 190 FS_FLOAT y1; 191 FS_FLOAT x2; 192 FS_FLOAT y2; 193 FS_FLOAT x3; 194 FS_FLOAT y3; 195 FS_FLOAT x4; 196 FS_FLOAT y4; 197 } FS_QUADPOINTSF; 198 199 // Annotation enums. 200 typedef int FPDF_ANNOTATION_SUBTYPE; 201 typedef int FPDF_ANNOT_APPEARANCEMODE; 202 203 // Dictionary value types. 204 typedef int FPDF_OBJECT_TYPE; 205 206 #if defined(COMPONENT_BUILD) 207 // FPDF_EXPORT should be consistent with |export| in the pdfium_fuzzer 208 // template in testing/fuzzers/BUILD.gn. 209 #if defined(WIN32) 210 #if defined(FPDF_IMPLEMENTATION) 211 #define FPDF_EXPORT __declspec(dllexport) 212 #else 213 #define FPDF_EXPORT __declspec(dllimport) 214 #endif // defined(FPDF_IMPLEMENTATION) 215 #else 216 #if defined(FPDF_IMPLEMENTATION) 217 #define FPDF_EXPORT __attribute__((visibility("default"))) 218 #else 219 #define FPDF_EXPORT 220 #endif // defined(FPDF_IMPLEMENTATION) 221 #endif // defined(WIN32) 222 #else 223 #define FPDF_EXPORT 224 #endif // defined(COMPONENT_BUILD) 225 226 #if defined(WIN32) && defined(FPDFSDK_EXPORTS) 227 #define FPDF_CALLCONV __stdcall 228 #else 229 #define FPDF_CALLCONV 230 #endif 231 232 // Exported Functions 233 #ifdef __cplusplus 234 extern "C" { 235 #endif 236 237 // PDF renderer types - Experimental. 238 // Selection of 2D graphics library to use for rendering to FPDF_BITMAPs. 239 typedef enum { 240 // Anti-Grain Geometry - https://sourceforge.net/projects/agg/ 241 FPDF_RENDERERTYPE_AGG = 0, 242 // Skia - https://skia.org/ 243 FPDF_RENDERERTYPE_SKIA = 1, 244 } FPDF_RENDERER_TYPE; 245 246 // Process-wide options for initializing the library. 247 typedef struct FPDF_LIBRARY_CONFIG_ { 248 // Version number of the interface. Currently must be 2. 249 // Support for version 1 will be deprecated in the future. 250 int version; 251 252 // Array of paths to scan in place of the defaults when using built-in 253 // FXGE font loading code. The array is terminated by a NULL pointer. 254 // The Array may be NULL itself to use the default paths. May be ignored 255 // entirely depending upon the platform. 256 const char** m_pUserFontPaths; 257 258 // Version 2. 259 260 // Pointer to the v8::Isolate to use, or NULL to force PDFium to create one. 261 void* m_pIsolate; 262 263 // The embedder data slot to use in the v8::Isolate to store PDFium's 264 // per-isolate data. The value needs to be in the range 265 // [0, |v8::Internals::kNumIsolateDataLots|). Note that 0 is fine for most 266 // embedders. 267 unsigned int m_v8EmbedderSlot; 268 269 // Version 3 - Experimental. 270 271 // Pointer to the V8::Platform to use. 272 void* m_pPlatform; 273 274 // Version 4 - Experimental. 275 276 // Explicit specification of core renderer to use. |m_RendererType| must be 277 // a valid value for |FPDF_LIBRARY_CONFIG| versions of this level or higher, 278 // or else the initialization will fail with an immediate crash. 279 // Note that use of a specified |FPDF_RENDERER_TYPE| value for which the 280 // corresponding render library is not included in the build will similarly 281 // fail with an immediate crash. 282 FPDF_RENDERER_TYPE m_RendererType; 283 } FPDF_LIBRARY_CONFIG; 284 285 // Function: FPDF_InitLibraryWithConfig 286 // Initialize the PDFium library and allocate global resources for it. 287 // Parameters: 288 // config - configuration information as above. 289 // Return value: 290 // None. 291 // Comments: 292 // You have to call this function before you can call any PDF 293 // processing functions. 294 FPDF_EXPORT void FPDF_CALLCONV 295 FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config); 296 297 // Function: FPDF_InitLibrary 298 // Initialize the PDFium library (alternative form). 299 // Parameters: 300 // None 301 // Return value: 302 // None. 303 // Comments: 304 // Convenience function to call FPDF_InitLibraryWithConfig() with a 305 // default configuration for backwards compatibility purposes. New 306 // code should call FPDF_InitLibraryWithConfig() instead. This will 307 // be deprecated in the future. 308 FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibrary(); 309 310 // Function: FPDF_DestroyLibrary 311 // Release global resources allocated to the PDFium library by 312 // FPDF_InitLibrary() or FPDF_InitLibraryWithConfig(). 313 // Parameters: 314 // None. 315 // Return value: 316 // None. 317 // Comments: 318 // After this function is called, you must not call any PDF 319 // processing functions. 320 // 321 // Calling this function does not automatically close other 322 // objects. It is recommended to close other objects before 323 // closing the library with this function. 324 FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary(); 325 326 // Policy for accessing the local machine time. 327 #define FPDF_POLICY_MACHINETIME_ACCESS 0 328 329 // Function: FPDF_SetSandBoxPolicy 330 // Set the policy for the sandbox environment. 331 // Parameters: 332 // policy - The specified policy for setting, for example: 333 // FPDF_POLICY_MACHINETIME_ACCESS. 334 // enable - True to enable, false to disable the policy. 335 // Return value: 336 // None. 337 FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSandBoxPolicy(FPDF_DWORD policy, 338 FPDF_BOOL enable); 339 340 #if defined(_WIN32) 341 // Experimental API. 342 // Function: FPDF_SetPrintMode 343 // Set printing mode when printing on Windows. 344 // Parameters: 345 // mode - FPDF_PRINTMODE_EMF to output EMF (default) 346 // FPDF_PRINTMODE_TEXTONLY to output text only (for charstream 347 // devices) 348 // FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 PostScript into 349 // EMF as a series of GDI comments. 350 // FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 PostScript into 351 // EMF as a series of GDI comments. 352 // FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH to output level 2 353 // PostScript via ExtEscape() in PASSTHROUGH mode. 354 // FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH to output level 3 355 // PostScript via ExtEscape() in PASSTHROUGH mode. 356 // FPDF_PRINTMODE_EMF_IMAGE_MASKS to output EMF, with more 357 // efficient processing of documents containing image masks. 358 // FPDF_PRINTMODE_POSTSCRIPT3_TYPE42 to output level 3 359 // PostScript with embedded Type 42 fonts, when applicable, into 360 // EMF as a series of GDI comments. 361 // FPDF_PRINTMODE_POSTSCRIPT3_TYPE42_PASSTHROUGH to output level 362 // 3 PostScript with embedded Type 42 fonts, when applicable, 363 // via ExtEscape() in PASSTHROUGH mode. 364 // Return value: 365 // True if successful, false if unsuccessful (typically invalid input). 366 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SetPrintMode(int mode); 367 #endif // defined(_WIN32) 368 369 // Function: FPDF_LoadDocument 370 // Open and load a PDF document. 371 // Parameters: 372 // file_path - Path to the PDF file (including extension). 373 // password - A string used as the password for the PDF file. 374 // If no password is needed, empty or NULL can be used. 375 // See comments below regarding the encoding. 376 // Return value: 377 // A handle to the loaded document, or NULL on failure. 378 // Comments: 379 // Loaded document can be closed by FPDF_CloseDocument(). 380 // If this function fails, you can use FPDF_GetLastError() to retrieve 381 // the reason why it failed. 382 // 383 // The encoding for |file_path| is UTF-8. 384 // 385 // The encoding for |password| can be either UTF-8 or Latin-1. PDFs, 386 // depending on the security handler revision, will only accept one or 387 // the other encoding. If |password|'s encoding and the PDF's expected 388 // encoding do not match, FPDF_LoadDocument() will automatically 389 // convert |password| to the other encoding. 390 FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV 391 FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password); 392 393 // Function: FPDF_LoadMemDocument 394 // Open and load a PDF document from memory. 395 // Parameters: 396 // data_buf - Pointer to a buffer containing the PDF document. 397 // size - Number of bytes in the PDF document. 398 // password - A string used as the password for the PDF file. 399 // If no password is needed, empty or NULL can be used. 400 // Return value: 401 // A handle to the loaded document, or NULL on failure. 402 // Comments: 403 // The memory buffer must remain valid when the document is open. 404 // The loaded document can be closed by FPDF_CloseDocument. 405 // If this function fails, you can use FPDF_GetLastError() to retrieve 406 // the reason why it failed. 407 // 408 // See the comments for FPDF_LoadDocument() regarding the encoding for 409 // |password|. 410 // Notes: 411 // If PDFium is built with the XFA module, the application should call 412 // FPDF_LoadXFA() function after the PDF document loaded to support XFA 413 // fields defined in the fpdfformfill.h file. 414 FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV 415 FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password); 416 417 // Experimental API. 418 // Function: FPDF_LoadMemDocument64 419 // Open and load a PDF document from memory. 420 // Parameters: 421 // data_buf - Pointer to a buffer containing the PDF document. 422 // size - Number of bytes in the PDF document. 423 // password - A string used as the password for the PDF file. 424 // If no password is needed, empty or NULL can be used. 425 // Return value: 426 // A handle to the loaded document, or NULL on failure. 427 // Comments: 428 // The memory buffer must remain valid when the document is open. 429 // The loaded document can be closed by FPDF_CloseDocument. 430 // If this function fails, you can use FPDF_GetLastError() to retrieve 431 // the reason why it failed. 432 // 433 // See the comments for FPDF_LoadDocument() regarding the encoding for 434 // |password|. 435 // Notes: 436 // If PDFium is built with the XFA module, the application should call 437 // FPDF_LoadXFA() function after the PDF document loaded to support XFA 438 // fields defined in the fpdfformfill.h file. 439 FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV 440 FPDF_LoadMemDocument64(const void* data_buf, 441 size_t size, 442 FPDF_BYTESTRING password); 443 444 // Structure for custom file access. 445 typedef struct { 446 // File length, in bytes. 447 unsigned long m_FileLen; 448 449 // A function pointer for getting a block of data from a specific position. 450 // Position is specified by byte offset from the beginning of the file. 451 // The pointer to the buffer is never NULL and the size is never 0. 452 // The position and size will never go out of range of the file length. 453 // It may be possible for PDFium to call this function multiple times for 454 // the same position. 455 // Return value: should be non-zero if successful, zero for error. 456 int (*m_GetBlock)(void* param, 457 unsigned long position, 458 unsigned char* pBuf, 459 unsigned long size); 460 461 // A custom pointer for all implementation specific data. This pointer will 462 // be used as the first parameter to the m_GetBlock callback. 463 void* m_Param; 464 } FPDF_FILEACCESS; 465 466 /* 467 * Structure for file reading or writing (I/O). 468 * 469 * Note: This is a handler and should be implemented by callers, 470 * and is only used from XFA. 471 */ 472 typedef struct FPDF_FILEHANDLER_ { 473 /* 474 * User-defined data. 475 * Note: Callers can use this field to track controls. 476 */ 477 void* clientData; 478 479 /* 480 * Callback function to release the current file stream object. 481 * 482 * Parameters: 483 * clientData - Pointer to user-defined data. 484 * Returns: 485 * None. 486 */ 487 void (*Release)(void* clientData); 488 489 /* 490 * Callback function to retrieve the current file stream size. 491 * 492 * Parameters: 493 * clientData - Pointer to user-defined data. 494 * Returns: 495 * Size of file stream. 496 */ 497 FPDF_DWORD (*GetSize)(void* clientData); 498 499 /* 500 * Callback function to read data from the current file stream. 501 * 502 * Parameters: 503 * clientData - Pointer to user-defined data. 504 * offset - Offset position starts from the beginning of file 505 * stream. This parameter indicates reading position. 506 * buffer - Memory buffer to store data which are read from 507 * file stream. This parameter should not be NULL. 508 * size - Size of data which should be read from file stream, 509 * in bytes. The buffer indicated by |buffer| must be 510 * large enough to store specified data. 511 * Returns: 512 * 0 for success, other value for failure. 513 */ 514 FPDF_RESULT (*ReadBlock)(void* clientData, 515 FPDF_DWORD offset, 516 void* buffer, 517 FPDF_DWORD size); 518 519 /* 520 * Callback function to write data into the current file stream. 521 * 522 * Parameters: 523 * clientData - Pointer to user-defined data. 524 * offset - Offset position starts from the beginning of file 525 * stream. This parameter indicates writing position. 526 * buffer - Memory buffer contains data which is written into 527 * file stream. This parameter should not be NULL. 528 * size - Size of data which should be written into file 529 * stream, in bytes. 530 * Returns: 531 * 0 for success, other value for failure. 532 */ 533 FPDF_RESULT (*WriteBlock)(void* clientData, 534 FPDF_DWORD offset, 535 const void* buffer, 536 FPDF_DWORD size); 537 /* 538 * Callback function to flush all internal accessing buffers. 539 * 540 * Parameters: 541 * clientData - Pointer to user-defined data. 542 * Returns: 543 * 0 for success, other value for failure. 544 */ 545 FPDF_RESULT (*Flush)(void* clientData); 546 547 /* 548 * Callback function to change file size. 549 * 550 * Description: 551 * This function is called under writing mode usually. Implementer 552 * can determine whether to realize it based on application requests. 553 * Parameters: 554 * clientData - Pointer to user-defined data. 555 * size - New size of file stream, in bytes. 556 * Returns: 557 * 0 for success, other value for failure. 558 */ 559 FPDF_RESULT (*Truncate)(void* clientData, FPDF_DWORD size); 560 } FPDF_FILEHANDLER; 561 562 // Function: FPDF_LoadCustomDocument 563 // Load PDF document from a custom access descriptor. 564 // Parameters: 565 // pFileAccess - A structure for accessing the file. 566 // password - Optional password for decrypting the PDF file. 567 // Return value: 568 // A handle to the loaded document, or NULL on failure. 569 // Comments: 570 // The application must keep the file resources |pFileAccess| points to 571 // valid until the returned FPDF_DOCUMENT is closed. |pFileAccess| 572 // itself does not need to outlive the FPDF_DOCUMENT. 573 // 574 // The loaded document can be closed with FPDF_CloseDocument(). 575 // 576 // See the comments for FPDF_LoadDocument() regarding the encoding for 577 // |password|. 578 // Notes: 579 // If PDFium is built with the XFA module, the application should call 580 // FPDF_LoadXFA() function after the PDF document loaded to support XFA 581 // fields defined in the fpdfformfill.h file. 582 FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV 583 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); 584 585 // Function: FPDF_GetFileVersion 586 // Get the file version of the given PDF document. 587 // Parameters: 588 // doc - Handle to a document. 589 // fileVersion - The PDF file version. File version: 14 for 1.4, 15 590 // for 1.5, ... 591 // Return value: 592 // True if succeeds, false otherwise. 593 // Comments: 594 // If the document was created by FPDF_CreateNewDocument, 595 // then this function will always fail. 596 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetFileVersion(FPDF_DOCUMENT doc, 597 int* fileVersion); 598 599 #define FPDF_ERR_SUCCESS 0 // No error. 600 #define FPDF_ERR_UNKNOWN 1 // Unknown error. 601 #define FPDF_ERR_FILE 2 // File not found or could not be opened. 602 #define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted. 603 #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password. 604 #define FPDF_ERR_SECURITY 5 // Unsupported security scheme. 605 #define FPDF_ERR_PAGE 6 // Page not found or content error. 606 #ifdef PDF_ENABLE_XFA 607 #define FPDF_ERR_XFALOAD 7 // Load XFA error. 608 #define FPDF_ERR_XFALAYOUT 8 // Layout XFA error. 609 #endif // PDF_ENABLE_XFA 610 611 // Function: FPDF_GetLastError 612 // Get last error code when a function fails. 613 // Parameters: 614 // None. 615 // Return value: 616 // A 32-bit integer indicating error code as defined above. 617 // Comments: 618 // If the previous SDK call succeeded, the return value of this 619 // function is not defined. This function only works in conjunction 620 // with APIs that mention FPDF_GetLastError() in their documentation. 621 FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError(); 622 623 // Experimental API. 624 // Function: FPDF_DocumentHasValidCrossReferenceTable 625 // Whether the document's cross reference table is valid or not. 626 // Parameters: 627 // document - Handle to a document. Returned by FPDF_LoadDocument. 628 // Return value: 629 // True if the PDF parser did not encounter problems parsing the cross 630 // reference table. False if the parser could not parse the cross 631 // reference table and the table had to be rebuild from other data 632 // within the document. 633 // Comments: 634 // The return value can change over time as the PDF parser evolves. 635 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV 636 FPDF_DocumentHasValidCrossReferenceTable(FPDF_DOCUMENT document); 637 638 // Experimental API. 639 // Function: FPDF_GetTrailerEnds 640 // Get the byte offsets of trailer ends. 641 // Parameters: 642 // document - Handle to document. Returned by FPDF_LoadDocument(). 643 // buffer - The address of a buffer that receives the 644 // byte offsets. 645 // length - The size, in ints, of |buffer|. 646 // Return value: 647 // Returns the number of ints in the buffer on success, 0 on error. 648 // 649 // |buffer| is an array of integers that describes the exact byte offsets of the 650 // trailer ends in the document. If |length| is less than the returned length, 651 // or |document| or |buffer| is NULL, |buffer| will not be modified. 652 FPDF_EXPORT unsigned long FPDF_CALLCONV 653 FPDF_GetTrailerEnds(FPDF_DOCUMENT document, 654 unsigned int* buffer, 655 unsigned long length); 656 657 // Function: FPDF_GetDocPermission 658 // Get file permission flags of the document. 659 // Parameters: 660 // document - Handle to a document. Returned by FPDF_LoadDocument. 661 // Return value: 662 // A 32-bit integer indicating permission flags. Please refer to the 663 // PDF Reference for detailed descriptions. If the document is not 664 // protected, 0xffffffff will be returned. 665 FPDF_EXPORT unsigned long FPDF_CALLCONV 666 FPDF_GetDocPermissions(FPDF_DOCUMENT document); 667 668 // Function: FPDF_GetSecurityHandlerRevision 669 // Get the revision for the security handler. 670 // Parameters: 671 // document - Handle to a document. Returned by FPDF_LoadDocument. 672 // Return value: 673 // The security handler revision number. Please refer to the PDF 674 // Reference for a detailed description. If the document is not 675 // protected, -1 will be returned. 676 FPDF_EXPORT int FPDF_CALLCONV 677 FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); 678 679 // Function: FPDF_GetPageCount 680 // Get total number of pages in the document. 681 // Parameters: 682 // document - Handle to document. Returned by FPDF_LoadDocument. 683 // Return value: 684 // Total number of pages in the document. 685 FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document); 686 687 // Function: FPDF_LoadPage 688 // Load a page inside the document. 689 // Parameters: 690 // document - Handle to document. Returned by FPDF_LoadDocument 691 // page_index - Index number of the page. 0 for the first page. 692 // Return value: 693 // A handle to the loaded page, or NULL if page load fails. 694 // Comments: 695 // The loaded page can be rendered to devices using FPDF_RenderPage. 696 // The loaded page can be closed using FPDF_ClosePage. 697 FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document, 698 int page_index); 699 700 // Experimental API 701 // Function: FPDF_GetPageWidthF 702 // Get page width. 703 // Parameters: 704 // page - Handle to the page. Returned by FPDF_LoadPage(). 705 // Return value: 706 // Page width (excluding non-displayable area) measured in points. 707 // One point is 1/72 inch (around 0.3528 mm). 708 FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageWidthF(FPDF_PAGE page); 709 710 // Function: FPDF_GetPageWidth 711 // Get page width. 712 // Parameters: 713 // page - Handle to the page. Returned by FPDF_LoadPage. 714 // Return value: 715 // Page width (excluding non-displayable area) measured in points. 716 // One point is 1/72 inch (around 0.3528 mm). 717 // Note: 718 // Prefer FPDF_GetPageWidthF() above. This will be deprecated in the 719 // future. 720 FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page); 721 722 // Experimental API 723 // Function: FPDF_GetPageHeightF 724 // Get page height. 725 // Parameters: 726 // page - Handle to the page. Returned by FPDF_LoadPage(). 727 // Return value: 728 // Page height (excluding non-displayable area) measured in points. 729 // One point is 1/72 inch (around 0.3528 mm) 730 FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageHeightF(FPDF_PAGE page); 731 732 // Function: FPDF_GetPageHeight 733 // Get page height. 734 // Parameters: 735 // page - Handle to the page. Returned by FPDF_LoadPage. 736 // Return value: 737 // Page height (excluding non-displayable area) measured in points. 738 // One point is 1/72 inch (around 0.3528 mm) 739 // Note: 740 // Prefer FPDF_GetPageHeightF() above. This will be deprecated in the 741 // future. 742 FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page); 743 744 // Experimental API. 745 // Function: FPDF_GetPageBoundingBox 746 // Get the bounding box of the page. This is the intersection between 747 // its media box and its crop box. 748 // Parameters: 749 // page - Handle to the page. Returned by FPDF_LoadPage. 750 // rect - Pointer to a rect to receive the page bounding box. 751 // On an error, |rect| won't be filled. 752 // Return value: 753 // True for success. 754 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetPageBoundingBox(FPDF_PAGE page, 755 FS_RECTF* rect); 756 757 // Experimental API. 758 // Function: FPDF_GetPageSizeByIndexF 759 // Get the size of the page at the given index. 760 // Parameters: 761 // document - Handle to document. Returned by FPDF_LoadDocument(). 762 // page_index - Page index, zero for the first page. 763 // size - Pointer to a FS_SIZEF to receive the page size. 764 // (in points). 765 // Return value: 766 // Non-zero for success. 0 for error (document or page not found). 767 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV 768 FPDF_GetPageSizeByIndexF(FPDF_DOCUMENT document, 769 int page_index, 770 FS_SIZEF* size); 771 772 // Function: FPDF_GetPageSizeByIndex 773 // Get the size of the page at the given index. 774 // Parameters: 775 // document - Handle to document. Returned by FPDF_LoadDocument. 776 // page_index - Page index, zero for the first page. 777 // width - Pointer to a double to receive the page width 778 // (in points). 779 // height - Pointer to a double to receive the page height 780 // (in points). 781 // Return value: 782 // Non-zero for success. 0 for error (document or page not found). 783 // Note: 784 // Prefer FPDF_GetPageSizeByIndexF() above. This will be deprecated in 785 // the future. 786 FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, 787 int page_index, 788 double* width, 789 double* height); 790 791 // Page rendering flags. They can be combined with bit-wise OR. 792 // 793 // Set if annotations are to be rendered. 794 #define FPDF_ANNOT 0x01 795 // Set if using text rendering optimized for LCD display. This flag will only 796 // take effect if anti-aliasing is enabled for text. 797 #define FPDF_LCD_TEXT 0x02 798 // Don't use the native text output available on some platforms 799 #define FPDF_NO_NATIVETEXT 0x04 800 // Grayscale output. 801 #define FPDF_GRAYSCALE 0x08 802 // Obsolete, has no effect, retained for compatibility. 803 #define FPDF_DEBUG_INFO 0x80 804 // Obsolete, has no effect, retained for compatibility. 805 #define FPDF_NO_CATCH 0x100 806 // Limit image cache size. 807 #define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 808 // Always use halftone for image stretching. 809 #define FPDF_RENDER_FORCEHALFTONE 0x400 810 // Render for printing. 811 #define FPDF_PRINTING 0x800 812 // Set to disable anti-aliasing on text. This flag will also disable LCD 813 // optimization for text rendering. 814 #define FPDF_RENDER_NO_SMOOTHTEXT 0x1000 815 // Set to disable anti-aliasing on images. 816 #define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000 817 // Set to disable anti-aliasing on paths. 818 #define FPDF_RENDER_NO_SMOOTHPATH 0x4000 819 // Set whether to render in a reverse Byte order, this flag is only used when 820 // rendering to a bitmap. 821 #define FPDF_REVERSE_BYTE_ORDER 0x10 822 // Set whether fill paths need to be stroked. This flag is only used when 823 // FPDF_COLORSCHEME is passed in, since with a single fill color for paths the 824 // boundaries of adjacent fill paths are less visible. 825 #define FPDF_CONVERT_FILL_TO_STROKE 0x20 826 827 // Struct for color scheme. 828 // Each should be a 32-bit value specifying the color, in 8888 ARGB format. 829 typedef struct FPDF_COLORSCHEME_ { 830 FPDF_DWORD path_fill_color; 831 FPDF_DWORD path_stroke_color; 832 FPDF_DWORD text_fill_color; 833 FPDF_DWORD text_stroke_color; 834 } FPDF_COLORSCHEME; 835 836 #ifdef _WIN32 837 // Function: FPDF_RenderPage 838 // Render contents of a page to a device (screen, bitmap, or printer). 839 // This function is only supported on Windows. 840 // Parameters: 841 // dc - Handle to the device context. 842 // page - Handle to the page. Returned by FPDF_LoadPage. 843 // start_x - Left pixel position of the display area in 844 // device coordinates. 845 // start_y - Top pixel position of the display area in device 846 // coordinates. 847 // size_x - Horizontal size (in pixels) for displaying the page. 848 // size_y - Vertical size (in pixels) for displaying the page. 849 // rotate - Page orientation: 850 // 0 (normal) 851 // 1 (rotated 90 degrees clockwise) 852 // 2 (rotated 180 degrees) 853 // 3 (rotated 90 degrees counter-clockwise) 854 // flags - 0 for normal display, or combination of flags 855 // defined above. 856 // Return value: 857 // None. 858 FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc, 859 FPDF_PAGE page, 860 int start_x, 861 int start_y, 862 int size_x, 863 int size_y, 864 int rotate, 865 int flags); 866 #endif 867 868 // Function: FPDF_RenderPageBitmap 869 // Render contents of a page to a device independent bitmap. 870 // Parameters: 871 // bitmap - Handle to the device independent bitmap (as the 872 // output buffer). The bitmap handle can be created 873 // by FPDFBitmap_Create or retrieved from an image 874 // object by FPDFImageObj_GetBitmap. 875 // page - Handle to the page. Returned by FPDF_LoadPage 876 // start_x - Left pixel position of the display area in 877 // bitmap coordinates. 878 // start_y - Top pixel position of the display area in bitmap 879 // coordinates. 880 // size_x - Horizontal size (in pixels) for displaying the page. 881 // size_y - Vertical size (in pixels) for displaying the page. 882 // rotate - Page orientation: 883 // 0 (normal) 884 // 1 (rotated 90 degrees clockwise) 885 // 2 (rotated 180 degrees) 886 // 3 (rotated 90 degrees counter-clockwise) 887 // flags - 0 for normal display, or combination of the Page 888 // Rendering flags defined above. With the FPDF_ANNOT 889 // flag, it renders all annotations that do not require 890 // user-interaction, which are all annotations except 891 // widget and popup annotations. 892 // Return value: 893 // None. 894 FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, 895 FPDF_PAGE page, 896 int start_x, 897 int start_y, 898 int size_x, 899 int size_y, 900 int rotate, 901 int flags); 902 903 // Function: FPDF_RenderPageBitmapWithMatrix 904 // Render contents of a page to a device independent bitmap. 905 // Parameters: 906 // bitmap - Handle to the device independent bitmap (as the 907 // output buffer). The bitmap handle can be created 908 // by FPDFBitmap_Create or retrieved by 909 // FPDFImageObj_GetBitmap. 910 // page - Handle to the page. Returned by FPDF_LoadPage. 911 // matrix - The transform matrix, which must be invertible. 912 // See PDF Reference 1.7, 4.2.2 Common Transformations. 913 // clipping - The rect to clip to in device coords. 914 // flags - 0 for normal display, or combination of the Page 915 // Rendering flags defined above. With the FPDF_ANNOT 916 // flag, it renders all annotations that do not require 917 // user-interaction, which are all annotations except 918 // widget and popup annotations. 919 // Return value: 920 // None. Note that behavior is undefined if det of |matrix| is 0. 921 FPDF_EXPORT void FPDF_CALLCONV 922 FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap, 923 FPDF_PAGE page, 924 const FS_MATRIX* matrix, 925 const FS_RECTF* clipping, 926 int flags); 927 928 #if defined(_SKIA_SUPPORT_) 929 // Experimental API. 930 // Function: FPDF_RenderPageSkia 931 // Render contents of a page to a Skia SkCanvas. 932 // Parameters: 933 // canvas - SkCanvas to render to. 934 // page - Handle to the page. 935 // size_x - Horizontal size (in pixels) for displaying the page. 936 // size_y - Vertical size (in pixels) for displaying the page. 937 // Return value: 938 // None. 939 FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageSkia(FPDF_SKIA_CANVAS canvas, 940 FPDF_PAGE page, 941 int size_x, 942 int size_y); 943 #endif 944 945 // Function: FPDF_ClosePage 946 // Close a loaded PDF page. 947 // Parameters: 948 // page - Handle to the loaded page. 949 // Return value: 950 // None. 951 FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page); 952 953 // Function: FPDF_CloseDocument 954 // Close a loaded PDF document. 955 // Parameters: 956 // document - Handle to the loaded document. 957 // Return value: 958 // None. 959 FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document); 960 961 // Function: FPDF_DeviceToPage 962 // Convert the screen coordinates of a point to page coordinates. 963 // Parameters: 964 // page - Handle to the page. Returned by FPDF_LoadPage. 965 // start_x - Left pixel position of the display area in 966 // device coordinates. 967 // start_y - Top pixel position of the display area in device 968 // coordinates. 969 // size_x - Horizontal size (in pixels) for displaying the page. 970 // size_y - Vertical size (in pixels) for displaying the page. 971 // rotate - Page orientation: 972 // 0 (normal) 973 // 1 (rotated 90 degrees clockwise) 974 // 2 (rotated 180 degrees) 975 // 3 (rotated 90 degrees counter-clockwise) 976 // device_x - X value in device coordinates to be converted. 977 // device_y - Y value in device coordinates to be converted. 978 // page_x - A pointer to a double receiving the converted X 979 // value in page coordinates. 980 // page_y - A pointer to a double receiving the converted Y 981 // value in page coordinates. 982 // Return value: 983 // Returns true if the conversion succeeds, and |page_x| and |page_y| 984 // successfully receives the converted coordinates. 985 // Comments: 986 // The page coordinate system has its origin at the left-bottom corner 987 // of the page, with the X-axis on the bottom going to the right, and 988 // the Y-axis on the left side going up. 989 // 990 // NOTE: this coordinate system can be altered when you zoom, scroll, 991 // or rotate a page, however, a point on the page should always have 992 // the same coordinate values in the page coordinate system. 993 // 994 // The device coordinate system is device dependent. For screen device, 995 // its origin is at the left-top corner of the window. However this 996 // origin can be altered by the Windows coordinate transformation 997 // utilities. 998 // 999 // You must make sure the start_x, start_y, size_x, size_y 1000 // and rotate parameters have exactly same values as you used in 1001 // the FPDF_RenderPage() function call. 1002 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page, 1003 int start_x, 1004 int start_y, 1005 int size_x, 1006 int size_y, 1007 int rotate, 1008 int device_x, 1009 int device_y, 1010 double* page_x, 1011 double* page_y); 1012 1013 // Function: FPDF_PageToDevice 1014 // Convert the page coordinates of a point to screen coordinates. 1015 // Parameters: 1016 // page - Handle to the page. Returned by FPDF_LoadPage. 1017 // start_x - Left pixel position of the display area in 1018 // device coordinates. 1019 // start_y - Top pixel position of the display area in device 1020 // coordinates. 1021 // size_x - Horizontal size (in pixels) for displaying the page. 1022 // size_y - Vertical size (in pixels) for displaying the page. 1023 // rotate - Page orientation: 1024 // 0 (normal) 1025 // 1 (rotated 90 degrees clockwise) 1026 // 2 (rotated 180 degrees) 1027 // 3 (rotated 90 degrees counter-clockwise) 1028 // page_x - X value in page coordinates. 1029 // page_y - Y value in page coordinate. 1030 // device_x - A pointer to an integer receiving the result X 1031 // value in device coordinates. 1032 // device_y - A pointer to an integer receiving the result Y 1033 // value in device coordinates. 1034 // Return value: 1035 // Returns true if the conversion succeeds, and |device_x| and 1036 // |device_y| successfully receives the converted coordinates. 1037 // Comments: 1038 // See comments for FPDF_DeviceToPage(). 1039 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page, 1040 int start_x, 1041 int start_y, 1042 int size_x, 1043 int size_y, 1044 int rotate, 1045 double page_x, 1046 double page_y, 1047 int* device_x, 1048 int* device_y); 1049 1050 // Function: FPDFBitmap_Create 1051 // Create a device independent bitmap (FXDIB). 1052 // Parameters: 1053 // width - The number of pixels in width for the bitmap. 1054 // Must be greater than 0. 1055 // height - The number of pixels in height for the bitmap. 1056 // Must be greater than 0. 1057 // alpha - A flag indicating whether the alpha channel is used. 1058 // Non-zero for using alpha, zero for not using. 1059 // Return value: 1060 // The created bitmap handle, or NULL if a parameter error or out of 1061 // memory. 1062 // Comments: 1063 // The bitmap always uses 4 bytes per pixel. The first byte is always 1064 // double word aligned. 1065 // 1066 // The byte order is BGRx (the last byte unused if no alpha channel) or 1067 // BGRA. 1068 // 1069 // The pixels in a horizontal line are stored side by side, with the 1070 // left most pixel stored first (with lower memory address). 1071 // Each line uses width * 4 bytes. 1072 // 1073 // Lines are stored one after another, with the top most line stored 1074 // first. There is no gap between adjacent lines. 1075 // 1076 // This function allocates enough memory for holding all pixels in the 1077 // bitmap, but it doesn't initialize the buffer. Applications can use 1078 // FPDFBitmap_FillRect() to fill the bitmap using any color. If the OS 1079 // allows it, this function can allocate up to 4 GB of memory. 1080 FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width, 1081 int height, 1082 int alpha); 1083 1084 // More DIB formats 1085 // Unknown or unsupported format. 1086 #define FPDFBitmap_Unknown 0 1087 // Gray scale bitmap, one byte per pixel. 1088 #define FPDFBitmap_Gray 1 1089 // 3 bytes per pixel, byte order: blue, green, red. 1090 #define FPDFBitmap_BGR 2 1091 // 4 bytes per pixel, byte order: blue, green, red, unused. 1092 #define FPDFBitmap_BGRx 3 1093 // 4 bytes per pixel, byte order: blue, green, red, alpha. 1094 #define FPDFBitmap_BGRA 4 1095 1096 // Function: FPDFBitmap_CreateEx 1097 // Create a device independent bitmap (FXDIB) 1098 // Parameters: 1099 // width - The number of pixels in width for the bitmap. 1100 // Must be greater than 0. 1101 // height - The number of pixels in height for the bitmap. 1102 // Must be greater than 0. 1103 // format - A number indicating for bitmap format, as defined 1104 // above. 1105 // first_scan - A pointer to the first byte of the first line if 1106 // using an external buffer. If this parameter is NULL, 1107 // then a new buffer will be created. 1108 // stride - Number of bytes for each scan line. The value must 1109 // be 0 or greater. When the value is 0, 1110 // FPDFBitmap_CreateEx() will automatically calculate 1111 // the appropriate value using |width| and |format|. 1112 // When using an external buffer, it is recommended for 1113 // the caller to pass in the value. 1114 // When not using an external buffer, it is recommended 1115 // for the caller to pass in 0. 1116 // Return value: 1117 // The bitmap handle, or NULL if parameter error or out of memory. 1118 // Comments: 1119 // Similar to FPDFBitmap_Create function, but allows for more formats 1120 // and an external buffer is supported. The bitmap created by this 1121 // function can be used in any place that a FPDF_BITMAP handle is 1122 // required. 1123 // 1124 // If an external buffer is used, then the caller should destroy the 1125 // buffer. FPDFBitmap_Destroy() will not destroy the buffer. 1126 // 1127 // It is recommended to use FPDFBitmap_GetStride() to get the stride 1128 // value. 1129 FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width, 1130 int height, 1131 int format, 1132 void* first_scan, 1133 int stride); 1134 1135 // Function: FPDFBitmap_GetFormat 1136 // Get the format of the bitmap. 1137 // Parameters: 1138 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create 1139 // or FPDFImageObj_GetBitmap. 1140 // Return value: 1141 // The format of the bitmap. 1142 // Comments: 1143 // Only formats supported by FPDFBitmap_CreateEx are supported by this 1144 // function; see the list of such formats above. 1145 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap); 1146 1147 // Function: FPDFBitmap_FillRect 1148 // Fill a rectangle in a bitmap. 1149 // Parameters: 1150 // bitmap - The handle to the bitmap. Returned by 1151 // FPDFBitmap_Create. 1152 // left - The left position. Starting from 0 at the 1153 // left-most pixel. 1154 // top - The top position. Starting from 0 at the 1155 // top-most line. 1156 // width - Width in pixels to be filled. 1157 // height - Height in pixels to be filled. 1158 // color - A 32-bit value specifing the color, in 8888 ARGB 1159 // format. 1160 // Return value: 1161 // None. 1162 // Comments: 1163 // This function sets the color and (optionally) alpha value in the 1164 // specified region of the bitmap. 1165 // 1166 // NOTE: If the alpha channel is used, this function does NOT 1167 // composite the background with the source color, instead the 1168 // background will be replaced by the source color and the alpha. 1169 // 1170 // If the alpha channel is not used, the alpha parameter is ignored. 1171 FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap, 1172 int left, 1173 int top, 1174 int width, 1175 int height, 1176 FPDF_DWORD color); 1177 1178 // Function: FPDFBitmap_GetBuffer 1179 // Get data buffer of a bitmap. 1180 // Parameters: 1181 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create 1182 // or FPDFImageObj_GetBitmap. 1183 // Return value: 1184 // The pointer to the first byte of the bitmap buffer. 1185 // Comments: 1186 // The stride may be more than width * number of bytes per pixel 1187 // 1188 // Applications can use this function to get the bitmap buffer pointer, 1189 // then manipulate any color and/or alpha values for any pixels in the 1190 // bitmap. 1191 // 1192 // Use FPDFBitmap_GetFormat() to find out the format of the data. 1193 FPDF_EXPORT void* FPDF_CALLCONV FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); 1194 1195 // Function: FPDFBitmap_GetWidth 1196 // Get width of a bitmap. 1197 // Parameters: 1198 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create 1199 // or FPDFImageObj_GetBitmap. 1200 // Return value: 1201 // The width of the bitmap in pixels. 1202 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); 1203 1204 // Function: FPDFBitmap_GetHeight 1205 // Get height of a bitmap. 1206 // Parameters: 1207 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create 1208 // or FPDFImageObj_GetBitmap. 1209 // Return value: 1210 // The height of the bitmap in pixels. 1211 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); 1212 1213 // Function: FPDFBitmap_GetStride 1214 // Get number of bytes for each line in the bitmap buffer. 1215 // Parameters: 1216 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create 1217 // or FPDFImageObj_GetBitmap. 1218 // Return value: 1219 // The number of bytes for each line in the bitmap buffer. 1220 // Comments: 1221 // The stride may be more than width * number of bytes per pixel. 1222 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetStride(FPDF_BITMAP bitmap); 1223 1224 // Function: FPDFBitmap_Destroy 1225 // Destroy a bitmap and release all related buffers. 1226 // Parameters: 1227 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create 1228 // or FPDFImageObj_GetBitmap. 1229 // Return value: 1230 // None. 1231 // Comments: 1232 // This function will not destroy any external buffers provided when 1233 // the bitmap was created. 1234 FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap); 1235 1236 // Function: FPDF_VIEWERREF_GetPrintScaling 1237 // Whether the PDF document prefers to be scaled or not. 1238 // Parameters: 1239 // document - Handle to the loaded document. 1240 // Return value: 1241 // None. 1242 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV 1243 FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); 1244 1245 // Function: FPDF_VIEWERREF_GetNumCopies 1246 // Returns the number of copies to be printed. 1247 // Parameters: 1248 // document - Handle to the loaded document. 1249 // Return value: 1250 // The number of copies to be printed. 1251 FPDF_EXPORT int FPDF_CALLCONV 1252 FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); 1253 1254 // Function: FPDF_VIEWERREF_GetPrintPageRange 1255 // Page numbers to initialize print dialog box when file is printed. 1256 // Parameters: 1257 // document - Handle to the loaded document. 1258 // Return value: 1259 // The print page range to be used for printing. 1260 FPDF_EXPORT FPDF_PAGERANGE FPDF_CALLCONV 1261 FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); 1262 1263 // Experimental API. 1264 // Function: FPDF_VIEWERREF_GetPrintPageRangeCount 1265 // Returns the number of elements in a FPDF_PAGERANGE. 1266 // Parameters: 1267 // pagerange - Handle to the page range. 1268 // Return value: 1269 // The number of elements in the page range. Returns 0 on error. 1270 FPDF_EXPORT size_t FPDF_CALLCONV 1271 FPDF_VIEWERREF_GetPrintPageRangeCount(FPDF_PAGERANGE pagerange); 1272 1273 // Experimental API. 1274 // Function: FPDF_VIEWERREF_GetPrintPageRangeElement 1275 // Returns an element from a FPDF_PAGERANGE. 1276 // Parameters: 1277 // pagerange - Handle to the page range. 1278 // index - Index of the element. 1279 // Return value: 1280 // The value of the element in the page range at a given index. 1281 // Returns -1 on error. 1282 FPDF_EXPORT int FPDF_CALLCONV 1283 FPDF_VIEWERREF_GetPrintPageRangeElement(FPDF_PAGERANGE pagerange, size_t index); 1284 1285 // Function: FPDF_VIEWERREF_GetDuplex 1286 // Returns the paper handling option to be used when printing from 1287 // the print dialog. 1288 // Parameters: 1289 // document - Handle to the loaded document. 1290 // Return value: 1291 // The paper handling option to be used when printing. 1292 FPDF_EXPORT FPDF_DUPLEXTYPE FPDF_CALLCONV 1293 FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document); 1294 1295 // Function: FPDF_VIEWERREF_GetName 1296 // Gets the contents for a viewer ref, with a given key. The value must 1297 // be of type "name". 1298 // Parameters: 1299 // document - Handle to the loaded document. 1300 // key - Name of the key in the viewer pref dictionary, 1301 // encoded in UTF-8. 1302 // buffer - A string to write the contents of the key to. 1303 // length - Length of the buffer. 1304 // Return value: 1305 // The number of bytes in the contents, including the NULL terminator. 1306 // Thus if the return value is 0, then that indicates an error, such 1307 // as when |document| is invalid or |buffer| is NULL. If |length| is 1308 // less than the returned length, or |buffer| is NULL, |buffer| will 1309 // not be modified. 1310 FPDF_EXPORT unsigned long FPDF_CALLCONV 1311 FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document, 1312 FPDF_BYTESTRING key, 1313 char* buffer, 1314 unsigned long length); 1315 1316 // Function: FPDF_CountNamedDests 1317 // Get the count of named destinations in the PDF document. 1318 // Parameters: 1319 // document - Handle to a document 1320 // Return value: 1321 // The count of named destinations. 1322 FPDF_EXPORT FPDF_DWORD FPDF_CALLCONV 1323 FPDF_CountNamedDests(FPDF_DOCUMENT document); 1324 1325 // Function: FPDF_GetNamedDestByName 1326 // Get a the destination handle for the given name. 1327 // Parameters: 1328 // document - Handle to the loaded document. 1329 // name - The name of a destination. 1330 // Return value: 1331 // The handle to the destination. 1332 FPDF_EXPORT FPDF_DEST FPDF_CALLCONV 1333 FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name); 1334 1335 // Function: FPDF_GetNamedDest 1336 // Get the named destination by index. 1337 // Parameters: 1338 // document - Handle to a document 1339 // index - The index of a named destination. 1340 // buffer - The buffer to store the destination name, 1341 // used as wchar_t*. 1342 // buflen [in/out] - Size of the buffer in bytes on input, 1343 // length of the result in bytes on output 1344 // or -1 if the buffer is too small. 1345 // Return value: 1346 // The destination handle for a given index, or NULL if there is no 1347 // named destination corresponding to |index|. 1348 // Comments: 1349 // Call this function twice to get the name of the named destination: 1350 // 1) First time pass in |buffer| as NULL and get buflen. 1351 // 2) Second time pass in allocated |buffer| and buflen to retrieve 1352 // |buffer|, which should be used as wchar_t*. 1353 // 1354 // If buflen is not sufficiently large, it will be set to -1 upon 1355 // return. 1356 FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document, 1357 int index, 1358 void* buffer, 1359 long* buflen); 1360 1361 // Experimental API. 1362 // Function: FPDF_GetXFAPacketCount 1363 // Get the number of valid packets in the XFA entry. 1364 // Parameters: 1365 // document - Handle to the document. 1366 // Return value: 1367 // The number of valid packets, or -1 on error. 1368 FPDF_EXPORT int FPDF_CALLCONV FPDF_GetXFAPacketCount(FPDF_DOCUMENT document); 1369 1370 // Experimental API. 1371 // Function: FPDF_GetXFAPacketName 1372 // Get the name of a packet in the XFA array. 1373 // Parameters: 1374 // document - Handle to the document. 1375 // index - Index number of the packet. 0 for the first packet. 1376 // buffer - Buffer for holding the name of the XFA packet. 1377 // buflen - Length of |buffer| in bytes. 1378 // Return value: 1379 // The length of the packet name in bytes, or 0 on error. 1380 // 1381 // |document| must be valid and |index| must be in the range [0, N), where N is 1382 // the value returned by FPDF_GetXFAPacketCount(). 1383 // |buffer| is only modified if it is non-NULL and |buflen| is greater than or 1384 // equal to the length of the packet name. The packet name includes a 1385 // terminating NUL character. |buffer| is unmodified on error. 1386 FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetXFAPacketName( 1387 FPDF_DOCUMENT document, 1388 int index, 1389 void* buffer, 1390 unsigned long buflen); 1391 1392 // Experimental API. 1393 // Function: FPDF_GetXFAPacketContent 1394 // Get the content of a packet in the XFA array. 1395 // Parameters: 1396 // document - Handle to the document. 1397 // index - Index number of the packet. 0 for the first packet. 1398 // buffer - Buffer for holding the content of the XFA packet. 1399 // buflen - Length of |buffer| in bytes. 1400 // out_buflen - Pointer to the variable that will receive the minimum 1401 // buffer size needed to contain the content of the XFA 1402 // packet. 1403 // Return value: 1404 // Whether the operation succeeded or not. 1405 // 1406 // |document| must be valid and |index| must be in the range [0, N), where N is 1407 // the value returned by FPDF_GetXFAPacketCount(). |out_buflen| must not be 1408 // NULL. When the aforementioned arguments are valid, the operation succeeds, 1409 // and |out_buflen| receives the content size. |buffer| is only modified if 1410 // |buffer| is non-null and long enough to contain the content. Callers must 1411 // check both the return value and the input |buflen| is no less than the 1412 // returned |out_buflen| before using the data in |buffer|. 1413 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetXFAPacketContent( 1414 FPDF_DOCUMENT document, 1415 int index, 1416 void* buffer, 1417 unsigned long buflen, 1418 unsigned long* out_buflen); 1419 1420 #ifdef PDF_ENABLE_V8 1421 // Function: FPDF_GetRecommendedV8Flags 1422 // Returns a space-separated string of command line flags that are 1423 // recommended to be passed into V8 via V8::SetFlagsFromString() 1424 // prior to initializing the PDFium library. 1425 // Parameters: 1426 // None. 1427 // Return value: 1428 // NUL-terminated string of the form "--flag1 --flag2". 1429 // The caller must not attempt to modify or free the result. 1430 FPDF_EXPORT const char* FPDF_CALLCONV FPDF_GetRecommendedV8Flags(); 1431 1432 // Experimental API. 1433 // Function: FPDF_GetArrayBufferAllocatorSharedInstance() 1434 // Helper function for initializing V8 isolates that will 1435 // use PDFium's internal memory management. 1436 // Parameters: 1437 // None. 1438 // Return Value: 1439 // Pointer to a suitable v8::ArrayBuffer::Allocator, returned 1440 // as void for C compatibility. 1441 // Notes: 1442 // Use is optional, but allows external creation of isolates 1443 // matching the ones PDFium will make when none is provided 1444 // via |FPDF_LIBRARY_CONFIG::m_pIsolate|. 1445 FPDF_EXPORT void* FPDF_CALLCONV FPDF_GetArrayBufferAllocatorSharedInstance(); 1446 #endif // PDF_ENABLE_V8 1447 1448 #ifdef PDF_ENABLE_XFA 1449 // Function: FPDF_BStr_Init 1450 // Helper function to initialize a FPDF_BSTR. 1451 FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* bstr); 1452 1453 // Function: FPDF_BStr_Set 1454 // Helper function to copy string data into the FPDF_BSTR. 1455 FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Set(FPDF_BSTR* bstr, 1456 const char* cstr, 1457 int length); 1458 1459 // Function: FPDF_BStr_Clear 1460 // Helper function to clear a FPDF_BSTR. 1461 FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Clear(FPDF_BSTR* bstr); 1462 #endif // PDF_ENABLE_XFA 1463 1464 #ifdef __cplusplus 1465 } 1466 #endif 1467 1468 #endif // PUBLIC_FPDFVIEW_H_ 1469