授权并初始化 SDK
在调用任何 SDK 的 API 之前,您的应用程序必须使用有效的许可证授权码初始化福昕转换 SDK 库。试用许可证文件位于开发包的 lib
目录下,包含 **_sn.txt
和 **_key.txt
两个文件。
初始化步骤:
获取授权码:
sn
参数的值取自**_sn.txt
文件中 "SN=" 后面的字符串。key
参数的值取自**_key.txt
文件中 "Sign=" 后面的字符串。
调用初始化函数:
- 使用获取到的
sn
和key
值,调用Library.initialize(sn, key)
函数进行 SDK 初始化。
- 使用获取到的
示例代码如下:
C++
const char* sn = " ";
const char* key = " ";
foxit::ErrorCode code = Library::Initialize(sn, key);
if (code != foxit::e_ErrSuccess) {
return FALSE;
}
java
// Load the library.
// You can also use System.load("filename") instead. The filename argument must be an absolute path name.
static {
String os = System.getProperty("os.name").toLowerCase();
String lib = "fpdfconversionsdk_java_";
if (os.startsWith("win")) {
lib += "win";
} else {
lib += "linux";
}
if (System.getProperty("sun.arch.data.model").equals("64")) {
lib += "64";
} else {
lib += "32";
}
System.loadLibrary(lib);
}
// Initialize the library.
int error_code = Library.initialize("sn", "key");
if (error_code != e_ErrSuccess) {
return;
}
C#
string sn = " ";
string key = " ";
ErrorCode error_code = Library.Initialize(sn, key);
if (error_code != ErrorCode.e_ErrSuccess)
{
return;
}
js
var sn = " ";
var key = " ";
var error_code = Library.Initialize(sn, key);
if (ErrorCode.e_ErrSuccess != error_code) {
if (ErrorCode.e_ErrInvalidLicense == error_code)
console.log("[Failed] Current used Foxit PDF Conversion SDK key information is invalid.");
else
console.log("Library Initialize Error: %d", error_code);
return;
}
py
sn = " "
key = " "
if __name__ == '__main__':
code = Library.Initialize(sn, key)
if code == e_ErrSuccess:
main()
Library.Release()