我已经使用库https://github.com/jblough/Android-Pdf-Viewer-Library成功显示了Assets
文件夹中的 Pdf 。我现在正在尝试解析和显示在线pdf“ http://www.gnostice.com/downloads/Gnostice_PathQuest.pdf ”,但它给出了以下错误:Android Pdf Viewer
<code>
04-19 03:17:04.995: W/System.err(27806): java.io.IOException: This may not be a PDF File
04-19 03:17:04.995: W/System.err(27806): at com.sun.pdfview.PDFFile.parseFile(PDFFile.java:1395)
04-19 03:17:04.995: W/System.err(27806): at com.sun.pdfview.PDFFile.<init>(PDFFile.java:140)
04-19 03:17:04.995: W/System.err(27806): at com.sun.pdfview.PDFFile.<init>(PDFFile.java:116)
04-19 03:17:04.995: W/System.err(27806): at net.sf.andpdf.pdfviewer.PdfViewerActivity.openFile(PdfViewerActivity.java:909)
04-19 03:17:04.995: W/System.err(27806): at net.sf.andpdf.pdfviewer.PdfViewerActivity$8.run(PdfViewerActivity.java:863)
04-19 03:17:04.995: W/System.err(27806): at java.lang.Thread.run(Thread.java:1027)
</code>
我打开URL Connection
连接为:
<code>
fileUrl = new URL(filename);
HttpURLConnection connection = (HttpURLConnection)fileUrl.openConnection();
connection.connect();
InputStream is = connection.getInputStream();
byte[] bytes = new byte[is.available()];
is.read(bytes);
System.out.println("Byte Lenght: " + bytes.length);
ByteBuffer bb = ByteBuffer.NEW(bytes);
is.close();
openFile(bb, password);
</code>
请帮助可能是什么问题?
谢谢