PageRenderTime 70ms CodeModel.GetById 18ms app.highlight 35ms RepoModel.GetById 2ms app.codeStats 0ms

/src/compiler/android/jni/ftk/fpdfemb.h

http://ftk.googlecode.com/
C++ Header | 1590 lines | 241 code | 125 blank | 1224 comment | 0 complexity | 762a27e5ce56d87c4fc62011a1aa6b6e MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1// FPDFEMB.H - Header file for FPDFEMB SDK
   2// Copyright (c) 2007-2008 Foxit Software Company, All Right Reserved.
   3
   4// Date: 2008-04-07
   5
   6// Embedded platforms have many different aspects from desktop platforms,
   7// among them, the followings are most important for PDF processing:
   8//
   9// 1.	Embedded platforms have only limited memory, and there is no virtual memory.
  10//		PDF is a very complicated format, processing PDF may consumes quite
  11//		large amount of memory, even for some smaller PDFs. And, in order to 
  12//		increase the performance of PDF parsing and rendering, cache memory
  13//		is often used. For some big PDFs with many pages, the cache may grow
  14//		while user browing through pages, eventually, for some PDFs, the memory
  15//		on the device may run out.
  16//
  17//		FPDFEMB SDK allows graceful out-of-memory (OOM) handling by returning 
  18//		OOM error code for all functions that may involve memory allocation. 
  19//		When an application detects OOM situation, it can do one of the followings:
  20//
  21//			a) Give user some prompt and quit the application or close the document;
  22//			b) Or better, try to recover from the error. Sometimes OOM can be caused
  23//				by ever-growing cache. For example, when user browses a 1000-page 
  24//				document, let's say OOM happen at page #300. In this case, the
  25//				application might close the whole document (cache will be gone with
  26//				it), reopen the document, then go directly to page #300. It's likely
  27//				the process will go through this time. This is called "OOM recovery".
  28//				If OOM happens again during a recovery, then, it's not possible to finish
  29//				the process, the application must quit of close the document.
  30//
  31// 2.	Embedded platforms has only limited computing power. Since some PDFs
  32//		can be very complicated and require a lot of processing to be displayed,
  33//		it may take a lot of time for the process to finish. This may cause
  34//		some problem with user experience, especially for devices like mobile
  35//		phones, when an application may need to be put on hold any time. Therefore, 
  36//		it's important to break lengthy process into small steps which can be 
  37//		stopped or resumed at any time. We call this kind of process as 
  38//		"progressive process".
  39//
  40//		FPDFEMB SDK allows progressive page parsing and rendering, the most time-
  41//		consuming part of PDF processing.
  42//
  43// IMPORTANT:
  44//		FPDFEMB module is not intended to run in multi-threaded environment.
  45
  46// Components inside FPDFEMB:
  47//		* Library Memory Management
  48//		* Document Operations
  49//		* Page Basic Operations
  50//		* Page Parsing
  51//		* Page Rendering
  52//		* Coordination Conversion
  53//		* Text Search
  54//		* Text Information
  55//		* Device Independant Bitmap
  56//		* Custom Font Handler and CJK Support
  57//		* Bookmark Information
  58//		* Hyperlink Information
  59//		* Graphic Output
  60
  61#ifndef _FPDFEMB_H_
  62#define _FPDFEMB_H_
  63
  64#ifdef __cplusplus
  65extern "C" {
  66#endif
  67
  68// Standard return type for many FPDFEMB functions: FPDFERR_SUCCESS for success, otherwise error code
  69typedef int FPDFEMB_RESULT;
  70
  71// Standard boolean type: 0 for false, non-zero for true
  72typedef int FPDFEMB_BOOL;
  73
  74// Unicode character. FPDFEMB uses UTF16LE format for unicode string.
  75typedef unsigned short FPDFEMB_WCHAR;
  76
  77// Error codes
  78#define FPDFERR_SUCCESS		0
  79#define FPDFERR_MEMORY		1		// Out of memory
  80#define FPDFERR_ERROR		2		// Error of any kind, without specific reason
  81#define FPDFERR_PASSWORD	3		// Incorrect password
  82#define FPDFERR_FORMAT		4		// Not PDF format
  83#define FPDFERR_FILE		5		// File access error
  84#define FPDFERR_PARAM		6		// Parameter error
  85#define FPDFERR_STATUS		7		// Not in correct status
  86#define FPDFERR_TOBECONTINUED	8	// To be continued
  87#define FPDFERR_NOTFOUND	9		// Search result not found
  88
  89/********************************************************************************************
  90****
  91****		Library Memory Management
  92****
  93********************************************************************************************/
  94
  95// Structure: FPDFEMB_MEMMGR
  96//			Including interfaces implemented by host application, providing memory allocation
  97//			facilities. All members are required.
  98//			A memory manager structure is required to be valid during the entire period
  99//			when an application using FPDFEMB module.
 100//
 101//			IMPORTANT NOTE: using of this interface is strongly not recommended, because
 102//			FPDFEMB now internally use FPDFEMB_MEMMGR_EX interface, which allows more
 103//			advanced memory management. This interface is retained for backward compatibility
 104//			only, and maybe discontinued in the future.
 105//
 106struct FPDFEMB_MEMMGR {
 107	// Interface: Alloc
 108	//		Allocate a memory block
 109	// Parameters:
 110	//		pMgr		-	Pointer to the memory manager.
 111	//		size		-	Number of bytes for the memory block.
 112	// Return Value:
 113	//		The pointer to allocated memory block. NULL if no memory available.
 114	// Comments:
 115	//		In order to handle OOM situation, application can use longjmp() inside 
 116	//		implementation of this function. If underlying memory manager fails to 
 117	//		allocate enough memory, then application can use longjmp() to jump to
 118	//		OOM handling codes.
 119	//
 120	void*	(*Alloc)(struct FPDFEMB_MEMMGR* pMgr, unsigned int size);
 121
 122	// Interface: AllocNL
 123	//		Allocate a memory block, without leaving
 124	// Parameters:
 125	//		pMgr		-	Pointer to the memory manager.
 126	//		size		-	Number of bytes for the memory block.
 127	// Return Value:
 128	//		The pointer to allocated memory block. NULL if no memory available.
 129	// Comments:
 130	//		Implementation MUST return NULL if no memory available, no exception
 131	//		or longjmp() can be used.
 132	//
 133	void*	(*AllocNL)(struct FPDFEMB_MEMMGR* pMgr, unsigned int size);
 134
 135	// Interfce: Realloc
 136	//		Reallocate a memory block
 137	// Parameters:
 138	//		pMgr		-	Pointer to the memory manager.
 139	//		pointer		-	An existing memory block, or NULL.
 140	//		new_size	-	New size (number of bytes) of the memory block. Can be zero.
 141	// Return value:
 142	//		The pointer of reallocated memory block, it could be a new block, or just
 143	//		the previous block with size modified.
 144	// Comments:
 145	//		If an existing memory block specified, the data in the memory block will
 146	//		be copied to the new block, if reallocated.
 147	//
 148	//		In order to handle OOM situation, application can use longjmp() inside 
 149	//		implementation of this function. If underlying memory manager fails to 
 150	//		allocate enough memory, then application can use longjmp() to jump to
 151	//		OOM handling codes.
 152	//
 153	void*	(*Realloc)(struct FPDFEMB_MEMMGR* pMgr, void* pointer, unsigned int new_size);
 154
 155	// Interface: Free
 156	//		Free a memory block
 157	// Parameters:
 158	//		pMgr		-	Pointer to the memory manager.
 159	//		pointer		-	An existing memory block.
 160	// Return Value:
 161	//		None.
 162	//
 163	void	(*Free)(struct FPDFEMB_MEMMGR* pMgr, void* pointer);
 164};
 165
 166// Function: FPDFEMB_Init
 167//			Initialize the FPDFEMB module
 168// Parameters:
 169//			mem_mgr		-	Pointer to memory manager structure
 170// Return Value:
 171//			Error code, or FPDFERR_SUCCESS for success.
 172// Comments:
 173//			This function will allocate necessary internal data structure for
 174//			the whole module to operate.
 175FPDFEMB_RESULT FPDFEMB_Init(FPDFEMB_MEMMGR* mem_mgr);
 176
 177typedef void (*FPDFEMB_FIXED_OOM_HANDLER)(void* memory, int size);
 178
 179// Function: FPDFEMB_InitFixedMemory
 180//			Initialize the FPDFEMB module, providing a fixed memory heap
 181// Parameters:
 182//			memory		-	Pointer to a pre-allocated memory block
 183//			size		-	Number of bytes in the memory block
 184//			oom_handler	-	Pointer to a function which will be called when OOM happens. Can be
 185//							NULL if application doesn't want to be notified om OOM.
 186// Return Value:
 187//			Error code, or FPDFERR_SUCCESS for success.
 188// Comments:
 189//			In many embedded system, memory usage are predetermined. The application
 190//			is assigned with fixed size of available memory, then it can pre-allocate
 191//			a memory block with maximum size and pass to this function to initialize
 192//			FPDFEMB module. In this case, FPDFEMB won't need any additional memory
 193//			allocation.
 194//
 195//			In case the pre-allocated memory has run out, the "oom_proc" callback
 196//			function will be called to notify the application that an OOM recovery
 197//			procedure needs to be performed.
 198//
 199FPDFEMB_RESULT FPDFEMB_InitFixedMemory(void* memory, int size, FPDFEMB_FIXED_OOM_HANDLER oom_handler);
 200
 201// Memory Management Flags
 202#define FPDFEMB_NONLEAVE		1
 203#define FPDFEMB_MOVABLE			2
 204#define FPDFEMB_DISCARDABLE		4
 205
 206// Structure: FPDFEMB_MEMMGR_EX
 207//			This is an extended version of memory manager interface, allowing advanced
 208//			memory management, including movable and discardable memory blocks.
 209//
 210//			Use this interface with FPDFEMB_InitExt function.
 211//
 212struct FPDFEMB_MEMMGR_EX {
 213	// Interface: Alloc
 214	//		Allocate a memory block
 215	// Parameters:
 216	//		pMgr		-	Pointer to the memory manager.
 217	//		size		-	Number of bytes for the memory block.
 218	//		flags		-	A combination of flags defined above.
 219	// Return Value:
 220	//		The pointer to allocated memory block. NULL if no memory available.
 221	//		If FPDFEMB_MOVABLE flag is used, implementation should return a handle
 222	//		to the memory block, if it supports movable block allocation.
 223	// Comments:
 224	//		The implementation should not do any action if no memory available,
 225	//		just return NULL. OOM handling can be done in OOM_Handler interface.
 226	//
 227	void*	(*Alloc)(struct FPDFEMB_MEMMGR_EX* pMgr, unsigned int size, int flags);
 228
 229	// Interface: OOM_Handler
 230	//		OOM (out-of-memory) situation handler
 231	// Parameters:
 232	//		pMgr		-	Pointer to the memory manager.
 233	// Return Value:
 234	//		None.
 235	// Comments:
 236	//		In order to handle OOM situation, application can use longjmp() inside 
 237	//		implementation of this function.
 238	//
 239	void	(*OOM_Handler)(struct FPDFEMB_MEMMGR_EX* pMgr);
 240
 241	// Interfce: Realloc
 242	//		Reallocate a memory block
 243	// Parameters:
 244	//		pMgr		-	Pointer to the memory manager.
 245	//		pointer		-	Pointer to an existing memory block, or handle to a movable
 246	//						block. Can not be NULL.
 247	//		new_size	-	New size (number of bytes) of the memory block. Can not be zero.
 248	// Return value:
 249	//		The pointer of reallocated memory block, it could be a new block, or just
 250	//		the previous block with size modified.
 251	//		If FPDFEMB_MOVABLE flag is used, implementation should return a handle
 252	//		to the memory block, if it supports movable block allocation.
 253	// Comments:
 254	//		If an existing memory block specified, the data in the memory block should
 255	//		be copied to the new block, if reallocated.
 256	//
 257	//		The implementation should not do any action if no memory available,
 258	//		just return NULL. OOM handling can be done in OOM_Handler interface.
 259	//
 260	void*	(*Realloc)(struct FPDFEMB_MEMMGR_EX* pMgr, void* pointer, unsigned int new_size, int flags);
 261
 262	// Interface: Lock
 263	//		Lock a movable memory block
 264	// Parameters:
 265	//		pMgr		-	Pointer to the memory manager.
 266	//		handle		-	Handle to movable memory block, returned by Alloc or Realloc.
 267	// Return Value:
 268	//		The pointer of the memory block. NULL if the block was discarded.
 269	// Comments:
 270	//		This interface is optional, if implementation doesn't support movable memory
 271	//		block, then this interface can be set to NULL.
 272	//
 273	void*	(*Lock)(struct FPDFEMB_MEMMGR_EX* pMgr, void* handle);
 274
 275	// Interface: Unlock
 276	//		Unlock a locked movable memory block
 277	// Parameters:
 278	//		pMgr		-	Pointer to the memory manager.
 279	//		handle		-	Handle to movable memory block, returned by Alloc or Realloc.
 280	// Return Value:
 281	//		None.
 282	// Comments:
 283	//		This interface is optional, if implementation doesn't support movable memory
 284	//		block, then this interface can be set to NULL.
 285	//
 286	void	(*Unlock)(struct FPDFEMB_MEMMGR_EX* pMgr, void* handle);
 287
 288	// Interface: Free
 289	//		Free a memory block
 290	// Parameters:
 291	//		pMgr		-	Pointer to the memory manager.
 292	//		pointer		-	Pointer to an existing memory block, or handle to a movable block.
 293	// Return Value:
 294	//		None.
 295	//
 296	void	(*Free)(struct FPDFEMB_MEMMGR_EX* pMgr, void* pointer, int flags);
 297
 298	void*	user;		// A user pointer, used by the application
 299};
 300
 301// Function: FPDFEMB_LoadJbig2Decoder
 302// Function: FPDFEMB_LoadJpeg2000Decoder
 303//			Enable JBIG2 or JPEG2000 image decoder 
 304// Parameters:
 305//			None.
 306// Return Value:
 307//			None.
 308// Comments:
 309//			If you want to display JBIG2 or JPEG2000 encoded images, you need to call 
 310//			these functions after FPDFEMB initialized.
 311//
 312//			Calling these functions will increase code size by about 200K-400K bytes.
 313//			Also JPEG2000 decoder may not be available on some platforms.
 314//
 315void FPDFEMB_LoadJbig2Decoder();
 316void FPDFEMB_LoadJpeg2000Decoder();
 317
 318// Function: FPDFEMB_InitEx
 319//			Initialize the FPDFEMB module with the extended memory manager
 320// Parameters:
 321//			mem_mgr		-	Pointer to memory manager structure
 322// Return Value:
 323//			Error code, or FPDFERR_SUCCESS for success.
 324// Comments:
 325//			This function will allocate necessary internal data structure for
 326//			the whole module to operate.
 327FPDFEMB_RESULT FPDFEMB_InitEx(FPDFEMB_MEMMGR_EX* mem_mgr);
 328
 329// Function: FPDFEMB_Exit
 330//			Stop using FPDFEMB module and release all resources
 331// Parameters:
 332//			None.
 333// Return Value:
 334//			None.
 335// Comments:
 336//			All loaded documents and pages will become invalid after this call.
 337//
 338//			This function is useful for OOM recovery: when your application hits
 339//			an OOM situation, calling this function will clear all memory allocated
 340//			by FPDFEMB module, then you can call one of the initialization functions,
 341//			reopen the document and recovery from OOM.
 342//
 343void FPDFEMB_Exit();
 344
 345// Function: FPDFEMB_AllocMemory
 346//			Allocate memory
 347// Parameters:
 348//			size		-	Number of bytes
 349// Return Value:
 350//			The allocated buffer pointer. NULL for out of memory.
 351//
 352void* FPDFEMB_AllocMemory(unsigned int size);
 353
 354// Function: FPDFEMB_FreeMemory
 355//			Free allocated memory
 356// Parameters:
 357//			pointer		-	Pointer returned by FPDFEMB_AllocMemory
 358// Return Value:
 359//			None.
 360//
 361void FPDFEMB_FreeMemory(void* pointer);
 362
 363// Function: FPDFEMB_FreeCaches
 364//			Free all expendable caches used by FPDFEMB in order to save memory
 365// Parameters:
 366//			None.
 367// Return Value:
 368//			None.
 369// Comments:
 370//			When an application memory manager runs out of memory, before an OOM situation 
 371//			is raised, the application can try this 
 372//
 373void FPDFEMB_FreeCaches();
 374
 375/********************************************************************************************
 376****
 377****		Document Operations
 378****
 379********************************************************************************************/
 380
 381// Structure: FPDFEMB_FILE_ACCESS
 382//		Describe the way to access a file (readonly).
 383struct FPDFEMB_FILE_ACCESS {
 384	// Inteface: GetSize
 385	//		Get total size of the file
 386	// Parameters:
 387	//		file		-	Pointer to this file access structure
 388	// Return Value:
 389	//		File size, in bytes. Implementation can return 0 for any error.
 390	// 
 391	unsigned int	(*GetSize)(struct FPDFEMB_FILE_ACCESS* file);
 392
 393	// Interface: ReadBlock
 394	//		Read a data block from the file
 395	// Parameters:
 396	//		file		-	Pointer to this file access structure
 397	//		buffer		-	Pointer to a buffer receiving read data
 398	//		offset		-	Byte offset for the block, from beginning of the file
 399	//		size		-	Number of bytes for the block.
 400	// Return Value:
 401	//		Error code, or FPDFERR_SUCCESS for success.
 402	//
 403	FPDFEMB_RESULT	(*ReadBlock)(struct FPDFEMB_FILE_ACCESS* file, void* buffer, 
 404									unsigned int offset, unsigned int size);
 405
 406	void*		user;		// A user pointer, used by the application
 407};
 408
 409// Structure: FPDFEMB_PAUSE
 410//			An interface for pausing a progressive process.
 411struct FPDFEMB_PAUSE {
 412	// Interface: NeedPauseNow
 413	//		Check if we need to pause a progressive proccess now
 414	// Parameters:
 415	//		pause		-	Pointer to the pause structure
 416	// Return Value:
 417	//		Non-zero for pause now, 0 for continue.
 418	// Comments:
 419	//		Typically implementation of this interface compares the current system tick
 420	//		with the previous one, if the time elapsed exceeds certain threshold, then
 421	//		the implementation returns TRUE, indicating a pause is needed.
 422	//
 423	FPDFEMB_BOOL (*NeedPauseNow)(struct FPDFEMB_PAUSE* pause);
 424
 425	void*		user;		// A user pointer, used by the application
 426};
 427
 428typedef void* FPDFEMB_DOCUMENT;
 429
 430// Function: FPDFEMB_StartLoadDocument
 431//			Start loading a PDF document
 432// Parameters:
 433//			file		-	Pointer to file access structure.
 434//							This structure must be kept valid as long as the document is open.
 435//			password	-	Pointer to a zero-terminated byte string, for the password.
 436//							Or NULL for no password.
 437//			document	-	Receiving the document handle
 438//			pause		-	A callback mechanism allowing the document loading process
 439//							to be paused before it's finished. This can be NULL if you
 440//							don't want to pause.
 441// Return Value:
 442//			FPDFERR_SUCCESS: document successfully loaded.
 443//			FPDFERR_TOBECONTINUED: The document loading can't be finished now.
 444//					See comments below.
 445//			FPDFERR_PASSWORD: incorrect password.
 446//			FPDFERR_FORMAT: not a PDF or corrupted PDF.
 447//			FPDFERR_FILE: file access error.
 448//			FPDFERR_MEMORY: out of memory.
 449// Comments:
 450//			Document loading is a progressive process. It might take a long time to
 451//			load a document, especiall when a file is corrupted, FPDFEMB will try to
 452//			recover the document contents by scanning the whole file. If "pause" parameter
 453//			is provided, this function may return FPDFERR_TOBECONTINUED any time during
 454//			the document loading.
 455//
 456//			When FPDFERR_TOBECONTINUED is returned, the "document" parameter will
 457//			still receive a valid document handle, however, no further operations can
 458//			be performed on the document, except the "FPDFEMB_ContineLoadDocument" function
 459//			call, which resume the document loading.
 460//
 461FPDFEMB_RESULT FPDFEMB_StartLoadDocument(FPDFEMB_FILE_ACCESS* file, const char* password, 
 462									FPDFEMB_DOCUMENT* document, FPDFEMB_PAUSE* pause);
 463
 464// Function: FPDFEMB_ContinueLoadDocument
 465//			Continue loading a PDF document
 466// Parameters:
 467//			document	-	Document handle returned by FPDFEMB_StartLoadDocument function
 468//			pause		-	A callback mechanism allowing the document loading process
 469//							to be paused before it's finished. This can be NULL if you
 470//							don't want to pause.
 471// Return Value:
 472//			FPDFERR_SUCCESS: document successfully loaded.
 473//			FPDFERR_TOBECONTINUED: The document loading can't be finished now.
 474//					Further call to this function is needed.
 475//			FPDFERR_PASSWORD: incorrect password.
 476//			FPDFERR_FORMAT: not a PDF or corrupted PDF.
 477//			FPDFERR_FILE: file access error.
 478//			FPDFERR_MEMORY: out of memory.
 479//			FPDFERR_STATUS: document already loaded.
 480//			FPDFERR_PARAM: invalid parameter (like NULL document handle)
 481//
 482FPDFEMB_RESULT FPDFEMB_ContinueLoadDocument(FPDFEMB_DOCUMENT document, FPDFEMB_PAUSE* pause);
 483
 484// Function: FPDFEMB_CloseDocument
 485//			Close a PDF document and free all associated resources
 486// Parameters:
 487//			document	-	Document handle
 488// Return Value:
 489//			Error code. FPDFERR_SUCCESS for success.
 490//
 491FPDFEMB_RESULT FPDFEMB_CloseDocument(FPDFEMB_DOCUMENT document);
 492
 493// Function: Get page count
 494//			Get number of pages in the document
 495// Parameters:
 496//			document	-	Document handle
 497// Return Value:
 498//			Number of pages.
 499//
 500int FPDFEMB_GetPageCount(FPDFEMB_DOCUMENT document);
 501
 502// Function: FPDFEMB_SetFileBufferSize
 503//			Set size of internal buffer used to read from source file.
 504// Parameters:
 505//			size		-	Number of bytes
 506// Return Value:
 507//			None.
 508// Comments:
 509//			Currently FPDFEMB uses 512 bytes as default buffer size. The new buffer size 
 510//			takes effect next time you call FPDFEMB_StartLoadDocument.
 511//
 512void FPDFEMB_SetFileBufferSize(int size);
 513
 514/********************************************************************************************
 515****
 516****		Page Basic Operations
 517****
 518********************************************************************************************/
 519
 520typedef void* FPDFEMB_PAGE;
 521
 522// Function: FPDFEMB_LoadPage
 523//			Load a page
 524// Parameters:
 525//			document	-	Document handle
 526//			index		-	Page index, starting from zero
 527//			page		-	Receiving the loaded page handler
 528// Return Value:
 529//			Error code, or FPDFERR_SUCCESS for success.
 530//
 531FPDFEMB_RESULT FPDFEMB_LoadPage(FPDFEMB_DOCUMENT document, int index, FPDFEMB_PAGE* page);
 532
 533// Function: FPDFEMB_ClosePage
 534//			Close a page and release all related resources
 535// Parameters:
 536//			page		-	Page handle
 537// Return Value:
 538//			Error code, or FPDFERR_SUCCESS for success.
 539//
 540FPDFEMB_RESULT FPDFEMB_ClosePage(FPDFEMB_PAGE page);
 541
 542// Function: FPDFEMB_GetPageSize
 543//			Get size of a page
 544// Parameters:
 545//			page		-	Page handle
 546//			width		-	Receiving page width, in hundredth of points
 547//			height		-	Receiving page height, in hundredth of points
 548// Return Value:
 549//			Error code, or FPDFERR_SUCCESS for success
 550//
 551FPDFEMB_RESULT FPDFEMB_GetPageSize(FPDFEMB_PAGE page, int* width, int* height);
 552
 553// Structure: FPDFEMB_RECT
 554//			Rectangle area in device or page coordination system
 555//
 556struct FPDFEMB_RECT
 557{
 558	// For device system, coordinations are measured in pixels;
 559	// For page system, coordinations are measured in hundredth of points.
 560	int		left;
 561	int		top;
 562	int		right;
 563	int		bottom;
 564};
 565
 566// Function: FPDFEMB_GetPageBBox
 567//			Get displayable area (bounding box) of a page
 568// Parameters:
 569//			page		-	Page handle
 570//			rect		-	Pointer to a structure receiving the rectangle
 571// Return Value:
 572//			Error code, or FPDFERR_SUCCESS for success
 573//
 574FPDFEMB_RESULT FPDFEMB_GetPageBBox(FPDFEMB_PAGE page, FPDFEMB_RECT* rect);
 575
 576/********************************************************************************************
 577****
 578****		Page Parsing
 579****
 580********************************************************************************************/
 581
 582// Function: FPDFEMB_StartParse
 583//			Start parsing a page, so it can get rendered or searched
 584// Parameters:
 585//			page		-	Page handle
 586//			text_only	-	flag for parsing texts only (used for searching)
 587//			pause		-	A structure that can pause the parsing process.
 588//							Or NULL if you don't want to pause the process.
 589// Return Value:
 590//			FPDFERR_SUCCESS: parsing successfully finished;
 591//			FPDFERR_TOBECONTINUED: parsing started successfully, but not finished;
 592//			FPDFERR_STATUS: page already parsed, or parsing already started. 
 593//			Other return value: error code.
 594// Comments:
 595//			Parsing is a progressive process. This function starts the parsing process,
 596//			and may return before parsing is finished, if a pause structure is provided.
 597//
 598//			Application should call FPDFEMB_ContinueParse repeatedly to finish the parsing
 599//			when return value is FPDFERR_TOBECONTINUED.
 600//
 601//			There can be only one parsing procedure active for a page, and if a page
 602//			has already been parsed, you can't start a parsing again.
 603//
 604FPDFEMB_RESULT FPDFEMB_StartParse(FPDFEMB_PAGE page, FPDFEMB_BOOL text_only, 
 605												FPDFEMB_PAUSE* pause);
 606
 607// Function: FPDFEMB_ContinueParse
 608//			Continue the page parsing
 609// Parameters:
 610//			page		-	Page handle
 611//			pause		-	A structure that can pause the parsing process.
 612//							Or NULL if you don't want to pause the process.
 613// Return Value:
 614//			FPDFERR_SUCCESS: parsing successfully finished;
 615//			FPDFERR_TOBECONTINUED: parsing performed successfully, but not finished;
 616//			FPDFERR_STATUS: page already parsed (or parsing not started). 
 617//			Other return value: error code.
 618// Comments:
 619//			FPDFEMB_StartParse should be called before on the page.
 620//
 621//			Application should call FPDFEMB_ContinueParse repeatedly to finish the parsing
 622//			when return value is FPDFERR_TOBECONTINUED.
 623//
 624FPDFEMB_RESULT FPDFEMB_ContinueParse(FPDFEMB_PAGE page, FPDFEMB_PAUSE* pause);
 625
 626// Function: FPDFEMB_GetParseProgress
 627//			Get an estimated parsing progress in percentage
 628// Parameters:
 629//			page		-	Page handle
 630// Return Value:
 631//			An integer between 0 and 100 (inclusive) indicating the parsing progress.
 632//			The result is just a rough estimation.
 633//
 634int FPDFEMB_GetParseProgress(FPDFEMB_PAGE page);
 635
 636/********************************************************************************************
 637****
 638****		Page Rendering
 639****
 640********************************************************************************************/
 641
 642typedef void* FPDFEMB_BITMAP;
 643
 644// Function: FPDFEMB_StartQuickDraw
 645//			Start drawing a quick preview of a page
 646// Parameters:
 647//			dib			-	DIB handle, as the rendering device
 648//			page		-	Page handle. The page has to be parsed first.
 649//			start_x		-	Left pixel position of the display area in the device coordination
 650//			start_y		-	Top pixel position of the display area in the device coordination
 651//			size_x		-	Horizontal size (in pixels) for displaying the page
 652//			size_y		-	Vertical size (in pixels) for displaying the page
 653//			rotate		-	Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 654//								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 655//			flags		-	Reserved, must be zero.
 656//			pause		-	Pointer to a structure that can pause the rendering process.
 657//							Can be NULL if no pausing is needed.
 658// Return Value:
 659//			FPDFERR_SUCCESS: quickdraw successly finished;
 660//			FPDFERR_TOBECONTINUED: quickdraw started successfully, but not finished.
 661//							FPDFEMB_ContinueQuickDraw needs to be called to finish the quickdraw;
 662//			FPDFERR_STATUS: quickdraw already in progress, or page not parsed;
 663//			Other return value: error code.
 664// Comments:
 665//			It's often useful to present user a quick preview of a page, right after the
 666//			page is parsed. This preview renders only a limited set of easy features in the
 667//			page, so it'll be rather quick to finish this process.
 668//
 669FPDFEMB_RESULT FPDFEMB_StartQuickDraw(FPDFEMB_BITMAP dib, FPDFEMB_PAGE page,
 670							int start_x, int start_y, int size_x, int size_y, int rotate,
 671							int flags, FPDFEMB_PAUSE* pause);
 672
 673// Function: FPDFEMB_ContinueQuickDraw
 674//			Continue a quick draw processing
 675// Parameters:
 676//			page		-	Page handle. The page has to be parsed first.
 677//			pause		-	Pointer to a structure that can pause the rendering process.
 678//							Can be NULL if no pausing is needed.
 679// Return Value:
 680//			FPDFERR_SUCCESS: quickdraw successly finished;
 681//			FPDFERR_TOBECONTINUED: quickdraw started successfully, but not finished.
 682//							more calls to this function needed to finish the quickdraw;
 683//			FPDFERR_STATUS: quickdraw not started yet; 
 684//			Other return value: error code.
 685//
 686FPDFEMB_RESULT FPDFEMB_ContinueQuickDraw(FPDFEMB_PAGE page, FPDFEMB_PAUSE* pause);
 687
 688#define FPDFEMB_ANNOT			0x01		// Set if annotations are to be rendered
 689#define FPDFEMB_LCD_TEXT		0x02		// Set if using text rendering optimized for LCD display
 690#define FPDFEMB_BGR_STRIPE		0x04		// Set if the device is using BGR LCD stripe
 691
 692// Function: FPDFEMB_StartRender
 693//			Start rendering of a page.
 694// Parameter:
 695//			dib			-	DIB handle, as the rendering device
 696//			page		-	Page handle. The page has to be parsed first.
 697//			start_x		-	Left pixel position of the display area in the device coordination
 698//			start_y		-	Top pixel position of the display area in the device coordination
 699//			size_x		-	Horizontal size (in pixels) for displaying the page
 700//			size_y		-	Vertical size (in pixels) for displaying the page
 701//			rotate		-	Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 702//								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 703//			flags		-	0 for normal display, or combination of flags defined above
 704//			clip		-	Pointer to clip rectangle (in DIB device coordinations),
 705//							or NULL if no clipping needed.
 706//			pause		-	Pointer to a structure that can pause the rendering process.
 707//							Can be NULL if no pausing is needed.
 708// Return Value:
 709//			FPDFERR_SUCCESS: rendering successfully finished;
 710//			FPDFERR_TOBECONTINUED: rendering started successfully, but not finished;
 711//			Other return value: error code.
 712// Comments:
 713//			Rendering is a progressive process. This function starts the rendering process,
 714//			and may return before rendering is finished, if a pause structure is provided.
 715//
 716//			Application should call FPDFEMB_ContinueRender repeatedly to finish the rendering 
 717//			when return value is FPDFERR_TOBECONTINUED.
 718//
 719//			There can be only one rendering procedure for a page at any time. And rendering
 720//			can be started over and over again for the same page. If a page rendering is already
 721//			active, starting another one will cancel the previous rendering.
 722//
 723//			Rendering of a page doesn't draw the page background, therefore, you usually need
 724//			to draw the background in the DIB yourself.
 725//
 726FPDFEMB_RESULT FPDFEMB_StartRender(FPDFEMB_BITMAP dib, FPDFEMB_PAGE page,
 727						int start_x, int start_y, int size_x, int size_y, int rotate, int flags,
 728						FPDFEMB_RECT* clip, FPDFEMB_PAUSE* pause);
 729
 730// Function: FPDFEMB_ContinueRender
 731//			Continue the page rendering
 732// Parameters:
 733//			page		-	Page handle
 734//			pause		-	Pointer to a structure that can pause the rendering process.
 735//							Can be NULL if no pausing is needed.
 736// Return Value:
 737//			FPDFERR_SUCCESS: rendering successfully finished.
 738//			FPDFERR_TOBECONTINUED: rendering needs to be continued;
 739//			Other return value: error code.
 740// Comments:
 741//			This function may return any time when the pause interface indicates 
 742//			a pause is needed. Application can call FPDFEMB_ContinueRender any number
 743//			of times, until FPDFERR_TOBECONTINUED is not returned.
 744//
 745FPDFEMB_RESULT FPDFEMB_ContinueRender(FPDFEMB_PAGE page, FPDFEMB_PAUSE* pause);
 746
 747// Function: FPDFEMB_GetRenderProgress
 748//			Get an estimated rendering progress in percentage
 749// Parameters:
 750//			page		-	Page handle
 751// Return Value:
 752//			An integer between 0 and 100 (inclusive) indicating the rendering progress.
 753//			The result is just a rough estimation.
 754//			If the rendering just finished, this function will return 0.
 755//
 756int FPDFEMB_GetRenderProgress(FPDFEMB_PAGE page);
 757
 758// Function: FPDFEMB_SetHalftoneLimit
 759//			Set pixel count limit for using halftone when display image
 760// Parameter:
 761//			limit		-	Number of pixels for the limit
 762// Return Value:
 763//			None.
 764// Comments:
 765//			By default, FPDFEMB displays all bitmaps using downsamping, which means
 766//			if the image is shrinked onto screen, only part of pixels will be picked
 767//			and displayed. This saves a lot of calculation, especially for big images
 768//			with millions of pixels. However the display quality can be bad. In order to
 769//			reach a balance between performance and quality, application can use this
 770//			function to set a limit, if number of pixels in an image is more than this
 771//			limit, then FPDFEMB will use downsampling for quick drawing, otherwise, if
 772//			the image has less pixels, FPDFEMB will use halftoning for better quality.
 773//
 774void FPDFEMB_SetHalftoneLimit(int limit);
 775
 776/********************************************************************************************
 777****
 778****		Coordination Conversion
 779****
 780********************************************************************************************/
 781
 782// Structure: FPDFEMB_POINT
 783//			A point in device or page coordination system
 784//
 785struct FPDFEMB_POINT
 786{
 787	// For device system, coordinations are measured in pixels;
 788	// For page system, coordinations are measured hundredth of points.
 789	int		x;
 790	int		y;
 791};
 792
 793// Function: FPDFEMB_DeviceToPagePoint, FPDFEMB_DeviceToPageRect
 794//			Convert the device coordinations of a point or a rectangle to page coordinations.
 795// Parameters:
 796//			page		-	Handle to the page. Returned by FPDFEMB_LoadPage function.
 797//			start_x		-	Left pixel position of the display area in the device coordination
 798//			start_y		-	Top pixel position of the display area in the device coordination
 799//			size_x		-	Horizontal size (in pixels) for displaying the page
 800//			size_y		-	Vertical size (in pixels) for displaying the page
 801//			rotate		-	Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 802//								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 803//			point		-	A point structure with device coordinations upon the call,
 804//							also receiving the result page coordinations.
 805//			rect		-	A rectangle structure with device coordinations upon the call,
 806//							also receiving the result page coordinations.
 807// Return value:
 808//			None.
 809// Comments:
 810//			The page coordination system has its origin at left-bottom corner of the page, 
 811//			with X axis goes along the bottom side to the right, and Y axis goes along the 
 812//			left side upward. No matter how you zoom, scroll, or rotate a page, a particular
 813//			element (like text or image) on the page should always have the same coordination 
 814//			values in the page coordination system. 
 815//
 816//			The device coordination system is device dependant. For bitmap device, its origin 
 817//			is at left-top corner of the window. You must make sure the start_x, start_y, size_x, 
 818//			size_y and rotate parameters have exactly same values as you used in 
 819//			FPDFEMB_StartRender() function call.
 820//
 821//			For rectangle conversion, the result rectangle is always "normalized", meaning for
 822//			page coordinations, left is always smaller than right, bottom is smaller than top.
 823//
 824void FPDFEMB_DeviceToPagePoint(FPDFEMB_PAGE page, 
 825						int start_x, int start_y, int size_x, int size_y, int rotate, 
 826						FPDFEMB_POINT* point);
 827
 828void FPDFEMB_DeviceToPageRect(FPDFEMB_PAGE page, 
 829						int start_x, int start_y, int size_x, int size_y, int rotate, 
 830						FPDFEMB_RECT* rect);
 831
 832// Function: FPDFEMB_PageToDevicePoint, FPDFEMB_PageToDeviceRect
 833//			Convert the page coordinations of a point or a rectangle to device coordinations.
 834// Parameters:
 835//			page		-	Handle to the page. Returned by FPDFEMB_LoadPage function.
 836//			start_x		-	Left pixel position of the display area in the device coordination
 837//			start_y		-	Top pixel position of the display area in the device coordination
 838//			size_x		-	Horizontal size (in pixels) for displaying the page
 839//			size_y		-	Vertical size (in pixels) for displaying the page
 840//			rotate		-	Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
 841//								2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
 842//			point		-	A point structure with page coordinations upon the call,
 843//							also receiving the result device coordinations.
 844//			rect		-	A rectangle structure with page coordinations upon the call,
 845//							also receiving the result device coordinations.
 846// Return value:
 847//			None
 848// Comments:
 849//			For rectangle conversion, the result rectangle is always "normalized", meaning for
 850//			device coordinations, left is always smaller than right, top is smaller than bottom.
 851//
 852void FPDFEMB_PageToDevicePoint(FPDFEMB_PAGE page, 
 853						int start_x, int start_y, int size_x, int size_y, int rotate, 
 854						FPDFEMB_POINT* point);
 855
 856void FPDFEMB_PageToDeviceRect(FPDFEMB_PAGE page, 
 857						int start_x, int start_y, int size_x, int size_y, int rotate, 
 858						FPDFEMB_RECT* rect);
 859
 860/********************************************************************************************
 861****
 862****		Text Search
 863****
 864********************************************************************************************/
 865
 866// Search flags for FPDFEMB_FindFirst function
 867#define FPDFEMB_MATCHCASE		1		// whether matching case
 868#define FPDFEMB_MATCHWHOLEWORD	2		// whether matching whole word
 869#define FPDFEMB_CONSECUTIVE		4		// whether matching consecutively (for example, "CC" will
 870										// match twice in "CCC").
 871
 872// Function: FPDFEMB_FindFirst
 873//			Find first occurance of a pattern string in a page
 874// Parameters:
 875//			page		-	Page handle.
 876//			pattern		-	A zero-terminated unicode string to be found. 
 877//			from_last	-	Whether we start from the end of page
 878//			flags		-	Search flags, see above defined constants
 879// Return Value:
 880//			Error code, or FPDFERR_SUCCESS for success.
 881//			Is not found, FPDFERR_NOTFOUND is returned.
 882// Comments:
 883//			A page must be parsed first before it can be searched.
 884//			There can be only one search in progress for a page. A new search will 
 885//			cancel the previous one.
 886//
 887//			IMPORTANT: this function is now obsolete and kept for back compatibility
 888//			only, please use FPDFEMB_FindFrom function below.
 889//
 890FPDFEMB_RESULT FPDFEMB_FindFirst(FPDFEMB_PAGE page, const FPDFEMB_WCHAR* pattern, 
 891								 FPDFEMB_BOOL from_last, unsigned int flags);
 892
 893// Function: FPDFEMB_FindFrom
 894//			Find first occurance of a pattern string in a page, from a particular position
 895// Parameters:
 896//			page		-	Page handle.
 897//			pattern		-	A zero-terminated unicode string to be found. 
 898//			pos			-	The position, returned from FPDFEMB_GetSearchPos.
 899//							Or 0 from the beginning of page, -1 from the end of page.
 900//			flags		-	Search flags, see above defined constants
 901// Return Value:
 902//			Error code, or FPDFERR_SUCCESS for success.
 903//			Is not found, FPDFERR_NOTFOUND is returned.
 904// Comments:
 905//			A page must be parsed first before it can be searched.
 906//			There can be only one search in progress for a page. A new search will 
 907//			cancel the previous one.
 908//
 909FPDFEMB_RESULT FPDFEMB_FindFrom(FPDFEMB_PAGE page, const FPDFEMB_WCHAR* pattern, 
 910								 int pos, unsigned int flags);
 911
 912// Function: FPDFEMB_FindNext
 913//			Find next occurance of a search
 914// Parameters:
 915//			page		-	Page handle. 
 916//							FPDFEMB_FindFirst must be called for this page first.
 917// Return Value:
 918//			Error code, or FPDFERR_SUCCESS for success.
 919//			Is not found, FPDFERR_NOTFOUND is returned.
 920//
 921FPDFEMB_RESULT FPDFEMB_FindNext(FPDFEMB_PAGE page);
 922
 923// Function: FPDFEMB_FindPrev
 924//			Find previous occurance of a search
 925// Parameters:
 926//			page		-	Page handle.
 927//							FPDFEMB_FindFirst must be called for this page first.
 928// Return Value:
 929//			Error code, or FPDFERR_SUCCESS for success.
 930//			Is not found, FPDFERR_NOTFOUND is returned.
 931//
 932FPDFEMB_RESULT FPDFEMB_FindPrev(FPDFEMB_PAGE page);
 933
 934// Function: FPDFEMB_CountFoundRects
 935//			Get number of rectangles for last found result
 936// Parameters:
 937//			page		-	Page handle.
 938// Return Value:
 939//			Number of rectangles for last found result. 0 for not found or failure.
 940//
 941int FPDFEMB_CountFoundRects(FPDFEMB_PAGE page);
 942
 943// Function: FPDFEMB_GetFoundRect
 944//			Get a particular found rectangle
 945// Parameters:
 946//			page		-	Page handle.
 947//			index		-	Zero-based index for the rectangle.
 948//			rect		-	Receiving the result rectangle, in hundredth of points
 949// Return Value:
 950//			Error code, or FPDFERR_SUCCESS for success.
 951// Comments:
 952//			Application should always call FPDFEMB_CountFoundRects first to get
 953//			number of rectangles, then use this function to get each rectangle.
 954//
 955//			The returned rectangle uses page coordination system.
 956//
 957FPDFEMB_RESULT FPDFEMB_GetFoundRect(FPDFEMB_PAGE page, int index, FPDFEMB_RECT* rect);
 958
 959// Function: FPDFEMB_GetSearchPos
 960//			Return position of current search result
 961// Parameters:
 962//			page		-	Page handle.
 963// Return Value:
 964//			Zero based character index for the current search result. -1 if not found.
 965//
 966int FPDFEMB_GetSearchPos(FPDFEMB_PAGE page);
 967
 968// Function: FPDFEMB_QuickSearch
 969//			Search a pattern in a page quickly, without the page to be parsed
 970// Parameters:
 971//			document	-	Document handle returned by FPDFEMB_StartLoadDocument function
 972//			page_index	-	Zero-based index of the page
 973//			pattern		-	A zero-terminated unicode string to be found. 
 974//			case_sensitive	-	Non-zero for case-sensitive searching, zero for case-insensitive
 975// Return Value:
 976//			FPDFERR_SUCCESS if pattern found, FPDFERR_NOTFOUND if pattern not found.
 977//			Otherwise error code is returned.
 978// Comments:
 979//			This function does a rough and quick search in a page, before the page is loaded. 
 980//			The quick search will not generate an exact result saying where the pattern is
 981//			found, and, it might be possible if a quick search result is "pattern found", and
 982//			a real search for the same pattern, in the same page, will result in "not found".
 983//
 984//			However, if quick search doesn't find a pattern in a page, then we can be sure the
 985//			pattern won't be found in this page when we do a real search. So, this function is 
 986//			very useful when we search in a multiple-page document, and we want to quickly skip
 987//			those pages in which the pattern can't possibly be found.
 988//
 989FPDFEMB_RESULT FPDFEMB_QuickSearch(FPDFEMB_DOCUMENT document, int page_index, 
 990								   const FPDFEMB_WCHAR* pattern, int case_sensitive);
 991
 992/********************************************************************************************
 993****
 994****		Text Information
 995****
 996********************************************************************************************/
 997
 998// Function: FPDFEMB_GetCharCount
 999//			Get number of characters in the page
1000// Parameters:
1001//			page		-	Page handle
1002//			count		-	Receiving number of characters
1003// Return Value:
1004//			Error code, or FPDFERR_SUCCESS for success.
1005//
1006FPDFEMB_RESULT FPDFEMB_GetCharCount(FPDFEMB_PAGE page, int* count);
1007
1008// Structure: FPDFEMB_CHAR_INFO
1009//			Character information.
1010struct FPDFEMB_CHAR_INFO {
1011	int		unicode;		// Unicode for the character. 0 if not available.
1012							// Space and new line charcters (U+0020 and U+000A) may be generated
1013							// according to the text formatting.
1014	FPDFEMB_POINT	origin;	// X/Y position for the character origin, in hundredth of points
1015	FPDFEMB_RECT	bbox;	// Bounding box of the character, in hundredth of points
1016							// Maybe an empty box (left == right or top == bottom).
1017};
1018
1019// Function: FPDFEMB_GetCharInfo
1020//			Get character information
1021// Parameters:
1022//			page		-	Page handle
1023//			index		-	Character index, starting from zero
1024//			char_info	-	Receiving the character info
1025// Return Value:
1026//			Error code, or FPDFERR_SUCCESS for success
1027// Comments:
1028//			Application must call FPDFEMB_GetCharCount first before it can call this function
1029//			for any particular characters.
1030//			
1031FPDFEMB_RESULT FPDFEMB_GetCharInfo(FPDFEMB_PAGE page, int index, FPDFEMB_CHAR_INFO* char_info);
1032
1033// Function: FPDFEMB_GetCharIndexAtPos()
1034//			Get index of character nearest to a certain position on the page
1035// Parameters:
1036//			page		-	Page handle
1037//			x			-	X position in PDF page coordination system
1038//			y			-	Y position in PDF page coordination system
1039//			index		-	Pointer to an integer receiving zero-based character index.
1040// Return Value:
1041//			Error code, or FPDFERR_SUCCESS for success
1042// Comments:
1043//			This function finds the character that's nearest to the particular page position.
1044//			If there is no character, the output index will be -1.
1045//			
1046FPDFEMB_RESULT FPDFEMB_GetCharIndexAtPos(FPDFEMB_PAGE page, double x, double y, int* index);
1047
1048/********************************************************************************************
1049****
1050****		Device Independant Bitmap
1051****
1052********************************************************************************************/
1053
1054#define FPDFDIB_BGR		1	// 3 bytes per pixel, byte order: Blue, Green, Red
1055#define FPDFDIB_BGRx	2	// 4 bytes per pixel, byte order: Blue, Green, Red, not used
1056#define FPDFDIB_BGRA	3	// 4 bytes per pixel, byte order: Blue, Green, Red, Alpha
1057#define FPDFDIB_GRAY	4	// 1 byte per pixel (grayscale)
1058
1059// Function: FPDFEMB_CreateDIB
1060//			Create a DIB (Device Independant Bitmap)
1061// Parameters:
1062//			width		-	Width pixels;
1063//			height		-	Height pixels;
1064//			format		-	Format type. See FPDFDIB_xxx constants
1065//			buffer		-	External buffer provided for the DIB,
1066//							or NULL if new buffer is to be allocated.
1067//			stride		-	Number of bytes for each scan line, for external buffer only.
1068//							If not specified, 4-byte alignment assumed.
1069//			dib			-	Receiving the created DIB handle
1070// Return Value:
1071//			Error code, or FPDFERR_SUCCESS for success
1072// Comments:
1073//			If "buffer" parameter is not NULL, then the provided buffer must conform
1074//			to standard DIB format (see comments of FPDFEMB_GetDIBData function below).
1075//
1076//			This function doesn't initialize the pixels inside the DIB buffer. So if you
1077//			want to use the DIB to display a PDF page, you usually need to initialize
1078//			the DIB to white background by youself.
1079//
1080FPDFEMB_RESULT FPDFEMB_CreateDIB(int width, int height, int format, 
1081									   void* buffer, int stride, FPDFEMB_BITMAP* dib);
1082
1083// Function: FPDFEMB_DestroyDIB
1084//			Destroy a DIB
1085// Parameters:
1086//			dib			-	DIB handle
1087// Return Value:
1088//			Error code, or FPDFERR_SUCCESS for success
1089// Comments:
1090//			If external buffer is used (specified in "buffer" parameter when calling
1091//			FPDFEMB_CreateDIB), the buffer will not be destroyed.
1092//
1093FPDFEMB_RESULT FPDFEMB_DestroyDIB(FPDFEMB_BITMAP dib);
1094
1095// Function: FPDFEMB_GetDIBWidth
1096//			Get width (in pixels) of a DIB
1097// Parameters:
1098//			dib			-	DIB handle
1099// Return Value:
1100//			DIB width in pixels.
1101//
1102int FPDFEMB_GetDIBWidth(FPDFEMB_BITMAP dib);
1103
1104// Function: FPDFEMB_GetDIBHeight
1105//			Get height (in pixels) of a DIB
1106// Parameters:
1107//			dib			-	DIB handle
1108// Return Value:
1109//			DIB height in pixels.
1110//
1111int FPDFEMB_GetDIBHeight(FPDFEMB_BITMAP dib);
1112
1113// Function: FPDFEMB_GetDIBData
1114//			Get data pointer to a DIB
1115// Parameters:
1116//			dib			-	DIB handle
1117// Return Value:
1118//			Pointer to the DIB data.
1119// Comments:
1120//			DIB data are organized in scanlines, from top down.
1121//
1122void* FPDFEMB_GetDIBData(FPDFEMB_BITMAP dib);
1123
1124// Function: FPDFEMB_GetDIBStride
1125//			Get scan line stride of a DIB
1126// Parameters:
1127//			dib			-	DIB handle
1128// Return Value:
1129//			Number of bytes occupied by a scanline
1130//
1131int FPDFEMB_GetDIBStride(FPDFEMB_BITMAP dib);
1132
1133// Function: FPDFEMB_GetRotatedDIB
1134//			Swap X/Y dimensions of a DIB to generate a rotated new DIB
1135// Parameters:
1136//			dib			-	DIB handle
1137//			flip_x		-	Whether flip pixels on the destination X dimension (left/right)
1138//			flip_y		-	Whether flip pixels on the destination Y dimension (up/down)
1139//			result_dib	-	Receiving the result DIB handle
1140// Return Value:
1141//			Error code, or FPDFERR_SUCCESS for success
1142//
1143FPDFEMB_RESULT FPDFEMB_GetRotatedDIB(FPDFEMB_BITMAP dib, 
1144									 FPDFEMB_BOOL bFlipX, FPDFEMB_BOOL bFlipY,
1145									 FPDFEMB_BITMAP* result_dib);
1146
1147// Function: FPDFEMB_StretchDIB
1148//			Stretch a source DIB into another destination DIB
1149// Parameters:
1150//			dest_dib	-	The destination DIB handle
1151//			dest_left	-	Left position in the destination DIB
1152//			dest_top	-	Top position in the destination DIB
1153//			dest_width	-	Destination width, in pixels. Can be negative for horizontal flipping
1154//			dest_height	-	Destination height, in pixels. Can be negative for vertical flipping
1155//			clip		-	Destination clipping rectangle, or NULL for no clipping.
1156//							The coordinations are measured in destination bitmap.
1157//			src_dib		-	Source DIB handle.
1158//			interpol	-	Whether we use interpolation to improve the result quality
1159// Return Value:
1160//			Error code, or FPDFERR_SUCCESS for success
1161//
1162FPDFEMB_RESULT FPDFEMB_StretchDIB(FPDFEMB_BITMAP dest_dib, int dest_left, int dest_top,
1163								  int dest_width, int dest_height, FPDFEMB_RECT* clip_rect, 
1164								  FPDFEMB_BITMAP src_dib, FPDFEMB_BOOL interpol);
1165
1166// Function: FPDFEMB_TransformDIB
1167//			Transform a source DIB into another destination DIB
1168// Parameters:
1169//			dest_dib	-	The destination DIB handle
1170//			clip		-	Destination clipping rectangle, or NULL for no clipping.
1171//							The coordinations are measured in destination bitmap.
1172//			src_dib		-	Source DIB handle.
1173//			x			-	X coordination of the dest origin
1174//			y			-	Y coordination of the dest origin
1175//			xx			-	X distance of the dest X vector
1176//			yx			-	Y distance of the dest X vector
1177//			xy			-	X distance of the dest Y vector
1178//			yy			-	Y distance of the dest Y vector
1179//			interpol	-	Whether we use interpolation to improve the result quality
1180// Return Value:
1181//			Error code, or FPDFERR_SUCCESS for success
1182// Comments:
1183//			All coordinations and distances are measured in destination bitmap system.
1184//
1185//			This function places the bottom-left pixel of the image at the destination
1186//			origin, then the bottom sideline along the destination X vector, and left 
1187//			sideline along the destination Y vector.
1188//			
1189FPDFEMB_RESULT FPDFEMB_TransformDIB(FPDFEMB_BITMAP dest_dib, FPDFEMB_RECT* clip_rect, 
1190								  FPDFEMB_BITMAP src_dib, int x, int y, int xx, int yx,
1191								  int xy, int yy, FPDFEMB_BOOL interpol);
1192
1193/********************************************************************************************
1194****
1195****		Custom Font Handler and CJK Support
1196****
1197********************************************************************************************/
1198
1199// FPDFEMB comes with standard fonts for Latin characters. If your device is targeted to
1200// Eastern Asian markets, then system fonts must be provided and registered with FPDFEMB.
1201// Depending on your device configuration, those system fonts might be in TrueType or Type1
1202// format, or some other non-standard compact format. For the first case, you should register
1203// a font mapper so FPDFEMB can pick the right font file, and for the second case, you
1204// should register a glyph provider so FPDFEMB can get glyph bitmap for each character.
1205
1206#define FPDFEMB_CHARSET_DEFAULT		0
1207#define FPDFEMB_CHARSET_GB			936
1208#define FPDFEMB_CHARSET_BIG5		950
1209#define FPDFEMB_CHARSET_JIS			932
1210#define FPDFEMB_CHARSET_KOREA		949
1211#define FPDFEMB_CHARSET_UNICODE		1200
1212
1213#define FPDFEMB_FONT_FIXEDPITCH		1
1214#define FPDFEMB_FONT_SERIF			2
1215#define FPDFEMB_FONT_SYMBOLIC		4
1216#define FPDFEMB_FONT_SCRIPT			8
1217#define FPDFEMB_FONT_NONSYMBOLIC	32
1218#define FPDFEMB_FONT_ITALIC			64
1219#define FPDFEMB_FONT_ALLCAP			0x10000
1220#define FPDFEMB_FONT_SMALLCAP		0x20000
1221#define FPDFEMB_FONT_FORCEBOLD		0x40000
1222
1223// Structure: FPDFEMB_FONT_MAPPER
1224//			Defines interface for system font mapper.
1225//
1226struct FPDFEMB_FONT_MAPPER
1227{
1228	// Interface: MapFont
1229	//		Find font file path for a particular PDF font
1230	// Parameters:
1231	//		mapper		-	Pointer to the FPDFEMB_FONT_MAPPER structure
1232	//		name		-	Font name
1233	//		charset		-	Charset ID (see above FPDFEMB_CHARSET_xxx constants)
1234	//		flags		-	Font flags (see above FPDFEMB_FONT_xxx constants)
1235	//		weight		-	Weight of the font. Range from 100 to 900. 400 is normal,
1236	//						700 is bold.
1237	//		path		-	Receiving the full file path. The buffer size is 512 bytes.
1238	//		face_index	-	Receiving an zero-based index value for the font face, if the 
1239	//						mapped font file is a "collection" (meaning a number of faces 
1240	//						are stored in the same file).

Large files files are truncated, but you can click here to view the full file