⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fpdfview.h

📁 Foxit Reader DLL开发的示例软件。可以很方便地实现自己的pdf viewer.
💻 H
📖 第 1 页 / 共 3 页
字号:
// FPDFVIEW.H - Header file for FPDFVIEW component
// Copyright (c) 2004-2006 Foxit Software Company, All Right Reserved.

// Revision: 1.8
// Date: 2007-02-07

#ifndef _FPDFVIEW_H_
#define _FPDFVIEW_H_

#if defined(_WIN32) && !defined(__WINDOWS__)
#include <windows.h>
#endif

// Data types
typedef void* FPDF_DOCUMENT;
typedef void* FPDF_PAGE;
typedef void* FPDF_BITMAP;

// String types
// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE encoded), and platform dependant string
typedef const char* FPDF_BYTESTRING;

typedef const unsigned short* FPDF_WIDESTRING;		// Foxit PDF SDK always use UTF-16LE encoding wide string,
													// each character use 2 bytes (except surrogation), with low byte first.

// For Windows programmers: for most case it's OK to treat FPDF_WIDESTRING as Windows unicode string,
//		 however, special care needs to be taken if you expect to process Unicode larger than 0xffff.
// For Linux/Unix programmers: most compiler/library environment uses 4 bytes for a Unicode character,
//		you have to convert between FPDF_WIDESTRING and system wide string by yourself.

#ifdef _WIN32_WCE
typedef const unsigned short* FPDF_STRING;
#else
typedef const char* FPDF_STRING;
#endif

#ifdef _WIN32
// On Windows system, functions are exported in a DLL
#define DLLEXPORT __declspec( dllexport )
#define STDCALL __stdcall
#else
#define DLLEXPORT
#define STDCALL
#endif

// Exported Functions
#ifdef __cplusplus
extern "C" {
#endif

// Function: FPDF_InitLibrary
//			Initialize the FPDFVIEW library (for static library distribution only)
// Parameters:
//			hInstance	-	For WIN32 system only: the instance of the executable or DLL module
// Return value:
//			None
// Comments:
//			If you are using static library version of FPDFVIEW, then you have to call this function
//			before you can call any PDF processing functions.
//			For DLL version this function does not present, because the library is automatically
//			initialized when DLL is loaded.
void FPDF_InitLibrary(void* hInstance);

// Function: FPDF_DestroyLibary
//			Release all resources allocated by the FPDFVIEW library (for static library distribution only)
// Parameters:
//			None
// Return value:
//			None
// Comments:
//			If you are using static library version of FPDFVIEW, then you can call this function
//			to release all memory blocks allocated by the library. After this function called, you
//			should not call any PDF processing functions.
//			For DLL version this function does not present, because the library is automatically
//			destroyed when DLL is unloaded.
void FPDF_DestroyLibrary();

// Function: FPDF_UnlockDLL
//			Unlock the DLL using license key info received from Foxit
// Parameters: 
//			license_id	-	A string received from Foxit identifying the SDK license
//			unlock_code	-	A string received from Foxit for unlocking the DLL
// Return value:
//			None
// Comments:
//			For SDK evaluators, this function call is not required, then all
//			rendered pages will come with an evaluation mark.
//			For purchased SDK customers, this should be the first function
//			to call before any other functions to be called.
//
DLLEXPORT void STDCALL FPDF_UnlockDLL(const char* license_id, const char* unlock_code);

// Function: FPDF_LoadDocument
//			Open and load a PDF document.
// Parameters: 
//			file_path	-	Path to the PDF file (including extension)
//			password	-	A string used as the password for PDF file. 
//							If no password needed, empty or NULL can be used.
// Return value:
//			A handle to the loaded document. If failed, NULL is returned.
// Comments:
//			Loaded document can be closed by FPDF_CloseDocument.
//			If this function fails, you can use FPDF_GetLastError() to retrieve
//			the reason why it fails.
//
DLLEXPORT FPDF_DOCUMENT	STDCALL FPDF_LoadDocument(FPDF_STRING file_path, 
												  FPDF_BYTESTRING password);

// Function: FPDF_LoadMemDocument
//			Open and load a PDF document from memory.
// Parameters: 
//			data_buf	-	Pointer to a buffer containing the PDF document
//			size		-	Number of bytes in the PDF document
//			password	-	A string used as the password for PDF file. 
//							If no password needed, empty or NULL can be used.
// Return value:
//			A handle to the loaded document. If failed, NULL is returned.
// Comments:
//			The memory buffer must remain valid when the document is open.
//			Loaded document can be closed by FPDF_CloseDocument.
//			If this function fails, you can use FPDF_GetLastError() to retrieve
//			the reason why it fails.
//
DLLEXPORT FPDF_DOCUMENT	STDCALL FPDF_LoadMemDocument(const void* data_buf, 
											int size, FPDF_BYTESTRING password);

// Structure for custom file access
typedef struct {
	// File length, in bytes
	unsigned long	m_FileLen;

	// A function pointer for getting a block of data from specific position.
	// Position is specified by byte offset from beginning of the file.
	// The position and size will never go out range of file length.
	// It may be possible for FPDFVIEW to call this function multiple times for same position.
	// Return value: should be non-zero if successful, zero for error.
	int				(*m_GetBlock)(void* param, unsigned long position, unsigned char* pBuf, unsigned long size);

	// A custom pointer for all implementation specific data.
	// This pointer will be used as the first parameter to GetBlock callback.
	void*			m_Param;
} FPDF_FILEACCESS;

// Function: FPDF_LoadCustomDocument
//			Load PDF document from a custom access descriptor
// Parameters:
//			pFileAccess	-	A structure for access the file
//			password	-	Optional password for decrypting the PDF file
// Return value:
//			A handle to the loaded document. If failed, NULL is returned.
// Comments:
//			The application should maintain the file resources being valid until the PDF document 
//			got closed by FPDF_CloseDocument() function.
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, 
														FPDF_BYTESTRING password);

