Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E/APV.PDFRenderer(5425): java.nio.BufferUnderflowException #10

Open
a-klimashevsky opened this issue Dec 18, 2012 · 6 comments
Open

E/APV.PDFRenderer(5425): java.nio.BufferUnderflowException #10

a-klimashevsky opened this issue Dec 18, 2012 · 6 comments

Comments

@a-klimashevsky
Copy link

During page renreding I catched this error. Also page was rendered incorect.
Stack trace
12-18 13:01:53.501: E/APV.PDFRenderer(5425): null
12-18 13:01:53.501: E/APV.PDFRenderer(5425): java.nio.BufferUnderflowException
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at java.nio.Buffer.checkGetBounds(Buffer.java:177)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:41)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at java.nio.MappedByteBufferAdapter.get(MappedByteBufferAdapter.java:144)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at java.nio.ByteBuffer.get(ByteBuffer.java:384)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at net.sf.andpdf.nio.NioByteBuffer.get(NioByteBuffer.java:99)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.decode.DCTDecode.decode(DCTDecode.java:73)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.decode.PDFDecoder.decodeStream(PDFDecoder.java:102)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.PDFObject.decodeStream(PDFObject.java:334)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.PDFObject.getStream(PDFObject.java:266)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.PDFObject.getStream(PDFObject.java:260)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.PDFImage.getImage(PDFImage.java:224)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.PDFRenderer.drawImage(PDFRenderer.java:374)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.PDFImageCmd.execute(PDFPage.java:654)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.PDFRenderer.iterate(PDFRenderer.java:674)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.BaseWatchable.execute(BaseWatchable.java:263)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.BaseWatchable.go(BaseWatchable.java:197)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at com.sun.pdfview.PDFPage.getImage(PDFPage.java:237)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at net.sf.andpdf.pdfviewer.PdfViewerActivity.showPage(PdfViewerActivity.java:794)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at net.sf.andpdf.pdfviewer.PdfViewerActivity.access$12(PdfViewerActivity.java:773)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at net.sf.andpdf.pdfviewer.PdfViewerActivity$3.run(PdfViewerActivity.java:259)
12-18 13:01:53.501: E/APV.PDFRenderer(5425): at java.lang.Thread.run(Thread.java:856)

@taynanbonaldo
Copy link

Gotta find an answer to this problem? I am also having the same problem, and could not solve it.

@a-klimashevsky
Copy link
Author

not yet

@taynanbonaldo
Copy link

Good news,

I managed to solve the problem:

  1. Download the project "Android-PDF-Viewer-Library";
  2. Import to your development environment;
  3. Make changes as instructed on this issue: multiple problems on page rendering. #1;
  4. Run the project. (If you can not run because of the message "android library projects can not be launched", follow the step-by-step located at the end of the comment);
  5. Probably the project will not open. But, that's it! Open the "bin" folder, copy the file android-pdf-viewer-library-master.jar and paste it into the libs folder of your project. (if you want, change the file name to PdfViewer.jar);
  6. Add the lib to the Build Path;

Performing the above steps, probably the error will be corrected.


Steps to solve "android library projects cannot be launched":

  1. In the Package Explorer, right-click the library project and select Properties.
  2. In the Properties window, select the "Android" properties group at left and locate. the Library properties at right.
  3. Select the "is Library" checkbox and click Apply.
  4. Click OK to close the Properties window.

I hope I helped!

Bye!

@preichelt
Copy link

For anyone that doesn't want to have to recompile the .jar after making the fix @taynanb detailed above, I've made a fork containing this fix and also fixes @mcnerthney has committed. It can be found here: https://github.com/preichelt/Android-Pdf-Viewer-Library and it contains the recompiled .jar.

Thanks @taynanb, @BarisCirika and @mcnerthney for your work

@laabor
Copy link

laabor commented Mar 1, 2013

@taynanb I followed Your instructions and tried @preichelt 's fork, but i get the same error in both cases:

Unable to execute dex: Multiple dex files define Lorg/bouncycastle/crypto/CipherParameters;
Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/bouncycastle/crypto/CipherParameters;

Any ideas how to fix that ?

@GyulaJuhasz
Copy link

I don't know if anyone is still interested, but this Exception is caused by a bug in Android's MappedByteBuffer class.

The solution is not to use rewind() on these Buffers (ie replace every ".rewind()" to ".position(0)", in all source files (even in the Sun's pdf viewer package, everywhere)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants