首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从PDFView中的url加载pdf

从PDFView中的url加载pdf
EN

Stack Overflow用户
提问于 2020-05-01 16:50:48
回答 1查看 987关注 0票数 0

我想从url加载pdf,我使用了PDFViewer库。但是,当打开我的应用程序时,它显示为空白。我需要你的帮助。

这是我的代码:

代码语言:javascript
运行
复制
        PDFView pdfView = findViewById(R.id.pdfView);
            pdfView.fromUri(Uri.parse("https://firebasestorage.googleapis.com/v0/b/pdff-69823.appspot.com/o/ehp1.pdf?alt=media&token=9bb1792e-0787-461c-a6a8-1be6724be93f")).load();

下面是我的XML:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.github.barteksc.pdfviewer.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

并且,我使用了这个依赖关系:

代码语言:javascript
运行
复制
    implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
EN

回答 1

Stack Overflow用户

发布于 2020-05-01 21:41:37

为什么我无法从URL打开PDF?

下载文件是一个长时间运行的过程,它必须知道活动的生命周期,必须支持一些配置,数据清理和缓存,所以创建这样的模块可能会以新库的形式结束。

我认为这个库只支持设备存储中已经存在的文件,或者您可以使用其他选项,如fromBytes(byte[])或fromStream(InputStream)。

另一种选择是您可以下载并加载该文件。

如果你选择实时渲染,那么可以选择其他选项,如Pdfjs等。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61539387

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档