【问题标题】:MuPdf save file after annotation android注释android后的MuPdf保存文件
【发布时间】:2016-01-05 14:07:42
【问题描述】:

我正在使用 mupdf 库进行注释。在我们支持 mupdfactivity 的注释之后,编写了下面的代码

@Override
public void onBackPressed() {
    if (core != null && core.hasChanges()) {
        DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                if (which == AlertDialog.BUTTON_POSITIVE)
                    core.save();

                finish();
            }
        };
        AlertDialog alert = mAlertBuilder.create();
        alert.setTitle("Save Changes");
        alert.setMessage(getString(R.string.document_has_changes_save_them_));
        alert.setButton(AlertDialog.BUTTON_POSITIVE,
                getString(R.string.yes), listener);
        alert.setButton(AlertDialog.BUTTON_NEGATIVE,
                getString(R.string.no), listener);
        alert.show();
    } else {
        super.onBackPressed();
    }
}

但是当我点击 core.save() 方法时,它会将我重定向到 MuPdfCore.java 中的本机函数体。

private native void saveInternal();

我想更改保存文件的路径。搜索这个方法实现,我在哪里可以得到保存方法的实现?有没有人做过这方面的工作?

提前致谢

【问题讨论】:

    标签: java android mupdf


    【解决方案1】:

    您可以在 platform/android/jni/mupdf.c 中找到您正在查找的函数以及从 Java 端调用的所有其他本机函数。

    您可以修改此函数以接受新路径,方法是将其声明更改为

    JNI_FN(MuPDFCore_saveAsInternal)(JNIEnv *env, jobject thiz, jstring jpath)
    

    然后可以通过类似声明使 Java 端可以访问该函数

    private native int saveAsInternal(String path);
    

    在班级MuPDFCore

    在 C 代码中,您可以通过类似的方式获取作为 Java 字符串传递的路径

    const char *new_path = NULL;                                                            
    if (jpath != NULL) {
        public static native boolean javascriptSupported();
        new_path = (*env)->GetStringUTFChars(env, jpath, NULL);
    }
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2013-11-26
      • 1970-01-01
      • 2015-04-19
      • 2011-05-04
      • 2020-05-30
      • 2015-04-19
      • 2017-01-12
      • 2018-05-23
      • 1970-01-01
      相关资源
      最近更新 更多