android studio pdf viewer Tutorial | অ্যান্ড্রয়েড স্টুডিও পিডিএফ ভিউয়ার টিউটোরিয়াল |

android studio pdf viewer Tutorial | অ্যান্ড্রয়েড স্টুডিও পিডিএফ ভিউয়ার টিউটোরিয়াল |

Add to build.gradle:

implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

 

Include PDFView in your layout

<com.github.barteksc.pdfviewer.PDFView    android:id="@+id/pdfView"    android:layout_width="match_parent"    android:layout_height="match_parent" />
 

Load a PDF file

private PDFView pdfView;
pdfView = findViewById(R.id.pdfView);
pdfView.fromAsset("filename") .enableSwipe(true) .swipeHorizontal(true) .enableDoubletap(true) .defaultPage(0) .enableAnnotationRendering(false) .password(null) .scrollHandle(null) .enableAntialiasing(true) .spacing(0) .pageFitPolicy(FitPolicy.WIDTH) .load();At Create Folder (assets ).Paste the PDF here...

Taking a deep look into the code above
.fromAsset(filename)

filename is a place holder for the pdf file you uploaded. Input the name without the extension (.pdf)

.enableSwipe(true)

This allows you to changing pages using swipe

.swipeHorizontal(true)

Allows you to swipe left and right horizontally

.enableAnnotationRendering(false)

This can be set to true if you want to render annotations such as colors, comments forms etc but in my case i disabled it by setting the value to false

.spacing(0)

As you might have thought of this determines the space in between pages measured in dp. To make it more obvious set view background which will make you see the spacing color

 

Post a Comment

মূল্যবান মতামতের জন্য আপনাকে অসংখ্য ধন্যবাদ

Previous Post Next Post