Comments (20)
hi ,you can also change .pdf file from assets to res/raw ,then everything is ok.
change code :
mFileDescriptor = context.getAssets().openFd("sample.pdf").getParcelFileDescriptor();
to
Resources res = context.getResources(); mFileDescriptor = res.openRawResourceFd(R.raw.sample).getParcelFileDescriptor();
from android-pdfrendererbasic.
@swetakadam I think you might upgrade gradle version to 2.2.0, when I upgrade gradle version to 2.2.0, then this crash will happen.
So, you should keep gradle version as 2.1.2.
@yaraki
I also create a PR, please have a look
from android-pdfrendererbasic.
Hi, I have the same problem:
java.io.IOException: not create document. Error:
at android.graphics.pdf.PdfRenderer.nativeCreate(Native Method)
at android.graphics.pdf.PdfRenderer.(PdfRenderer.java:153)
at com.example.android.pdfrendererbasic.PdfRendererBasicFragment.openRenderer(PdfRendererBasicFragment.java:141)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.pdf.PdfRenderer.getPageCount()' on a null object reference
at com.example.android.pdfrendererbasic.PdfRendererBasicFragment.showPage(PdfRendererBasicFragment.java:163)
at com.example.android.pdfrendererbasic.PdfRendererBasicFragment.onViewCreated(PdfRendererBasicFragment.java:101)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:908)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.app.BackStackRecord.run(BackStackRecord.java:834)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
at android.app.Activity.performStart(Activity.java:6005)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
the demo is working, I only change the sample.pdf to my own pdf.
from android-pdfrendererbasic.
That error means that mPdfRenderer = new PdfRenderer(mFileDescriptor)
in the openRenderer
method was not called, which will not happen just by adding some permissions or replacing the PDF file. What else have you changed? Did you change the logic around openRenderer
? Feel free to reopen the issue if this doesn't work.
from android-pdfrendererbasic.
i have the exact same problem
from android-pdfrendererbasic.
Same problem w aide ide
from android-pdfrendererbasic.
I have the same problem.
from android-pdfrendererbasic.
Any solution to the issue?
from android-pdfrendererbasic.
any solution still the same ... I have just replaced file ... not changed any other code
from android-pdfrendererbasic.
@yaraki -- it is not working please can we open this again
from android-pdfrendererbasic.
Can you provide a project to reproduce the issue?
from android-pdfrendererbasic.
@yaraki -- I solved the issue for me ... .. check this discussion they provide deeper details https://code.google.com/p/android/issues/detail?id=82841 ...
sorry could not give example project ... even if you checkout google sample .. and replace sample.pdf to some other file in assets .... it will keep displaying sample.pdf .. or sometimes keep throwing above error ..
My fix was --
I am not reading from assets ... assets directory is causing issues
SDcard -- files on it work as a charm ..
Another important change done by me is -- the code from onDetach is moved to onDestroy ...
I will investigate further about assets directory .. for now I wasted a day and half on this example just to change the file
from android-pdfrendererbasic.
As README.md says, if you are using a file from assets, include this in your build.gradle.
android {
aaptOptions {
noCompress "pdf"
}
}
from android-pdfrendererbasic.
I did that too .. as filed from assets are compressed ...
from android-pdfrendererbasic.
Chauyan, thanks for the report. It seems that Android gradle plugin 2.2.0 has a bug with aaptOptions: https://code.google.com/p/android/issues/detail?id=224273
from android-pdfrendererbasic.
@yaraki , thank you for reporting.
from android-pdfrendererbasic.
@yaraki
I m using xamarin studio so in xamarin studio it is app.csprj file I tried that "" but error says
"Java.io.extension: can not create file error 3"
I searched lot but couldnt find answer
from android-pdfrendererbasic.
@hpu-spring87
I liked your trick so when I was trying it into my project my xamarin studio extenion for visual studio 2015 crashed so couldnt tried. I ll try
from android-pdfrendererbasic.
@hpu-spring87
I tried your logic but same erro
Java.IO.IOException: cannot create document. Error: 3
from android-pdfrendererbasic.
I found answer for my problem here
the 4th Comment from "This allows the sample to work:
"
from android-pdfrendererbasic.
Related Issues (20)
- Crash with big pdf file HOT 1
- handle embed link in pdf page HOT 1
- How to upgrade image resolution? HOT 2
- java.io.IOException: cannot create document. Error: 3 HOT 6
- How to open pdf file from the sd Instance of Assets folder. HOT 1
- not support half-transparent white HOT 1
- can not read custom fonts HOT 3
- black border around content HOT 1
- App crashes when minimize the App and Open App again HOT 4
- How to open password protected PDFs? HOT 1
- Does not show annotations HOT 1
- How to use in android 17 (api) HOT 1
- Show Pdf in Recyclerview HOT 7
- Cannot open PDF file after open wrong file HOT 13
- App is crashing in Samsung J5 Api 23. HOT 1
- WHEN CHANGE API LEVEL GOT ERROR
- The PdfRenderer cannot set the API level to 19... HOT 1
- Upstream issue with PdfRenderer HOT 2
- Some Fatal Error HOT 4
- How to zoom page ?? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-pdfrendererbasic.