The best way to view PDF in your application is by using third party library barteksc .the code is very simple and it works fine.
1. Add the dependency in build gradle(Module app)
1. Add the dependency in build gradle(Module app)
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
2.Xml file<com.github.barteksc.pdfviewer.PDFView android:id="@+id/pdfv" android:layout_width="match_parent" android:layout_height="match_parent"></com.github.barteksc.pdfviewer.PDFView>3.Java filePDFView pdfView; @Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_resume); pdfView=findViewById(R.id.pdfv); pdfView.fromAsset("resume.pdf").load();}
No comments:
Post a Comment