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