PDF文件另存为Android的.apk文件的一部分 [英] Pdf files as part of Android .apk

查看:209
本文介绍了PDF文件另存为Android的.apk文件的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建立一个Android应用程序,它显示的PDF文件列表。这些PDF文件应该受到保护,换句话说 - 该应用程序的用户应该无法通过任何手段(复制/剪切/打印...等),以获取PDF内容的副本。我的问题现在

I have to build an Android application which shows a list of pdf files. These pdf files should be secured, in other words - the user of the app should not be able to get a copy of the pdf content by any means (copy/cut/print...etc). My questions now are


  1. 我应该如何出货的PDF文件的内容与.apk文件一起。

  2. 如果我们发送的文件的内容在diff格式(生/字节code),我应该如何将文件转换回PDF,我应该在哪里放置安装的机器上的文件,使得它是安全的

仅供参考,我会的Adobe Redaer当前版本锁定为PDF查看器来查看PDF文件,因为它不允许复制/粘贴/打印。

FYI, I will be locking down current version of Adobe Redaer as the pdf viewer to view the pdf files as it doesn't allow copy/paste/print.

这是我开发的第一个Android应用程序。所以,我有种Android的新手。任何帮助将大大AP preciated。

This is the first Android app that I am developing. So, I'm a kind of Android newbie. Any help would be greatly appreciated.

谢谢,
纳文

推荐答案

您可以在此(这些)PDF文件(S)复制到资产的文件夹中,因此您的文件将是应用程序的一部分,不能被外界访问,你也可以把它们当作普通文件(即与PDF阅读器在你的情况开)。每当你想获得访问背景文件,您可以拨打 context.getAssets()

You can copy this(these) pdf file(s) into assets folder, thus your files will be the part of your application and can not be accessible outside, and you can also treat them as normal files (i.e. open with any pdf viewer in your case). Whenever you want to get access to context file you can call context.getAssets() .

希望这信息帮助。

更新:这里是code我用来打开下载目录中的文件,这code如果安装在手机可以在任何兼容的PDF阅读器打开PDF文件,经测试使用Adobe Reader。您将需要PDF文件的URI的资产文件夹运行code。

Update : Here is the code I am using to open a file in downloads directory, this code can open the pdf file in any compatible pdf reader if installed on phone, Tested with Adobe Reader. You will need a URI of the pdf file in assets folder to run the code.

String fileName = pdfUrl.substring(pdfUrl.lastIndexOf("/"));

        Log.i("fileName", "" + fileName);
        File file = new File("/sdcard/download" + fileName);
        // File file = new
        // File("/sdcard/download/airtel_latest000.mp3");

        Intent intent;
        if (file.exists()) {

            Uri path = Uri.fromFile(file);

            intent = new Intent(Intent.ACTION_VIEW);

            intent.setDataAndType(path, "application/pdf");

            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

            downloaded = true;

        } else {

            intent = new Intent(Intent.ACTION_VIEW);

            intent.setData(Uri.parse(pdfUrl));

            downloaded = false;
        }
        try {
            startActivityForResult(intent, 5);

        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "No Application Available to View PDF",
                    Toast.LENGTH_SHORT).show();
        }

这篇关于PDF文件另存为Android的.apk文件的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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