I need to insert a pdf in my application; how could I do that? Is there a pdf view? The pdf will be inside the application itself in the assets folder. Thank you.
I need to insert a pdf in my application; how could I do that? Is there a pdf view? The pdf will be inside the application itself in the assets folder. Thank you.
Just a hint about Java and android, you can not put applications inside ./assets
and run them, what you do is use Intent
to access another application installed on Android or else you put a library ( .java or .jar) in your project that gives your application the ability to read PDFs.
To view the PDF with the device's default player you can use the code quoted in this SOen response :
File file = new File("CAMINHO DO SEU PDF/example.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
If there might be an application for reading, you may want to use a library such as ieee8023 / PDFViewer , in this case you will also have to use Intent
, this is well updated but lacks documentation.
Alternatively you can view this repository link , to use it do something like:
pdfView.fromAsset("CAMINHO DO SEU PDF/example.pdf")
.pages(0, 2, 1, 3, 3, 3)
.defaultPage(1)
.showMinimap(false)
.enableSwipe(true)
.onDraw(onDrawListener)
.onLoad(onLoadCompleteListener)
.onPageChange(onPageChangeListener)
.load();