Thursday, June 13, 2019

View pdf in android from assets

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)


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 file

PDFView 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:

Alert Dialog Box

Alert Dialog Box Android AlertDialog   can be used to display the dialog message with OK and Cancel buttons. It can be used to inter...