John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame^] | 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 | |
| 8 | #ifndef _FPDFVIEW_H_ |
| 9 | #define _FPDFVIEW_H_ |
| 10 | |
| 11 | #if defined(_WIN32) && !defined(__WINDOWS__) |
| 12 | #include <windows.h> |
| 13 | #endif |
| 14 | |
| 15 | // Data types |
| 16 | typedef void* FPDF_MODULEMGR; |
| 17 | |
| 18 | // PDF types |
| 19 | typedef void* FPDF_DOCUMENT; |
| 20 | typedef void* FPDF_PAGE; |
| 21 | typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc) |
| 22 | typedef void* FPDF_PATH; |
| 23 | typedef void* FPDF_CLIPPATH; |
| 24 | typedef void* FPDF_BITMAP; |
| 25 | typedef void* FPDF_FONT; |
| 26 | |
| 27 | typedef void* FPDF_TEXTPAGE; |
| 28 | typedef void* FPDF_SCHHANDLE; |
| 29 | typedef void* FPDF_PAGELINK; |
| 30 | typedef void* FPDF_HMODULE; |
| 31 | typedef void* FPDF_DOCSCHHANDLE; |
| 32 | |
| 33 | typedef void* FPDF_BOOKMARK; |
| 34 | typedef void* FPDF_DEST; |
| 35 | typedef void* FPDF_ACTION; |
| 36 | typedef void* FPDF_LINK; |
| 37 | |
| 38 | // Basic data types |
| 39 | typedef int FPDF_BOOL; |
| 40 | typedef int FPDF_ERROR; |
| 41 | typedef unsigned long FPDF_DWORD; |
| 42 | |
| 43 | typedef float FS_FLOAT; |
| 44 | |
| 45 | // String types |
| 46 | typedef unsigned short FPDF_WCHAR; |
| 47 | typedef unsigned char const* FPDF_LPCBYTE; |
| 48 | |
| 49 | // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE encoded), and platform dependent string |
| 50 | typedef const char* FPDF_BYTESTRING; |
| 51 | |
| 52 | typedef const unsigned short* FPDF_WIDESTRING; // Foxit PDF SDK always use UTF-16LE encoding wide string, |
| 53 | // each character use 2 bytes (except surrogation), with low byte first. |
| 54 | |
| 55 | // For Windows programmers: for most case it's OK to treat FPDF_WIDESTRING as Windows unicode string, |
| 56 | // however, special care needs to be taken if you expect to process Unicode larger than 0xffff. |
| 57 | // For Linux/Unix programmers: most compiler/library environment uses 4 bytes for a Unicode character, |
| 58 | // you have to convert between FPDF_WIDESTRING and system wide string by yourself. |
| 59 | |
| 60 | #ifdef _WIN32_WCE |
| 61 | typedef const unsigned short* FPDF_STRING; |
| 62 | #else |
| 63 | typedef const char* FPDF_STRING; |
| 64 | #endif |
| 65 | |
| 66 | #ifndef _FS_DEF_MATRIX_ |
| 67 | #define _FS_DEF_MATRIX_ |
| 68 | /** @brief Matrix for transformation. */ |
| 69 | typedef struct _FS_MATRIX_ |
| 70 | { |
| 71 | float a; /**< @brief Coefficient a.*/ |
| 72 | float b; /**< @brief Coefficient b.*/ |
| 73 | float c; /**< @brief Coefficient c.*/ |
| 74 | float d; /**< @brief Coefficient d.*/ |
| 75 | float e; /**< @brief Coefficient e.*/ |
| 76 | float f; /**< @brief Coefficient f.*/ |
| 77 | } FS_MATRIX; |
| 78 | #endif |
| 79 | |
| 80 | #ifndef _FS_DEF_RECTF_ |
| 81 | #define _FS_DEF_RECTF_ |
| 82 | /** @brief Rectangle area(float) in device or page coordination system. */ |
| 83 | typedef struct _FS_RECTF_ |
| 84 | { |
| 85 | /**@{*/ |
| 86 | /** @brief The x-coordinate of the left-top corner. */ |
| 87 | float left; |
| 88 | /** @brief The y-coordinate of the left-top corner. */ |
| 89 | float top; |
| 90 | /** @brief The x-coordinate of the right-bottom corner. */ |
| 91 | float right; |
| 92 | /** @brief The y-coordinate of the right-bottom corner. */ |
| 93 | float bottom; |
| 94 | /**@}*/ |
| 95 | }* FS_LPRECTF, FS_RECTF; |
| 96 | /** @brief Const Pointer to ::FS_RECTF structure.*/ |
| 97 | typedef const FS_RECTF* FS_LPCRECTF; |
| 98 | #endif |
| 99 | |
| 100 | #if defined(_WIN32) && defined(FPDFSDK_EXPORTS) |
| 101 | // On Windows system, functions are exported in a DLL |
| 102 | #define DLLEXPORT __declspec( dllexport ) |
| 103 | #define STDCALL __stdcall |
| 104 | #else |
| 105 | #define DLLEXPORT |
| 106 | #define STDCALL |
| 107 | #endif |
| 108 | |
| 109 | extern const char g_ExpireDate[]; |
| 110 | extern const char g_ModuleCodes[]; |
| 111 | |
| 112 | // Exported Functions |
| 113 | #ifdef __cplusplus |
| 114 | extern "C" { |
| 115 | #endif |
| 116 | |
| 117 | // Function: FPDF_InitLibrary |
| 118 | // Initialize the FPDFSDK library |
| 119 | // Parameters: |
| 120 | // hInstance - For WIN32 system only: the instance of the executable or DLL module. |
| 121 | // Return value: |
| 122 | // None. |
| 123 | // Comments: |
| 124 | // You have to call this function before you can call any PDF processing functions. |
| 125 | |
| 126 | DLLEXPORT void STDCALL FPDF_InitLibrary(void* hInstance); |
| 127 | |
| 128 | |
| 129 | // Function: FPDF_DestroyLibary |
| 130 | // Release all resources allocated by the FPDFSDK library. |
| 131 | // Parameters: |
| 132 | // None. |
| 133 | // Return value: |
| 134 | // None. |
| 135 | // Comments: |
| 136 | // You can call this function to release all memory blocks allocated by the library. |
| 137 | // After this function called, you should not call any PDF processing functions. |
| 138 | DLLEXPORT void STDCALL FPDF_DestroyLibrary(); |
| 139 | |
| 140 | //Policy for accessing the local machine time. |
| 141 | #define FPDF_POLICY_MACHINETIME_ACCESS 0 |
| 142 | |
| 143 | // Function: FPDF_SetSandBoxPolicy |
| 144 | // Set the policy for the sandbox environment. |
| 145 | // Parameters: |
| 146 | // policy - The specified policy for setting, for example:FPDF_POLICY_MACHINETIME_ACCESS. |
| 147 | // enable - True for enable, False for disable the policy. |
| 148 | // Return value: |
| 149 | // None. |
| 150 | DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); |
| 151 | |
| 152 | /** |
| 153 | * Open and load a PDF document. |
| 154 | * @param[in] file_path - Path to the PDF file (including extension). |
| 155 | * @param[in] password - A string used as the password for PDF file. |
| 156 | * If no password needed, empty or NULL can be used. |
| 157 | * @note Loaded document can be closed by FPDF_CloseDocument. |
| 158 | * If this function fails, you can use FPDF_GetLastError() to retrieve |
| 159 | * the reason why it fails. |
| 160 | * @retval A handle to the loaded document. If failed, NULL is returned. |
| 161 | */ |
| 162 | DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, |
| 163 | FPDF_BYTESTRING password); |
| 164 | |
| 165 | // Function: FPDF_LoadMemDocument |
| 166 | // Open and load a PDF document from memory. |
| 167 | // Parameters: |
| 168 | // data_buf - Pointer to a buffer containing the PDF document. |
| 169 | // size - Number of bytes in the PDF document. |
| 170 | // password - A string used as the password for PDF file. |
| 171 | // If no password needed, empty or NULL can be used. |
| 172 | // Return value: |
| 173 | // A handle to the loaded document. If failed, NULL is returned. |
| 174 | // Comments: |
| 175 | // The memory buffer must remain valid when the document is open. |
| 176 | // Loaded document can be closed by FPDF_CloseDocument. |
| 177 | // If this function fails, you can use FPDF_GetLastError() to retrieve |
| 178 | // the reason why it fails. |
| 179 | // |
| 180 | DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, |
| 181 | int size, FPDF_BYTESTRING password); |
| 182 | |
| 183 | // Structure for custom file access. |
| 184 | typedef struct { |
| 185 | // File length, in bytes. |
| 186 | unsigned long m_FileLen; |
| 187 | |
| 188 | // A function pointer for getting a block of data from specific position. |
| 189 | // Position is specified by byte offset from beginning of the file. |
| 190 | // The position and size will never go out range of file length. |
| 191 | // It may be possible for FPDFSDK to call this function multiple times for same position. |
| 192 | // Return value: should be non-zero if successful, zero for error. |
| 193 | int (*m_GetBlock)(void* param, unsigned long position, unsigned char* pBuf, unsigned long size); |
| 194 | |
| 195 | // A custom pointer for all implementation specific data. |
| 196 | // This pointer will be used as the first parameter to m_GetBlock callback. |
| 197 | void* m_Param; |
| 198 | } FPDF_FILEACCESS; |
| 199 | |
| 200 | // Function: FPDF_LoadCustomDocument |
| 201 | // Load PDF document from a custom access descriptor. |
| 202 | // Parameters: |
| 203 | // pFileAccess - A structure for access the file. |
| 204 | // password - Optional password for decrypting the PDF file. |
| 205 | // Return value: |
| 206 | // A handle to the loaded document. If failed, NULL is returned. |
| 207 | // Comments: |
| 208 | // The application should maintain the file resources being valid until the PDF document close. |
| 209 | // Loaded document can be closed by FPDF_CloseDocument. |
| 210 | DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, |
| 211 | FPDF_BYTESTRING password); |
| 212 | |
| 213 | // Function: FPDF_GetFileVersion |
| 214 | // Get the file version of the specific PDF document. |
| 215 | // Parameters: |
| 216 | // doc - Handle to document. |
| 217 | // fileVersion - The PDF file version. File version: 14 for 1.4, 15 for 1.5, ... |
| 218 | // Return value: |
| 219 | // TRUE if this call succeed, If failed, FALSE is returned. |
| 220 | // Comments: |
| 221 | // If the document is created by function ::FPDF_CreateNewDocument, then this function would always fail. |
| 222 | DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVersion); |
| 223 | |
| 224 | #define FPDF_ERR_SUCCESS 0 // No error. |
| 225 | #define FPDF_ERR_UNKNOWN 1 // Unknown error. |
| 226 | #define FPDF_ERR_FILE 2 // File not found or could not be opened. |
| 227 | #define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted. |
| 228 | #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password. |
| 229 | #define FPDF_ERR_SECURITY 5 // Unsupported security scheme. |
| 230 | #define FPDF_ERR_PAGE 6 // Page not found or content error. |
| 231 | |
| 232 | // Function: FPDF_GetLastError |
| 233 | // Get last error code when an SDK function failed. |
| 234 | // Parameters: |
| 235 | // None. |
| 236 | // Return value: |
| 237 | // A 32-bit integer indicating error codes (defined above). |
| 238 | // Comments: |
| 239 | // If the previous SDK call succeeded, the return value of this function |
| 240 | // is not defined. |
| 241 | // |
| 242 | DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); |
| 243 | |
| 244 | // Function: FPDF_GetDocPermission |
| 245 | // Get file permission flags of the document. |
| 246 | // Parameters: |
| 247 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 248 | // Return value: |
| 249 | // A 32-bit integer indicating permission flags. Please refer to PDF Reference for |
| 250 | // detailed description. If the document is not protected, 0xffffffff will be returned. |
| 251 | // |
| 252 | DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); |
| 253 | |
| 254 | // Function: FPDF_GetPageCount |
| 255 | // Get total number of pages in a document. |
| 256 | // Parameters: |
| 257 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 258 | // Return value: |
| 259 | // Total number of pages in the document. |
| 260 | // |
| 261 | DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); |
| 262 | |
| 263 | // Function: FPDF_LoadPage |
| 264 | // Load a page inside a document. |
| 265 | // Parameters: |
| 266 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 267 | // page_index - Index number of the page. 0 for the first page. |
| 268 | // Return value: |
| 269 | // A handle to the loaded page. If failed, NULL is returned. |
| 270 | // Comments: |
| 271 | // Loaded page can be rendered to devices using FPDF_RenderPage function. |
| 272 | // Loaded page can be closed by FPDF_ClosePage. |
| 273 | // |
| 274 | DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index); |
| 275 | |
| 276 | // Function: FPDF_GetPageWidth |
| 277 | // Get page width. |
| 278 | // Parameters: |
| 279 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 280 | // Return value: |
| 281 | // Page width (excluding non-displayable area) measured in points. |
| 282 | // One point is 1/72 inch (around 0.3528 mm). |
| 283 | // |
| 284 | DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); |
| 285 | |
| 286 | // Function: FPDF_GetPageHeight |
| 287 | // Get page height. |
| 288 | // Parameters: |
| 289 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 290 | // Return value: |
| 291 | // Page height (excluding non-displayable area) measured in points. |
| 292 | // One point is 1/72 inch (around 0.3528 mm) |
| 293 | // |
| 294 | DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); |
| 295 | |
| 296 | // Function: FPDF_GetPageSizeByIndex |
| 297 | // Get the size of a page by index. |
| 298 | // Parameters: |
| 299 | // document - Handle to document. Returned by FPDF_LoadDocument function. |
| 300 | // page_index - Page index, zero for the first page. |
| 301 | // width - Pointer to a double value receiving the page width (in points). |
| 302 | // height - Pointer to a double value receiving the page height (in points). |
| 303 | // Return value: |
| 304 | // Non-zero for success. 0 for error (document or page not found). |
| 305 | // |
| 306 | DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, double* width, double* height); |
| 307 | |
| 308 | |
| 309 | // Page rendering flags. They can be combined with bit OR. |
| 310 | #define FPDF_ANNOT 0x01 // Set if annotations are to be rendered. |
| 311 | #define FPDF_LCD_TEXT 0x02 // Set if using text rendering optimized for LCD display. |
| 312 | #define FPDF_NO_NATIVETEXT 0x04 // Don't use the native text output available on some platforms |
| 313 | #define FPDF_GRAYSCALE 0x08 // Grayscale output. |
| 314 | #define FPDF_DEBUG_INFO 0x80 // Set if you want to get some debug info. |
| 315 | // Please discuss with Foxit first if you need to collect debug info. |
| 316 | #define FPDF_NO_CATCH 0x100 // Set if you don't want to catch exception. |
| 317 | #define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 // Limit image cache size. |
| 318 | #define FPDF_RENDER_FORCEHALFTONE 0x400 // Always use halftone for image stretching. |
| 319 | #define FPDF_PRINTING 0x800 // Render for printing. |
| 320 | #define FPDF_REVERSE_BYTE_ORDER 0x10 //set whether render in a reverse Byte order, this flag only |
| 321 | //enable when render to a bitmap. |
| 322 | #ifdef _WIN32 |
| 323 | // Function: FPDF_RenderPage |
| 324 | // Render contents in a page to a device (screen, bitmap, or printer). |
| 325 | // This function is only supported on Windows system. |
| 326 | // Parameters: |
| 327 | // dc - Handle to device context. |
| 328 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 329 | // start_x - Left pixel position of the display area in the device coordinate. |
| 330 | // start_y - Top pixel position of the display area in the device coordinate. |
| 331 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 332 | // size_y - Vertical size (in pixels) for displaying the page. |
| 333 | // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), |
| 334 | // 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). |
| 335 | // flags - 0 for normal display, or combination of flags defined above. |
| 336 | // Return value: |
| 337 | // None. |
| 338 | // |
| 339 | DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, |
| 340 | int rotate, int flags); |
| 341 | #endif |
| 342 | |
| 343 | // Function: FPDF_RenderPageBitmap |
| 344 | // Render contents in a page to a device independent bitmap |
| 345 | // Parameters: |
| 346 | // bitmap - Handle to the device independent bitmap (as the output buffer). |
| 347 | // Bitmap handle can be created by FPDFBitmap_Create function. |
| 348 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 349 | // start_x - Left pixel position of the display area in the bitmap coordinate. |
| 350 | // start_y - Top pixel position of the display area in the bitmap coordinate. |
| 351 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 352 | // size_y - Vertical size (in pixels) for displaying the page. |
| 353 | // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), |
| 354 | // 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). |
| 355 | // flags - 0 for normal display, or combination of flags defined above. |
| 356 | // Return value: |
| 357 | // None. |
| 358 | // |
| 359 | DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, |
| 360 | int size_x, int size_y, int rotate, int flags); |
| 361 | |
| 362 | // Function: FPDF_ClosePage |
| 363 | // Close a loaded PDF page. |
| 364 | // Parameters: |
| 365 | // page - Handle to the loaded page. |
| 366 | // Return value: |
| 367 | // None. |
| 368 | // |
| 369 | DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); |
| 370 | |
| 371 | // Function: FPDF_CloseDocument |
| 372 | // Close a loaded PDF document. |
| 373 | // Parameters: |
| 374 | // document - Handle to the loaded document. |
| 375 | // Return value: |
| 376 | // None. |
| 377 | // |
| 378 | DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); |
| 379 | |
| 380 | // Function: FPDF_DeviceToPage |
| 381 | // Convert the screen coordinate of a point to page coordinate. |
| 382 | // Parameters: |
| 383 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 384 | // start_x - Left pixel position of the display area in the device coordinate. |
| 385 | // start_y - Top pixel position of the display area in the device coordinate. |
| 386 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 387 | // size_y - Vertical size (in pixels) for displaying the page. |
| 388 | // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), |
| 389 | // 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). |
| 390 | // device_x - X value in device coordinate, for the point to be converted. |
| 391 | // device_y - Y value in device coordinate, for the point to be converted. |
| 392 | // page_x - A Pointer to a double receiving the converted X value in page coordinate. |
| 393 | // page_y - A Pointer to a double receiving the converted Y value in page coordinate. |
| 394 | // Return value: |
| 395 | // None. |
| 396 | // Comments: |
| 397 | // The page coordinate system has its origin at left-bottom corner of the page, with X axis goes along |
| 398 | // the bottom side to the right, and Y axis goes along the left side upward. NOTE: this coordinate system |
| 399 | // can be altered when you zoom, scroll, or rotate a page, however, a point on the page should always have |
| 400 | // the same coordinate values in the page coordinate system. |
| 401 | // |
| 402 | // The device coordinate system is device dependent. For screen device, its origin is at left-top |
| 403 | // corner of the window. However this origin can be altered by Windows coordinate transformation |
| 404 | // utilities. You must make sure the start_x, start_y, size_x, size_y and rotate parameters have exactly |
| 405 | // same values as you used in FPDF_RenderPage() function call. |
| 406 | // |
| 407 | DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, |
| 408 | int rotate, int device_x, int device_y, double* page_x, double* page_y); |
| 409 | |
| 410 | // Function: FPDF_PageToDevice |
| 411 | // Convert the page coordinate of a point to screen coordinate. |
| 412 | // Parameters: |
| 413 | // page - Handle to the page. Returned by FPDF_LoadPage function. |
| 414 | // start_x - Left pixel position of the display area in the device coordinate. |
| 415 | // start_y - Top pixel position of the display area in the device coordinate. |
| 416 | // size_x - Horizontal size (in pixels) for displaying the page. |
| 417 | // size_y - Vertical size (in pixels) for displaying the page. |
| 418 | // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), |
| 419 | // 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). |
| 420 | // page_x - X value in page coordinate, for the point to be converted. |
| 421 | // page_y - Y value in page coordinate, for the point to be converted. |
| 422 | // device_x - A pointer to an integer receiving the result X value in device coordinate. |
| 423 | // device_y - A pointer to an integer receiving the result Y value in device coordinate. |
| 424 | // Return value: |
| 425 | // None. |
| 426 | // Comments: |
| 427 | // See comments of FPDF_DeviceToPage() function. |
| 428 | // |
| 429 | DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, |
| 430 | int rotate, double page_x, double page_y, int* device_x, int* device_y); |
| 431 | |
| 432 | // Function: FPDFBitmap_Create |
| 433 | // Create a Foxit Device Independent Bitmap (FXDIB). |
| 434 | // Parameters: |
| 435 | // width - Number of pixels in a horizontal line of the bitmap. Must be greater than 0. |
| 436 | // height - Number of pixels in a vertical line of the bitmap. Must be greater than 0. |
| 437 | // alpha - A flag indicating whether alpha channel is used. Non-zero for using alpha, zero for not using. |
| 438 | // Return value: |
| 439 | // The created bitmap handle, or NULL if parameter error or out of memory. |
| 440 | // Comments: |
| 441 | // An FXDIB always use 4 byte per pixel. The first byte of a pixel is always double word aligned. |
| 442 | // Each pixel contains red (R), green (G), blue (B) and optionally alpha (A) values. |
| 443 | // The byte order is BGRx (the last byte unused if no alpha channel) or BGRA. |
| 444 | // |
| 445 | // The pixels in a horizontal line (also called scan line) are stored side by side, with left most |
| 446 | // pixel stored first (with lower memory address). Each scan line uses width*4 bytes. |
| 447 | // |
| 448 | // Scan lines are stored one after another, with top most scan line stored first. There is no gap |
| 449 | // between adjacent scan lines. |
| 450 | // |
| 451 | // This function allocates enough memory for holding all pixels in the bitmap, but it doesn't |
| 452 | // initialize the buffer. Applications can use FPDFBitmap_FillRect to fill the bitmap using any color. |
| 453 | DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha); |
| 454 | |
| 455 | // More DIB formats |
| 456 | #define FPDFBitmap_Gray 1 // Gray scale bitmap, one byte per pixel. |
| 457 | #define FPDFBitmap_BGR 2 // 3 bytes per pixel, byte order: blue, green, red. |
| 458 | #define FPDFBitmap_BGRx 3 // 4 bytes per pixel, byte order: blue, green, red, unused. |
| 459 | #define FPDFBitmap_BGRA 4 // 4 bytes per pixel, byte order: blue, green, red, alpha. |
| 460 | |
| 461 | // Function: FPDFBitmap_CreateEx |
| 462 | // Create a Foxit Device Independent Bitmap (FXDIB) |
| 463 | // Parameters: |
| 464 | // width - Number of pixels in a horizontal line of the bitmap. Must be greater than 0. |
| 465 | // height - Number of pixels in a vertical line of the bitmap. Must be greater than 0. |
| 466 | // format - A number indicating for bitmap format, as defined above. |
| 467 | // first_scan - A pointer to the first byte of first scan line, for external buffer |
| 468 | // only. If this parameter is NULL, then the SDK will create its own buffer. |
| 469 | // stride - Number of bytes for each scan line, for external buffer only.. |
| 470 | // Return value: |
| 471 | // The created bitmap handle, or NULL if parameter error or out of memory. |
| 472 | // Comments: |
| 473 | // Similar to FPDFBitmap_Create function, with more formats and external buffer supported. |
| 474 | // Bitmap created by this function can be used in any place that a FPDF_BITMAP handle is |
| 475 | // required. |
| 476 | // |
| 477 | // If external scanline buffer is used, then the application should destroy the buffer |
| 478 | // by itself. FPDFBitmap_Destroy function will not destroy the buffer. |
| 479 | // |
| 480 | DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, int height, int format, void* first_scan, int stride); |
| 481 | |
| 482 | // Function: FPDFBitmap_FillRect |
| 483 | // Fill a rectangle area in an FXDIB. |
| 484 | // Parameters: |
| 485 | // bitmap - The handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 486 | // left - The left side position. Starting from 0 at the left-most pixel. |
| 487 | // top - The top side position. Starting from 0 at the top-most scan line. |
| 488 | // width - Number of pixels to be filled in each scan line. |
| 489 | // height - Number of scan lines to be filled. |
| 490 | // red - A number from 0 to 255, identifying the red intensity. |
| 491 | // green - A number from 0 to 255, identifying the green intensity. |
| 492 | // blue - A number from 0 to 255, identifying the blue intensity. |
| 493 | // alpha - (Only if the alpha channeled is used when bitmap created) A number from 0 to 255, |
| 494 | // identifying the alpha value. |
| 495 | // Return value: |
| 496 | // None. |
| 497 | // Comments: |
| 498 | // This function set the color and (optionally) alpha value in specified region of the bitmap. |
| 499 | // NOTE: If alpha channel is used, this function does NOT composite the background with the source color, |
| 500 | // instead the background will be replaced by the source color and alpha. |
| 501 | // If alpha channel is not used, the "alpha" parameter is ignored. |
| 502 | // |
| 503 | DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top, int width, int height, |
| 504 | int red, int green, int blue, int alpha); |
| 505 | |
| 506 | // Function: FPDFBitmap_GetBuffer |
| 507 | // Get data buffer of an FXDIB |
| 508 | // Parameters: |
| 509 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 510 | // Return value: |
| 511 | // The pointer to the first byte of the bitmap buffer. |
| 512 | // Comments: |
| 513 | // The stride may be more than width * number of bytes per pixel |
| 514 | // Applications can use this function to get the bitmap buffer pointer, then manipulate any color |
| 515 | // and/or alpha values for any pixels in the bitmap. |
| 516 | DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); |
| 517 | |
| 518 | // Function: FPDFBitmap_GetWidth |
| 519 | // Get width of an FXDIB. |
| 520 | // Parameters: |
| 521 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 522 | // Return value: |
| 523 | // The number of pixels in a horizontal line of the bitmap. |
| 524 | DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); |
| 525 | |
| 526 | // Function: FPDFBitmap_GetHeight |
| 527 | // Get height of an FXDIB. |
| 528 | // Parameters: |
| 529 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 530 | // Return value: |
| 531 | // The number of pixels in a vertical line of the bitmap. |
| 532 | DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); |
| 533 | |
| 534 | // Function: FPDFBitmap_GetStride |
| 535 | // Get number of bytes for each scan line in the bitmap buffer. |
| 536 | // Parameters: |
| 537 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 538 | // Return value: |
| 539 | // The number of bytes for each scan line in the bitmap buffer. |
| 540 | // Comments: |
| 541 | // The stride may be more than width * number of bytes per pixel |
| 542 | DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap); |
| 543 | |
| 544 | // Function: FPDFBitmap_Destroy |
| 545 | // Destroy an FXDIB and release all related buffers. |
| 546 | // Parameters: |
| 547 | // bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. |
| 548 | // Return value: |
| 549 | // None. |
| 550 | // Comments: |
| 551 | // This function will not destroy any external buffer. |
| 552 | // |
| 553 | DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); |
| 554 | |
| 555 | // Function: FPDF_VIEWERREF_GetPrintScaling |
| 556 | // Whether the PDF document prefers to be scaled or not. |
| 557 | // Parameters: |
| 558 | // document - Handle to the loaded document. |
| 559 | // Return value: |
| 560 | // None. |
| 561 | // |
| 562 | DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); |
| 563 | |
| 564 | // Function: FPDF_GetNamedDestByName |
| 565 | // get a special dest handle by the index. |
| 566 | // Parameters: |
| 567 | // document - Handle to the loaded document. |
| 568 | // name - The name of a special named dest. |
| 569 | // Return value: |
| 570 | // The handle of the dest. |
| 571 | // |
| 572 | DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_BYTESTRING name); |
| 573 | |
| 574 | #ifdef __cplusplus |
| 575 | }; |
| 576 | #endif |
| 577 | |
| 578 | #endif // _FPDFVIEW_H_ |