Foxit PDF SDK 5.3

How to modify or add additional functionality/methods to the Android C API demo?

To handle additional functionality or methods to Foxit PDF SDK Android C API demo, follow the steps below:

  1. Go to “samples\ViewerDemo\jni” and review how the implementation on how some of the API are already done.Tip: Look for functions that have similar parameters and use it as your template for writing your own.
  2. Create a new .cpp and .h file that includes the method you need.For guidance, see http://developer.android.com/training/articles/perf-jni.htmlFor example for the cpp JNI file can contain,
JNIEXPORT jint JNICALL Java_com_foxit_gsdk_pdf_MyNewSomething

  (JNIEnv *env, jobject jpdfObj, jlong parameter1, jint parameter2, jobject parameterEtc)

{

//Note:Wrap job here. Means error handling and how you want the function to work.

return FSPDF_SOMETHING(parameter1);

}

For example for the .h content file can contain,

JNIEXPORT jint JNICALL Java_com_foxit_gsdk_pdf_MyNewSomething

  (JNIEnv *, jobject, jlong, jint, jobject);
  1. Open samples\ViewerDemo\jni\arm_mk\jni\Android.mkAnd add your new source file to the defineFor example,
    LOCAL_SRC_FILES :=\
    
    $(SRC_PATH)/com_foxit_gsdk_pdf_MyNewSomethingSource.cpp \
  2. Add the same define from step c to samples\ViewerDemo\jni\x86_mk\jni\Android.mk
  3. Create a Java file at “samples\ViewerDemo\pdf_src\com\foxit\gsdk\pdf” and define your interface.
  4. Open a command prompt/Cygwin and navigate to “samples\ViewerDemo\jni” and run the command ndk-build –bNote: Please see “docs\FoxitPDFSDK4_1_DeveloperGuide.pdf” if you are having problems running this command.
  5. The new interface should now be available to use.

Note: This article refers to a deprecated version of a Foxit Product. If you are still using Foxit PDF SDK 5.3 or older, please refer to your download package documents for Developer Guide and API Reference.

Get a trial version of the new Foxit PDF SDK and see our latest generation SDK’s brand new features!

Updated on April 4, 2017

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: