1

我正在做一个需要显示 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)

提前致谢。

4

1 回答 1

1

问题在于缓冲区大小。需要注意位图,例如确保消除内存不足异常。

于 2013-09-25T09:57:37.397 回答