#define FPDF_ERR_SUCCESS		0		// no error
#define FPDF_ERR_UNKNOWN		1		// unknown error
#define FPDF_ERR_FILE			2		// file not found or could not be opened
#define FPDF_ERR_FORMAT			3		// file not in PDF format or corrupted
#define FPDF_ERR_PASSWORD		4		// password required or incorrect password
#define FPDF_ERR_SECURITY		5		// unsupported security scheme
#define FPDF_ERR_PAGE			6		// page not found or content error

// Function: FPDF_GetLastError
//			Get last error code when an SDK function failed
// Parameters: 
//			None
// Return value:
//			A 32-bit integer indicating error codes (defined above).
// Comments:
//			If the previous SDK call succeeded, the return value of this function
//			is not defined.
//
DLLEXPORT unsigned long	STDCALL FPDF_GetLastError();

// Function: FPDF_GetDocPermission
//			Get file permission flags of the document.
// Parameters: 
//			document	-	Handle to document. Returned by FPDF_LoadDocument function.
// Return value:
//			A 32-bit integer indicating permission flags. Please refer to PDF Reference for
//			detailed description. If the document is not protected, 0xffffffff will be returned.
//
DLLEXPORT unsigned long	STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);

// Function: FPDF_GetPageCount
//			Get total number of pages in a document.
// Parameters: 
//			document	-	Handle to document. Returned by FPDF_LoadDocument function.
// Return value:
//			total number of pages in the document.
//
DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document);

// Function: FPDF_LoadPage
//			Load a page inside a document.
// Parameters: 
//			document	-	Handle to document. Returned by FPDF_LoadDocument function.
//			page_index	-	Index number of the page. 0 for the first page.
// Return value:
//			A handle to the loaded page. If failed, NULL is returned.
// Comments:
//			Loaded page can be rendered to devices using FPDF_RenderPage function.
//			Loaded page can be closed by FPDF_CloseDocument.
//
DLLEXPORT FPDF_PAGE	STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index);

// Function: FPDF_GetPageWidth
//			Get page width
// Parameters:
//			page		-	Handle to the page. Returned by FPDF_LoadPage function.
// Return value:
//			Page width (excluding non-displayable area) measured in points.
//			One point is 1/72 inch (around 0.3528 mm)
//
DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page);

// Function: FPDF_GetPageHeight
//			Get page height
// Parameters:
//			page		-	Handle to the page. Returned by FPDF_LoadPage function.
// Return value:
//			Page height (excluding non-displayable area) measured in points.
//			One point is 1/72 inch (around 0.3528 mm)
//
DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page);

// Function: FPDF_GetPageWidthByIndex
//			Get page width from a page index
// Parameters:
//			document	-	Handle to document. Returned by FPDF_LoadDocument function.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -