繁体   English   中英

如何通过使用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.

与Windows演示应用程序不同,Android演示应用程序没有内置的HTTP客户端。 因此,您不能简单地提供一个URL。

如果要执行此操作,则必须自己实现HTTP通信。 我相信Windows应用程序使用了Curl库,我不知道这是否适用于Android。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM