如何通过使用 mupdf 在 android 中指定其服务器端路径来打开位于服务器端的 pdf 文件
How to open pdf file which is located at server side by specifying its server side path in android using mupdf
我正在使用 mupdf 库在我的 android 应用程序中呈现 pdf 文件。
当我为 pdf 指定本地路径时,它在我的应用程序中成功打开,而当我编写以下代码来呈现服务器端 pdf 文件时,它在对话框中给出错误消息,因为无法打开 pdf 文件
Uri uri = Uri.parse("http://kmmc.in/wp-content/uploads/2014/01/lesson2.pdf");
Intent intent = new Intent(context, MuPDFActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
context.startActivity(intent);
我是 android 应用程序开发的新手。
这是我的 LogCat:
06-03 10:57:53.517 1645-1645/com.tekinarslan.sample I/art﹕ Not late-enabling -Xcheck:jni (already on)
06-03 10:57:56.676 1645-1665/com.tekinarslan.sample D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-03 10:57:56.717 1645-1645/com.tekinarslan.sample D/﹕ HostConnection::get() New Host Connection established 0xb4a93ec0, tid 1645
06-03 10:57:56.873 1645-1645/com.tekinarslan.sample D/Atlas﹕ Validating map...
06-03 10:57:57.380 1645-1645/com.tekinarslan.sample I/System.out﹕ Trying to open /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.419 1645-1645/com.tekinarslan.sample W/linker﹕ libmupdf.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
06-03 10:57:57.503 1645-1645/com.tekinarslan.sample E/libmupdf﹕ Opening document...
06-03 10:57:57.504 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: cannot open /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.504 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: cannot load document '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.505 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: Cannot open document: '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.505 1645-1645/com.tekinarslan.sample E/libmupdf﹕ Failed: Cannot open document: '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.508 1645-1645/com.tekinarslan.sample I/System.out﹕ java.lang.Exception: Cannot open file: /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.853 1645-1657/com.tekinarslan.sample I/art﹕ Background sticky concurrent mark sweep GC freed 2315(157KB) AllocSpace objects, 0(0B) LOS objects, 20% free, 887KB/1117KB, paused 997us total 139.942ms
06-03 10:57:58.297 1645-1657/com.tekinarslan.sample I/art﹕ Background partial concurrent mark sweep GC freed 358(28KB) AllocSpace objects, 1(81KB) LOS objects, 50% free, 985KB/2009KB, paused 14.274ms total 208.324ms
06-03 10:57:58.482 1645-1645/com.tekinarslan.sample I/Choreographer﹕ Skipped 41 frames! The application may be doing too much work on its main thread.
06-03 10:57:58.601 1645-1665/com.tekinarslan.sample D/﹕ HostConnection::get() New Host Connection established 0xb4b36ff0, tid 1665
06-03 10:57:58.613 1645-1665/com.tekinarslan.sample I/OpenGLRenderer﹕ Initialized EGL, version 1.4
06-03 10:57:58.640 1645-1665/com.tekinarslan.sample D/OpenGLRenderer﹕ Enabling debug mode 0
06-03 10:57:58.655 1645-1665/com.tekinarslan.sample W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-03 10:57:58.655 1645-1665/com.tekinarslan.sample W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb4b5a240, error=EGL_SUCCESS
06-03 10:57:58.795 1645-1665/com.tekinarslan.sample W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-03 10:57:58.795 1645-1665/com.tekinarslan.sample W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb4b5a260, error=EGL_SUCCESS
06-03 10:57:59.114 1645-1645/com.tekinarslan.sample I/Choreographer﹕ Skipped 37 frames! The application may be doing too much work on its main thread.
android 演示应用程序与 Windows 演示应用程序不同,它没有内置 HTTP 客户端。所以你不能简单地提供一个 URL.
如果您想这样做,您必须自己实现 HTTP 通信。我相信 Windows 应用程序使用了 Curl 库,我不知道这是否适用于 Android。
我正在使用 mupdf 库在我的 android 应用程序中呈现 pdf 文件。 当我为 pdf 指定本地路径时,它在我的应用程序中成功打开,而当我编写以下代码来呈现服务器端 pdf 文件时,它在对话框中给出错误消息,因为无法打开 pdf 文件
Uri uri = Uri.parse("http://kmmc.in/wp-content/uploads/2014/01/lesson2.pdf");
Intent intent = new Intent(context, MuPDFActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
context.startActivity(intent);
我是 android 应用程序开发的新手。
这是我的 LogCat:
06-03 10:57:53.517 1645-1645/com.tekinarslan.sample I/art﹕ Not late-enabling -Xcheck:jni (already on)
06-03 10:57:56.676 1645-1665/com.tekinarslan.sample D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-03 10:57:56.717 1645-1645/com.tekinarslan.sample D/﹕ HostConnection::get() New Host Connection established 0xb4a93ec0, tid 1645
06-03 10:57:56.873 1645-1645/com.tekinarslan.sample D/Atlas﹕ Validating map...
06-03 10:57:57.380 1645-1645/com.tekinarslan.sample I/System.out﹕ Trying to open /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.419 1645-1645/com.tekinarslan.sample W/linker﹕ libmupdf.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
06-03 10:57:57.503 1645-1645/com.tekinarslan.sample E/libmupdf﹕ Opening document...
06-03 10:57:57.504 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: cannot open /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.504 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: cannot load document '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.505 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: Cannot open document: '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.505 1645-1645/com.tekinarslan.sample E/libmupdf﹕ Failed: Cannot open document: '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.508 1645-1645/com.tekinarslan.sample I/System.out﹕ java.lang.Exception: Cannot open file: /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.853 1645-1657/com.tekinarslan.sample I/art﹕ Background sticky concurrent mark sweep GC freed 2315(157KB) AllocSpace objects, 0(0B) LOS objects, 20% free, 887KB/1117KB, paused 997us total 139.942ms
06-03 10:57:58.297 1645-1657/com.tekinarslan.sample I/art﹕ Background partial concurrent mark sweep GC freed 358(28KB) AllocSpace objects, 1(81KB) LOS objects, 50% free, 985KB/2009KB, paused 14.274ms total 208.324ms
06-03 10:57:58.482 1645-1645/com.tekinarslan.sample I/Choreographer﹕ Skipped 41 frames! The application may be doing too much work on its main thread.
06-03 10:57:58.601 1645-1665/com.tekinarslan.sample D/﹕ HostConnection::get() New Host Connection established 0xb4b36ff0, tid 1665
06-03 10:57:58.613 1645-1665/com.tekinarslan.sample I/OpenGLRenderer﹕ Initialized EGL, version 1.4
06-03 10:57:58.640 1645-1665/com.tekinarslan.sample D/OpenGLRenderer﹕ Enabling debug mode 0
06-03 10:57:58.655 1645-1665/com.tekinarslan.sample W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-03 10:57:58.655 1645-1665/com.tekinarslan.sample W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb4b5a240, error=EGL_SUCCESS
06-03 10:57:58.795 1645-1665/com.tekinarslan.sample W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-03 10:57:58.795 1645-1665/com.tekinarslan.sample W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb4b5a260, error=EGL_SUCCESS
06-03 10:57:59.114 1645-1645/com.tekinarslan.sample I/Choreographer﹕ Skipped 37 frames! The application may be doing too much work on its main thread.
android 演示应用程序与 Windows 演示应用程序不同,它没有内置 HTTP 客户端。所以你不能简单地提供一个 URL.
如果您想这样做,您必须自己实现 HTTP 通信。我相信 Windows 应用程序使用了 Curl 库,我不知道这是否适用于 Android。