包括在一个应用程序的PDF文件的最佳方法 [英] Best way to include pdfs in an app

查看:96
本文介绍了包括在一个应用程序的PDF文件的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要开发一个应用程序,它基本上是一个PDF阅读器:它是由一个列表组成,每个列表元素是一个PDF文件的名称,当用户点击列表元素的PDF弹出出来,读取PDF阅读器安装在设备上。

I have to develop an app which is basically a pdf reader: it is composed by a list, each list element is a pdf file name, when user clicks on a list element the pdf is popped out, read by a pdf reader installed on the device.

现在,问题是,我想包括这些PDF文件在我的应用程序。 到目前为止,我发现的唯一方法是将它们设置为资源,但问题是,每次我要显示其中一人我就必须将它复制的公共文件夹,这显然需要时间......不有另一种方式?

Now, problem is that i'd like to include these pdfs in my app. Till now the only way I found is to set them as resource, but the problem is that each time I want to display one of them I'll have to copy it in a public folder and this obviously takes time...isn't there another way?

推荐答案

您可以添加的ContentProvider 您的应用程序,流的PDF文件,从资源的其他进程。例如,我的 StreamProvider 扩展Android的 FileProvider 来添加对从原料资源或资产提供文件服务的支持。演示项目,特别是展示了从服务资产PDF。

You can add a ContentProvider to your app that streams the PDFs to the other process from the resource. For example, my StreamProvider extends Android's FileProvider to add support for serving files from raw resources or assets. The demo project, in particular, demonstrates serving a PDF from assets.

这篇关于包括在一个应用程序的PDF文件的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