Foxit PDF SDK 5.3

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

Follow the steps to add new functionality to your Android C API demo for Foxit PDF SDK:

  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 has 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.html 

    For example for the cpp content,

  3. JNIEXPORT jint JNICALL Java_com_foxit_gsdk_pdf_MyNewSomething 
    
    (JNIEnv *env, jobject jpdfObj, jlong parameter1, jint parameter2, jobject parameterEtc) 
    
    { 
    
    // Wrap job here. Means error handling and how you want the function to work. return FSPDF_SOMETHING(parameter1); 
    
    } 
    
    // For example for the .h content, 
    
    JNIEXPORT jint JNICALL Java_com_foxit_gsdk_pdf_MyNewSomething 
    
    (JNIEnv *, jobject, jlong, jint, jobject);
  4. Open samples\ViewerDemo\jni\arm_mk\jni\Android.mkAnd add your new source file to the define

    For example, LOCAL_SRC_FILES :=\

    For example, “$(SRC_PATH)/com_foxit_gsdk_pdf_MyNewSomethingSource.cpp \

  5. Add the same define from step c to samples\ViewerDemo\jni\x86_mk\jni\Android.mk
  6. Create a Java file at “samples\ViewerDemo\pdf_src\com\foxit\gsdk\pdf” and define your interface.
  7. Open a command prompt/Cygwin and navigate to “samples\ViewerDemo\jni” and run the command ndk-build –b Note: Please see “docs\FoxitPDFSDK4_1_DeveloperGuide.pdf” if you are having problems running this command.
  8. 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 5, 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: