base64解码是否禁用pdf文件中的搜索?

时间:2013-12-10 16:28:19

标签: android pdf base64 decode encode

在我的Android应用程序中通过Web服务从服务器接收阿拉伯语编码的pdf文件,然后我将其解码并保存以便随时打开它,这也是我file我下载的编码_问题是文件不再可搜索,这是我用来解码文件的代码:

    protected Void doInBackground(String... myLink) {

        if (conDetector.isConnectingToInternet()) {

            File myDir = getFilesDir();
            String fileName = PDFCACHE;
            File cachedFile = new File(myDir, fileName);
            // to check if the cached file in the memory or not
            if (cachedFile.exists()) {

                try {
                    readPDFFile();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            } else if (!cachedFile.exists()) {

                try {

                    URL url = new URL(myLink[0]);

                    URLConnection urlConnection = url.openConnection();
                    urlConnection.connect();
                    file_size = urlConnection.getContentLength();

                    source = new BufferedInputStream(url.openStream(), 8192);
                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
                    buffer = new byte[1024];
                    long total = 0;
                    int count = 0;

                    // buffer=new
                    // Scanner(source).useDelimiter("\\A").next().getBytes();*/
                    // buffer = Base64.decode(buffer, 0);

                    for (int i; (i = source.read(buffer)) != -1;) {
                        total += i;
                        bos.write(buffer, 0, i); // no doubt here is 0
                        publishProgress(""
                                + (int) ((total * 100) / file_size));
                    }
                    if (flag == false) {
                        bytes = bos.toByteArray();
                        bytes = Base64.decode(bytes, Base64.DEFAULT);

                        String decodedString = new String(bytes);
                        if (bytes != null) {
                            openBuffer(bytes);
                            if (manipulateCache())
                                try {
                                    savePDFFile(bytes);
                                    // source.close();
                                } catch (IOException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }

                        } else {
                            core = openFile(decodedString);

                        }

                    }
                } catch (MalformedURLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();

                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

            // when there is no internet connection "offline mode"
        } else if (!(conDetector.isConnectingToInternet())) {

            if (!PDFCACHE.equals(null)) {

                try {
                    readPDFFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }
        return null;
    }       }

1 个答案:

答案 0 :(得分:0)

您收到的文件无法搜索,字体对象包含 ToUnicode 地图,声称大多数使用的字形都是数字,符号或拉丁字符,这些字符与阿拉伯字符的外观不符。

因此,没有标准的PDF查看器可用于搜索文件。