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 #if defined(_WIN32) && !defined(__WINDOWS__) 14 #include <windows.h> 15 #endif 16 17 #ifdef PDF_ENABLE_XFA 18 // PDF_USE_XFA is set in confirmation that this version of PDFium can support 19 // XFA forms as requested by the PDF_ENABLE_XFA setting. 20 #define PDF_USE_XFA 21 #endif // PDF_ENABLE_XFA 22 23 // PDF types 24 typedef void* FPDF_ACTION; 25 typedef void* FPDF_BITMAP; 26 typedef void* FPDF_BOOKMARK; 27 typedef void* FPDF_CLIPPATH; 28 typedef void* FPDF_DEST; 29 typedef void* FPDF_DOCSCHHANDLE; 30 typedef void* FPDF_DOCUMENT; 31 typedef void* FPDF_FONT; 32 typedef void* FPDF_HMODULE; 33 typedef void* FPDF_LINK; 34 typedef void* FPDF_MODULEMGR; 35 typedef void* FPDF_PAGE; 36 typedef void* FPDF_PAGELINK; 37 typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc) 38 typedef void* FPDF_PAGERANGE; 39 typedef void* FPDF_PATH; 40 typedef void* FPDF_RECORDER; 41 typedef void* FPDF_SCHHANDLE; 42 typedef void* FPDF_TEXTPAGE; 43 44 #ifdef PDF_ENABLE_XFA 45 typedef void* FPDF_STRINGHANDLE; 46 typedef void* FPDF_WIDGET; 47 #endif // PDF_ENABLE_XFA 48 49 // Basic data types 50 typedef int FPDF_BOOL; 51 typedef int FPDF_ERROR; 52 typedef unsigned long FPDF_DWORD; 53 typedef float FS_FLOAT; 54 55 #ifdef PDF_ENABLE_XFA 56 typedef void* FPDF_LPVOID; 57 typedef void const* FPDF_LPCVOID; 58 typedef char const* FPDF_LPCSTR; 59 typedef int FPDF_RESULT; 60 #endif 61 62 // Duplex types 63 typedef enum _FPDF_DUPLEXTYPE_ { 64 DuplexUndefined = 0, 65 Simplex, 66 DuplexFlipShortEdge, 67 DuplexFlipLongEdge 68 } FPDF_DUPLEXTYPE; 69 70 // String types 71 typedef unsigned short FPDF_WCHAR; 72 typedef unsigned char const* FPDF_LPCBYTE; 73 74 // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE 75 // encoded), and platform dependent string 76 typedef const char* FPDF_BYTESTRING; 77 78 // FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2 79 // bytes (except surrogation), with the low byte first. 80 typedef const unsigned short* FPDF_WIDESTRING; 81 82 #ifdef PDF_ENABLE_XFA 83 // Structure for a byte string. 84 // Note, a byte string commonly means a UTF-16LE formated string. 85 typedef struct _FPDF_BSTR { 86 // String buffer. 87 char* str; 88 // Length of the string, in bytes. 89 int len; 90 } FPDF_BSTR; 91 #endif // PDF_ENABLE_XFA 92 93 // For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a 94 // Windows unicode string, however, special care needs to be taken if you 95 // expect to process Unicode larger than 0xffff. 96 // 97 // For Linux/Unix programmers: most compiler/library environments use 4 bytes 98 // for a Unicode character, and you have to convert between FPDF_WIDESTRING and 99 // system wide string by yourself. 100 typedef const char* FPDF_STRING; 101 102 // Matrix for transformation. 103 typedef struct _FS_MATRIX_ { 104 float a; 105 float b; 106 float c; 107 float d; 108 float e; 109 float f; 110 } FS_MATRIX; 111 112 // Rectangle area(float) in device or page coordinate system. 113 typedef struct _FS_RECTF_ { 114 // The x-coordinate of the left-top corner. 115 float left; 116 // The y-coordinate of the left-top corner. 117 float top; 118 // The x-coordinate of the right-bottom corner. 119 float right; 120 // The y-coordinate of the right-bottom corner. 121 float bottom; 122 } * FS_LPRECTF, FS_RECTF; 123 124 // Const Pointer to FS_RECTF structure. 125 typedef const FS_RECTF* FS_LPCRECTF; 126 127 #if defined(_WIN32) && defined(FPDFSDK_EXPORTS) 128 // On Windows system, functions are exported in a DLL 129 #define DLLEXPORT __declspec(dllexport) 130 #define STDCALL __stdcall 131 #else 132 #define DLLEXPORT 133 #define STDCALL 134 #endif 135 136 // Exported Functions 137 #ifdef __cplusplus 138 extern "C" { 139 #endif 140 141 // Function: FPDF_InitLibrary 142 // Initialize the FPDFSDK library 143 // Parameters: 144 // None 145 // Return value: 146 // None. 147 // Comments: 148 // Convenience function to call FPDF_InitLibraryWithConfig() for 149 // backwards comatibility purposes. 150 DLLEXPORT void STDCALL FPDF_InitLibrary(); 151 152 // Process-wide options for initializing the library. 153 typedef struct FPDF_LIBRARY_CONFIG_ { 154 // Version number of the interface. Currently must be 2. 155 int version; 156 157 // Array of paths to scan in place of the defaults when using built-in 158 // FXGE font loading code. The array is terminated by a NULL pointer. 159 // The Array may be NULL itself to use the default paths. May be ignored 160 // entirely depending upon the platform. 161 const char** m_pUserFontPaths; 162 163 // Version 2. 164 165 // pointer to the v8::Isolate to use, or NULL to force PDFium to create one. 166 void* m_pIsolate; 167 168 // The embedder data slot to use in the v8::Isolate to store PDFium's 169 // per-isolate data. The value needs to be between 0 and 170 // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine 171 // for most embedders. 172 unsigned int m_v8EmbedderSlot; 173 } FPDF_LIBRARY_CONFIG; 174 175 // Function: FPDF_InitLibraryWithConfig 176 // Initialize the FPDFSDK library 177 // Parameters: 178 // config - configuration information as above. 179 // Return value: 180 // None. 181 // Comments: 182 // You have to call this function before you can call any PDF 183 // processing functions. 184 DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( 185 const FPDF_LIBRARY_CONFIG* config); 186 187 // Function: FPDF_DestroyLibary 188 // Release all resources allocated by the FPDFSDK library. 189 // Parameters: 190 // None. 191 // Return value: 192 // None. 193 // Comments: 194 // You can call this function to release all memory blocks allocated by 195 // the library. 196 // After this function is called, you should not call any PDF 197 // processing functions. 198 DLLEXPORT void STDCALL FPDF_DestroyLibrary(); 199 200 // Policy for accessing the local machine time. 201 #define FPDF_POLICY_MACHINETIME_ACCESS 0 202 203 // Function: FPDF_SetSandBoxPolicy 204 // Set the policy for the sandbox environment. 205 // Parameters: 206 // policy - The specified policy for setting, for example: 207 // FPDF_POLICY_MACHINETIME_ACCESS. 208 // enable - True to enable, false to disable the policy. 209 // Return value: 210 // None. 211 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, 212 FPDF_BOOL enable); 213 214 // Function: FPDF_LoadDocument 215 // Open and load a PDF document. 216 // Parameters: 217 // file_path - Path to the PDF file (including extension). 218 // password - A string used as the password for the PDF file. 219 // If no password is needed, empty or NULL can be used. 220 // Return value: 221 // A handle to the loaded document, or NULL on failure. 222 // Comments: 223 // Loaded document can be closed by FPDF_CloseDocument(). 224 // If this function fails, you can use FPDF_GetLastError() to retrieve 225 // the reason why it failed. 226 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, 227 FPDF_BYTESTRING password); 228 229 // Function: FPDF_LoadMemDocument 230 // Open and load a PDF document from memory. 231 // Parameters: 232 // data_buf - Pointer to a buffer containing the PDF document. 233 // size - Number of bytes in the PDF document. 234 // password - A string used as the password for the PDF file. 235 // If no password is needed, empty or NULL can be used. 236 // Return value: 237 // A handle to the loaded document, or NULL on failure. 238 // Comments: 239 // The memory buffer must remain valid when the document is open. 240 // The loaded document can be closed by FPDF_CloseDocument. 241 // If this function fails, you can use FPDF_GetLastError() to retrieve 242 // the reason why it failed. 243 // Notes: 244 // If PDFium is built with the XFA module, the application should call 245 // FPDF_LoadXFA() function after the PDF document loaded to support XFA 246 // fields defined in the fpdfformfill.h file. 247 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, 248 int size, 249 FPDF_BYTESTRING password); 250 251 // Structure for custom file access. 252 typedef struct { 253 // File length, in bytes. 254 unsigned long m_FileLen; 255 256 // A function pointer for getting a block of data from a specific position. 257 // Position is specified by byte offset from the beginning of the file. 258 // The position and size will never go out of range of the file length. 259 // It may be possible for FPDFSDK to call this function multiple times for 260 // the same position. 261 // Return value: should be non-zero if successful, zero for error. 262 int (*m_GetBlock)(void* param, 263 unsigned long position, 264 unsigned char* pBuf, 265 unsigned long size); 266 267 // A custom pointer for all implementation specific data. This pointer will 268 // be used as the first parameter to the m_GetBlock callback. 269 void* m_Param; 270 } FPDF_FILEACCESS; 271 272 #ifdef PDF_ENABLE_XFA 273 /** 274 * @brief Structure for file reading or writing (I/O). 275 * 276 * @note This is a handler and should be implemented by callers. 277 */ 278 typedef struct _FPDF_FILEHANDLER { 279 /** 280 * @brief User-defined data. 281 * @note Callers can use this field to track controls. 282 */ 283 FPDF_LPVOID clientData; 284 /** 285 * @brief Callback function to release the current file stream object. 286 * 287 * @param[in] clientData Pointer to user-defined data. 288 * 289 * @return None. 290 */ 291 void (*Release)(FPDF_LPVOID clientData); 292 /** 293 * @brief Callback function to retrieve the current file stream size. 294 * 295 * @param[in] clientData Pointer to user-defined data. 296 * 297 * @return Size of file stream. 298 */ 299 FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData); 300 /** 301 * @brief Callback function to read data from the current file stream. 302 * 303 * @param[in] clientData Pointer to user-defined data. 304 * @param[in] offset Offset position starts from the beginning of file 305 * stream. This parameter indicates reading position. 306 * @param[in] buffer Memory buffer to store data which are read from 307 * file stream. This parameter should not be <b>NULL</b>. 308 * @param[in] size Size of data which should be read from file 309 * stream, in bytes. The buffer indicated by the parameter <i>buffer</i> 310 * should be enough to store specified data. 311 * 312 * @return 0 for success, other value for failure. 313 */ 314 FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, 315 FPDF_DWORD offset, 316 FPDF_LPVOID buffer, 317 FPDF_DWORD size); 318 /** 319 * @brief Callback function to write data into the current file stream. 320 * 321 * @param[in] clientData Pointer to user-defined data. 322 * @param[in] offset Offset position starts from the beginning of file 323 * stream. This parameter indicates writing position. 324 * @param[in] buffer Memory buffer contains data which is written into 325 * file stream. This parameter should not be <b>NULL</b>. 326 * @param[in] size Size of data which should be written into file 327 * stream, in bytes. 328 * 329 * @return 0 for success, other value for failure. 330 */ 331 FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, 332 FPDF_DWORD offset, 333 FPDF_LPCVOID buffer, 334 FPDF_DWORD size); 335 /** 336 * @brief Callback function to flush all internal accessing buffers. 337 * 338 * @param[in] clientData Pointer to user-defined data. 339 * 340 * @return 0 for success, other value for failure. 341 */ 342 FPDF_RESULT (*Flush)(FPDF_LPVOID clientData); 343 /** 344 * @brief Callback function to change file size. 345 * 346 * @details This function is called under writing mode usually. Implementer 347 * can determine whether to realize it based on application requests. 348 * 349 * @param[in] clientData Pointer to user-defined data. 350 * @param[in] size New size of file stream, in bytes. 351 * 352 * @return 0 for success, other value for failure. 353 */ 354 FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size); 355 } FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER; 356 357 #endif 358 // Function: FPDF_LoadCustomDocument 359 // Load PDF document from a custom access descriptor. 360 // Parameters: 361 // pFileAccess - A structure for accessing the file. 362 // password - Optional password for decrypting the PDF file. 363 // Return value: 364 // A handle to the loaded document, or NULL on failure. 365 // Comments: 366 // The application must keep the file resources valid until the PDF 367 // document is closed. 368 // 369 // The loaded document can be closed with FPDF_CloseDocument. 370 // Notes: 371 // If PDFium is built with the XFA module, the application should call 372 // FPDF_LoadXFA() function after the PDF document loaded to support XFA 373 // fields defined in the fpdfformfill.h file. 374 DLLEXPORT FPDF_DOCUMENT STDCALL 375 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); 376 377 // Function: FPDF_GetFileVersion 378 // Get the file version of the given PDF document. 379 // Parameters: 380 // doc - Handle to a document. 381 // fileVersion - The PDF file version. File version: 14 for 1.4, 15 382 // for 1.5, ... 383 // Return value: 384 // True if succeeds, false otherwise. 385 // Comments: 386 // If the document was created by FPDF_CreateNewDocument, 387 // then this function will always fail. 388 DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, 389 int* fileVersion); 390 391 #define FPDF_ERR_SUCCESS 0 // No error. 392 #define FPDF_ERR_UNKNOWN 1 // Unknown error. 393 #define FPDF_ERR_FILE 2 // File not found or could not be opened. 394 #define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted. 395 #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password. 396 #define FPDF_ERR_SECURITY 5 // Unsupported security scheme. 397 #define FPDF_ERR_PAGE 6 // Page not found or content error. 398 #ifdef PDF_ENABLE_XFA 399 #define FPDF_ERR_XFALOAD 7 // Load XFA error. 400 #define FPDF_ERR_XFALAYOUT 8 // Layout XFA error. 401 #endif // PDF_ENABLE_XFA 402 403 // Function: FPDF_GetLastError 404 // Get last error code when a function fails. 405 // Parameters: 406 // None. 407 // Return value: 408 // A 32-bit integer indicating error code as defined above. 409 // Comments: 410 // If the previous SDK call succeeded, the return value of this 411 // function is not defined. 412 DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); 413 414 // Function: FPDF_GetDocPermission 415 // Get file permission flags of the document. 416 // Parameters: 417 // document - Handle to a document. Returned by FPDF_LoadDocument. 418 // Return value: 419 // A 32-bit integer indicating permission flags. Please refer to the 420 // PDF Reference for detailed descriptions. If the document is not 421 // protected, 0xffffffff will be returned. 422 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); 423 424 // Function: FPDF_GetSecurityHandlerRevision 425 // Get the revision for the security handler. 426 // Parameters: 427 // document - Handle to a document. Returned by FPDF_LoadDocument. 428 // Return value: 429 // The security handler revision number. Please refer to the PDF 430 // Reference for a detailed description. If the document is not 431 // protected, -1 will be returned. 432 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); 433 434 // Function: FPDF_GetPageCount 435 // Get total number of pages in the document. 436 // Parameters: 437 // document - Handle to document. Returned by FPDF_LoadDocument. 438 // Return value: 439 // Total number of pages in the document. 440 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); 441 442 // Function: FPDF_LoadPage 443 // Load a page inside the document. 444 // Parameters: 445 // document - Handle to document. Returned by FPDF_LoadDocument 446 // page_index - Index number of the page. 0 for the first page. 447 // Return value: 448 // A handle to the loaded page, or NULL if page load fails. 449 // Comments: 450 // The loaded page can be rendered to devices using FPDF_RenderPage. 451 // The loaded page can be closed using FPDF_ClosePage. 452 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, 453 int page_index); 454 455 // Function: FPDF_GetPageWidth 456 // Get page width. 457 // Parameters: 458 // page - Handle to the page. Returned by FPDF_LoadPage. 459 // Return value: 460 // Page width (excluding non-displayable area) measured in points. 461 // One point is 1/72 inch (around 0.3528 mm). 462 DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); 463 464 // Function: FPDF_GetPageHeight 465 // Get page height. 466 // Parameters: 467 // page - Handle to the page. Returned by FPDF_LoadPage. 468 // Return value: 469 // Page height (excluding non-displayable area) measured in points. 470 // One point is 1/72 inch (around 0.3528 mm) 471 DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); 472 473 // Function: FPDF_GetPageSizeByIndex 474 // Get the size of the page at the given index. 475 // Parameters: 476 // document - Handle to document. Returned by FPDF_LoadDocument. 477 // page_index - Page index, zero for the first page. 478 // width - Pointer to a double to receive the page width 479 // (in points). 480 // height - Pointer to a double to receive the page height 481 // (in points). 482 // Return value: 483 // Non-zero for success. 0 for error (document or page not found). 484 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, 485 int page_index, 486 double* width, 487 double* height); 488 489 // Page rendering flags. They can be combined with bit-wise OR. 490 // 491 // Set if annotations are to be rendered. 492 #define FPDF_ANNOT 0x01 493 // Set if using text rendering optimized for LCD display. 494 #define FPDF_LCD_TEXT 0x02 495 // Don't use the native text output available on some platforms 496 #define FPDF_NO_NATIVETEXT 0x04 497 // Grayscale output. 498 #define FPDF_GRAYSCALE 0x08 499 // Set if you want to get some debug info. 500 #define FPDF_DEBUG_INFO 0x80 501 // Set if you don't want to catch exceptions. 502 #define FPDF_NO_CATCH 0x100 503 // Limit image cache size. 504 #define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 505 // Always use halftone for image stretching. 506 #define FPDF_RENDER_FORCEHALFTONE 0x400 507 // Render for printing. 508 #define FPDF_PRINTING 0x800 509 // Set to disable anti-aliasing on text. 510 #define FPDF_RENDER_NO_SMOOTHTEXT 0x1000 511 // Set to disable anti-aliasing on images. 512 #define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000 513 // Set to disable anti-aliasing on paths. 514 #define FPDF_RENDER_NO_SMOOTHPATH 0x4000 515 // Set whether to render in a reverse Byte order, this flag is only used when 516 // rendering to a bitmap. 517 #define FPDF_REVERSE_BYTE_ORDER 0x10 518 519 #ifdef _WIN32 520 // Function: FPDF_RenderPage 521 // Render contents of a page to a device (screen, bitmap, or printer). 522 // This function is only supported on Windows. 523 // Parameters: 524 // dc - Handle to the device context. 525 // page - Handle to the page. Returned by FPDF_LoadPage. 526 // start_x - Left pixel position of the display area in 527 // device coordinates. 528 // start_y - Top pixel position of the display area in device 529 // coordinates. 530 // size_x - Horizontal size (in pixels) for displaying the page. 531 // size_y - Vertical size (in pixels) for displaying the page. 532 // rotate - Page orientation: 533 // 0 (normal) 534 // 1 (rotated 90 degrees clockwise) 535 // 2 (rotated 180 degrees) 536 // 3 (rotated 90 degrees counter-clockwise) 537 // flags - 0 for normal display, or combination of flags 538 // defined above. 539 // Return value: 540 // None. 541 DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, 542 FPDF_PAGE page, 543 int start_x, 544 int start_y, 545 int size_x, 546 int size_y, 547 int rotate, 548 int flags); 549 #endif 550 551 // Function: FPDF_RenderPageBitmap 552 // Render contents of a page to a device independent bitmap. 553 // Parameters: 554 // bitmap - Handle to the device independent bitmap (as the 555 // output buffer). The bitmap handle can be created 556 // by FPDFBitmap_Create. 557 // page - Handle to the page. Returned by FPDF_LoadPage 558 // start_x - Left pixel position of the display area in 559 // bitmap coordinates. 560 // start_y - Top pixel position of the display area in bitmap 561 // coordinates. 562 // size_x - Horizontal size (in pixels) for displaying the page. 563 // size_y - Vertical size (in pixels) for displaying the page. 564 // rotate - Page orientation: 565 // 0 (normal) 566 // 1 (rotated 90 degrees clockwise) 567 // 2 (rotated 180 degrees) 568 // 3 (rotated 90 degrees counter-clockwise) 569 // flags - 0 for normal display, or combination of flags 570 // defined above. 571 // Return value: 572 // None. 573 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, 574 FPDF_PAGE page, 575 int start_x, 576 int start_y, 577 int size_x, 578 int size_y, 579 int rotate, 580 int flags); 581 582 #ifdef _SKIA_SUPPORT_ 583 DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, 584 int size_x, 585 int size_y); 586 #endif 587 588 // Function: FPDF_ClosePage 589 // Close a loaded PDF page. 590 // Parameters: 591 // page - Handle to the loaded page. 592 // Return value: 593 // None. 594 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); 595 596 // Function: FPDF_CloseDocument 597 // Close a loaded PDF document. 598 // Parameters: 599 // document - Handle to the loaded document. 600 // Return value: 601 // None. 602 DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); 603 604 // Function: FPDF_DeviceToPage 605 // Convert the screen coordinates of a point to page coordinates. 606 // Parameters: 607 // page - Handle to the page. Returned by FPDF_LoadPage. 608 // start_x - Left pixel position of the display area in 609 // device coordinates. 610 // start_y - Top pixel position of the display area in device 611 // coordinates. 612 // size_x - Horizontal size (in pixels) for displaying the page. 613 // size_y - Vertical size (in pixels) for displaying the page. 614 // rotate - Page orientation: 615 // 0 (normal) 616 // 1 (rotated 90 degrees clockwise) 617 // 2 (rotated 180 degrees) 618 // 3 (rotated 90 degrees counter-clockwise) 619 // device_x - X value in device coordinates to be converted. 620 // device_y - Y value in device coordinates to be converted. 621 // page_x - A pointer to a double receiving the converted X 622 // value in page coordinates. 623 // page_y - A pointer to a double receiving the converted Y 624 // value in page coordinates. 625 // Return value: 626 // None. 627 // Comments: 628 // The page coordinate system has its origin at the left-bottom corner 629 // of the page, with the X-axis on the bottom going to the right, and 630 // the Y-axis on the left side going up. 631 // 632 // NOTE: this coordinate system can be altered when you zoom, scroll, 633 // or rotate a page, however, a point on the page should always have 634 // the same coordinate values in the page coordinate system. 635 // 636 // The device coordinate system is device dependent. For screen device, 637 // its origin is at the left-top corner of the window. However this 638 // origin can be altered by the Windows coordinate transformation 639 // utilities. 640 // 641 // You must make sure the start_x, start_y, size_x, size_y 642 // and rotate parameters have exactly same values as you used in 643 // the FPDF_RenderPage() function call. 644 DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, 645 int start_x, 646 int start_y, 647 int size_x, 648 int size_y, 649 int rotate, 650 int device_x, 651 int device_y, 652 double* page_x, 653 double* page_y); 654 655 // Function: FPDF_PageToDevice 656 // Convert the page coordinates of a point to screen coordinates. 657 // Parameters: 658 // page - Handle to the page. Returned by FPDF_LoadPage. 659 // start_x - Left pixel position of the display area in 660 // device coordinates. 661 // start_y - Top pixel position of the display area in device 662 // coordinates. 663 // size_x - Horizontal size (in pixels) for displaying the page. 664 // size_y - Vertical size (in pixels) for displaying the page. 665 // rotate - Page orientation: 666 // 0 (normal) 667 // 1 (rotated 90 degrees clockwise) 668 // 2 (rotated 180 degrees) 669 // 3 (rotated 90 degrees counter-clockwise) 670 // page_x - X value in page coordinates. 671 // page_y - Y value in page coordinate. 672 // device_x - A pointer to an integer receiving the result X 673 // value in device coordinates. 674 // device_y - A pointer to an integer receiving the result Y 675 // value in device coordinates. 676 // Return value: 677 // None. 678 // Comments: 679 // See comments for FPDF_DeviceToPage(). 680 DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, 681 int start_x, 682 int start_y, 683 int size_x, 684 int size_y, 685 int rotate, 686 double page_x, 687 double page_y, 688 int* device_x, 689 int* device_y); 690 691 // Function: FPDFBitmap_Create 692 // Create a device independent bitmap (FXDIB). 693 // Parameters: 694 // width - The number of pixels in width for the bitmap. 695 // Must be greater than 0. 696 // height - The number of pixels in height for the bitmap. 697 // Must be greater than 0. 698 // alpha - A flag indicating whether the alpha channel is used. 699 // Non-zero for using alpha, zero for not using. 700 // Return value: 701 // The created bitmap handle, or NULL if a parameter error or out of 702 // memory. 703 // Comments: 704 // The bitmap always uses 4 bytes per pixel. The first byte is always 705 // double word aligned. 706 // 707 // The byte order is BGRx (the last byte unused if no alpha channel) or 708 // BGRA. 709 // 710 // The pixels in a horizontal line are stored side by side, with the 711 // left most pixel stored first (with lower memory address). 712 // Each line uses width * 4 bytes. 713 // 714 // Lines are stored one after another, with the top most line stored 715 // first. There is no gap between adjacent lines. 716 // 717 // This function allocates enough memory for holding all pixels in the 718 // bitmap, but it doesn't initialize the buffer. Applications can use 719 // FPDFBitmap_FillRect to fill the bitmap using any color. 720 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, 721 int height, 722 int alpha); 723 724 // More DIB formats 725 // Gray scale bitmap, one byte per pixel. 726 #define FPDFBitmap_Gray 1 727 // 3 bytes per pixel, byte order: blue, green, red. 728 #define FPDFBitmap_BGR 2 729 // 4 bytes per pixel, byte order: blue, green, red, unused. 730 #define FPDFBitmap_BGRx 3 731 // 4 bytes per pixel, byte order: blue, green, red, alpha. 732 #define FPDFBitmap_BGRA 4 733 734 // Function: FPDFBitmap_CreateEx 735 // Create a device independent bitmap (FXDIB) 736 // Parameters: 737 // width - The number of pixels in width for the bitmap. 738 // Must be greater than 0. 739 // height - The number of pixels in height for the bitmap. 740 // Must be greater than 0. 741 // format - A number indicating for bitmap format, as defined 742 // above. 743 // first_scan - A pointer to the first byte of the first line if 744 // using an external buffer. If this parameter is NULL, 745 // then the a new buffer will be created. 746 // stride - Number of bytes for each scan line, for external 747 // buffer only. 748 // Return value: 749 // The bitmap handle, or NULL if parameter error or out of memory. 750 // Comments: 751 // Similar to FPDFBitmap_Create function, but allows for more formats 752 // and an external buffer is supported. The bitmap created by this 753 // function can be used in any place that a FPDF_BITMAP handle is 754 // required. 755 // 756 // If an external buffer is used, then the application should destroy 757 // the buffer by itself. FPDFBitmap_Destroy function will not destroy 758 // the buffer. 759 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, 760 int height, 761 int format, 762 void* first_scan, 763 int stride); 764 765 // Function: FPDFBitmap_FillRect 766 // Fill a rectangle in a bitmap. 767 // Parameters: 768 // bitmap - The handle to the bitmap. Returned by 769 // FPDFBitmap_Create. 770 // left - The left position. Starting from 0 at the 771 // left-most pixel. 772 // top - The top position. Starting from 0 at the 773 // top-most line. 774 // width - Width in pixels to be filled. 775 // height - Height in pixels to be filled. 776 // color - A 32-bit value specifing the color, in 8888 ARGB 777 // format. 778 // Return value: 779 // None. 780 // Comments: 781 // This function sets the color and (optionally) alpha value in the 782 // specified region of the bitmap. 783 // 784 // NOTE: If the alpha channel is used, this function does NOT 785 // composite the background with the source color, instead the 786 // background will be replaced by the source color and the alpha. 787 // 788 // If the alpha channel is not used, the alpha parameter is ignored. 789 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, 790 int left, 791 int top, 792 int width, 793 int height, 794 FPDF_DWORD color); 795 796 // Function: FPDFBitmap_GetBuffer 797 // Get data buffer of a bitmap. 798 // Parameters: 799 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. 800 // Return value: 801 // The pointer to the first byte of the bitmap buffer. 802 // Comments: 803 // The stride may be more than width * number of bytes per pixel 804 // 805 // Applications can use this function to get the bitmap buffer pointer, 806 // then manipulate any color and/or alpha values for any pixels in the 807 // bitmap. 808 // 809 // The data is in BGRA format. Where the A maybe unused if alpha was 810 // not specified. 811 DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); 812 813 // Function: FPDFBitmap_GetWidth 814 // Get width of a bitmap. 815 // Parameters: 816 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. 817 // Return value: 818 // The width of the bitmap in pixels. 819 DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); 820 821 // Function: FPDFBitmap_GetHeight 822 // Get height of a bitmap. 823 // Parameters: 824 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. 825 // Return value: 826 // The height of the bitmap in pixels. 827 DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); 828 829 // Function: FPDFBitmap_GetStride 830 // Get number of bytes for each line in the bitmap buffer. 831 // Parameters: 832 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. 833 // Return value: 834 // The number of bytes for each line in the bitmap buffer. 835 // Comments: 836 // The stride may be more than width * number of bytes per pixel. 837 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap); 838 839 // Function: FPDFBitmap_Destroy 840 // Destroy a bitmap and release all related buffers. 841 // Parameters: 842 // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. 843 // Return value: 844 // None. 845 // Comments: 846 // This function will not destroy any external buffers provided when 847 // the bitmap was created. 848 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); 849 850 // Function: FPDF_VIEWERREF_GetPrintScaling 851 // Whether the PDF document prefers to be scaled or not. 852 // Parameters: 853 // document - Handle to the loaded document. 854 // Return value: 855 // None. 856 DLLEXPORT FPDF_BOOL STDCALL 857 FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); 858 859 // Function: FPDF_VIEWERREF_GetNumCopies 860 // Returns the number of copies to be printed. 861 // Parameters: 862 // document - Handle to the loaded document. 863 // Return value: 864 // The number of copies to be printed. 865 DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); 866 867 // Function: FPDF_VIEWERREF_GetPrintPageRange 868 // Page numbers to initialize print dialog box when file is printed. 869 // Parameters: 870 // document - Handle to the loaded document. 871 // Return value: 872 // The print page range to be used for printing. 873 DLLEXPORT FPDF_PAGERANGE STDCALL 874 FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); 875 876 // Function: FPDF_VIEWERREF_GetDuplex 877 // Returns the paper handling option to be used when printing from 878 // the print dialog. 879 // Parameters: 880 // document - Handle to the loaded document. 881 // Return value: 882 // The paper handling option to be used when printing. 883 DLLEXPORT FPDF_DUPLEXTYPE STDCALL 884 FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document); 885 886 // Function: FPDF_CountNamedDests 887 // Get the count of named destinations in the PDF document. 888 // Parameters: 889 // document - Handle to a document 890 // Return value: 891 // The count of named destinations. 892 DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document); 893 894 // Function: FPDF_GetNamedDestByName 895 // Get a the destination handle for the given name. 896 // Parameters: 897 // document - Handle to the loaded document. 898 // name - The name of a destination. 899 // Return value: 900 // The handle to the destination. 901 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, 902 FPDF_BYTESTRING name); 903 904 // Function: FPDF_GetNamedDest 905 // Get the named destination by index. 906 // Parameters: 907 // document - Handle to a document 908 // index - The index of a named destination. 909 // buffer - The buffer to store the destination name, 910 // used as wchar_t*. 911 // buflen [in/out] - Size of the buffer in bytes on input, 912 // length of the result in bytes on output 913 // or -1 if the buffer is too small. 914 // Return value: 915 // The destination handle for a given index, or NULL if there is no 916 // named destination corresponding to |index|. 917 // Comments: 918 // Call this function twice to get the name of the named destination: 919 // 1) First time pass in |buffer| as NULL and get buflen. 920 // 2) Second time pass in allocated |buffer| and buflen to retrieve 921 // |buffer|, which should be used as wchar_t*. 922 // 923 // If buflen is not sufficiently large, it will be set to -1 upon 924 // return. 925 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, 926 int index, 927 void* buffer, 928 long* buflen); 929 930 #ifdef PDF_ENABLE_XFA 931 // Function: FPDF_BStr_Init 932 // Helper function to initialize a byte string. 933 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str); 934 935 // Function: FPDF_BStr_Set 936 // Helper function to set string data. 937 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, 938 FPDF_LPCSTR bstr, 939 int length); 940 941 // Function: FPDF_BStr_Clear 942 // Helper function to clear a byte string. 943 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str); 944 #endif // PDF_ENABLE_XFA 945 946 #ifdef __cplusplus 947 } 948 #endif 949 950 #endif // PUBLIC_FPDFVIEW_H_ 951