我正在处理一个需要显示pdf文件的项目。我有很多pdf格式的图片。我正在使用pdfviewer.jar来处理它。我实现了代码,其中显示了我的pdf,但不显示图像。错误为:
09-05 02:09:31.730: W/System.err(1050): com.sun.pdfview.PDFParseException: could not decode image of compressed size 65985
09-05 02:09:31.730: W/System.err(1050): at com.sun.pdfview.decode.DCTDecode.decode(DCTDecode.java:78)
09-05 02:09:31.730: W/System.err(1050): at com.sun.pdfview.decode.PDFDecoder.decodeStream(PDFDecoder.java:102)
09-05 02:09:31.730: W/System.err(1050): at com.sun.pdfview.PDFObject.decodeStream(PDFObject.java:334)
09-05 02:09:31.750: W/System.err(1050): at com.sun.pdfview.PDFObject.getStream(PDFObject.java:266)
09-05 02:09:31.750: W/System.err(1050): at com.sun.pdfview.PDFObject.getStream(PDFObject.java:260)
09-05 02:09:31.770: W/System.err(1050): at com.sun.pdfview.PDFImage.getImage(PDFImage.java:224)
09-05 02:09:31.770: W/System.err(1050): at com.sun.pdfview.PDFRenderer.drawImage(PDFRenderer.java:374)
09-05 02:09:31.770: W/System.err(1050): at com.sun.pdfview.PDFImageCmd.execute(PDFPage.java:654)
09-05 02:09:31.780: W/System.err(1050): at com.sun.pdfview.PDFRenderer.iterate(PDFRenderer.java:674)
09-05 02:09:31.780: W/System.err(1050): at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
09-05 02:09:31.780: W/System.err(1050): at com.sun.pdfview.BaseWatchable.execute(BaseWatchable.java:263)
09-05 02:09:31.800: W/System.err(1050): at com.sun.pdfview.BaseWatchable.go(BaseWatchable.java:197)
09-05 02:09:31.810: W/System.err(1050): at com.sun.pdfview.PDFPage.getImage(PDFPage.java:237)
09-05 02:09:31.820: W/System.err(1050): at net.sf.andpdf.pdfviewer.PdfViewerActivity.showPage(PdfViewerActivity.java:790)
09-05 02:09:31.820: W/System.err(1050): at net.sf.andpdf.pdfviewer.PdfViewerActivity.access$12(PdfViewerActivity.java:769)
09-05 02:09:31.820: W/System.err(1050): at net.sf.andpdf.pdfviewer.PdfViewerActivity$3.run(PdfViewerActivity.java:259)
09-05 02:09:31.829: W/System.err(1050): at java.lang.Thread.run(Thread.java:841)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): null
09-05 02:09:31.859: E/APV.PDFRenderer(1050): java.lang.NullPointerException
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at android.graphics.Canvas.drawBitmap(Canvas.java:1227)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at com.sun.pdfview.PDFRenderer.drawImage(PDFRenderer.java:386)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at com.sun.pdfview.PDFImageCmd.execute(PDFPage.java:654)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at com.sun.pdfview.PDFRenderer.iterate(PDFRenderer.java:674)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at com.sun.pdfview.BaseWatchable.execute(BaseWatchable.java:263)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at com.sun.pdfview.BaseWatchable.go(BaseWatchable.java:197)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at com.sun.pdfview.PDFPage.getImage(PDFPage.java:237)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at net.sf.andpdf.pdfviewer.PdfViewerActivity.showPage(PdfViewerActivity.java:790)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at net.sf.andpdf.pdfviewer.PdfViewerActivity.access$12(PdfViewerActivity.java:769)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at net.sf.andpdf.pdfviewer.PdfViewerActivity$3.run(PdfViewerActivity.java:259)
09-05 02:09:31.859: E/APV.PDFRenderer(1050): at java.lang.Thread.run(Thread.java:841)
提前谢谢。
问题出在缓冲区大小上。需要注意位图,比如确保内存外异常被消除。