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