在我的应用程序中打开和查看PDF我的、应用程序、PDF

2023-09-06 05:19:55 作者:孤傲白狼

使用这个code:

try {

    URL url = new URL(aurl[0]);
    URLConnection conexion = url.openConnection();
    conexion.connect();

    int lenghtOfFile = conexion.getContentLength();
    Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);

    InputStream input = new BufferedInputStream(url.openStream());
    FileOutputStream fos = openFileOutput("try.pdf", Context.MODE_PRIVATE);
    //PARA DESCARGARLO EN SD//
//  OutputStream output = new FileOutputStream("/sdcard/prueba.pdf");

    byte data[] = new byte[1024];

    long total = 0;

        while ((count = input.read(data)) != -1) {
            total += count;
            publishProgress(""+(int)((total*100)/lenghtOfFile));
            fos.write(data, 0, count);
        }

        fos.flush();
        fos.close();
        input.close();
    } catch (Exception e) {}
    return null;

我一直在应用程序的8 MB大小的PDF文件。我用了几个codeS,试图打开和查看,但无法找到正确的路。

I keep in the application a PDF of 8 MB size. I've used several codes to try to open it and view it but can not find the way.

有什么建议?

推荐答案

请参见下面的SO答案的链接,阅读PDF从SD卡使用PDF查看器。

Please see below SO Answer's link for read pdf from sdcard using PDFViewer.

Read PDF文件

 
精彩推荐
图片推荐