@@ -6,19 +6,27 @@ Library for displaying PDF documents on Android, with `animations`, `gestures`,
66It is based on [ PdfiumAndroid] ( https://github.com/barteksc/PdfiumAndroid ) for decoding PDF files. Works on API 11 and higher.
77Licensed under Apache License 2.0.
88
9- ## What's new in 1.4.0?
10- * Fix NPE and IndexOutOfBound bugs when rendering parts
11- * Merge pull request by [ paulo-sato-daitan] ( https://github.com/paulo-sato-daitan ) for disabling page change animation
12- * Merge pull request by [ Miha-x64] ( https://github.com/Miha-x64 ) for drawing background if set on ` PDFView `
13-
14- Next release is coming soon, it will introduce continuous scroll through whole document
15- and some incompatibilities with current API (only few small).
9+ ## What's new in 2.0.0?
10+ * few API changes
11+ * improved rendering speed and accuracy
12+ * added continuous scroll - now it behaves like Adobe Reader and others
13+ * added ` fling ` scroll gesture for velocity based scrolling
14+ * added scroll handle as a replacement for scrollbar
15+
16+ ## Changes in 2.0 API
17+ * ` Configurator#defaultPage(int) ` and ` PDFView#jumpTo(int) ` now require page index (i.e. starting from 0)
18+ * ` OnPageChangeListener#onPageChanged(int, int) ` is called with page index (i.e. starting from 0)
19+ * removed scrollbar
20+ * added scroll handle as a replacement for scrollbar, use with ` Configurator#scrollHandle() `
21+ * added ` OnPageScrollListener ` listener due to continuous scroll, register with ` Configurator#onPageScroll() `
22+ * default scroll direction is vertical, so ` Configurator#swipeVertical() ` was changed to ` Configurator#swipeHorizontal() `
23+ * removed minimap and mask configuration
1624
1725## Installation
1826
1927Add to _ build.gradle_ :
2028
21- ` compile 'com.github.barteksc:android-pdf-viewer:1.4 .0' `
29+ ` compile 'com.github.barteksc:android-pdf-viewer:2.0 .0' `
2230
2331Library is available in jcenter repository, probably it'll be in Maven Central soon.
2432
4250pdfView. fromAsset(String )
4351 .pages(0 , 2 , 1 , 3 , 3 , 3 ) // all pages are displayed by default
4452 .enableSwipe(true )
53+ .swipeHorizontal(false )
4554 .enableDoubletap(true )
46- .swipeVertical(false )
47- .defaultPage(1 )
48- .showMinimap(false )
55+ .defaultPage(0 )
4956 .onDraw(onDrawListener)
5057 .onLoad(onLoadCompleteListener)
5158 .onPageChange(onPageChangeListener)
59+ .onPageScroll(onPageScrollListener)
5260 .onError(onErrorListener)
5361 .enableAnnotationRendering(false )
5462 .password(null )
55- .showPageWithAnimation( true )
63+ .scrollHandle( null )
5664 .load();
5765```
5866
5967* ` enableSwipe ` is optional, it allows you to block changing pages using swipe
6068* ` pages ` is optional, it allows you to filter and order the pages of the PDF as you need
6169* ` onDraw ` is also optional, and allows you to draw something on a provided canvas, above the current page
6270
63- ## Show scrollbar
71+ ## Scroll handle
6472
65- Use ** ScrollBar ** class to place scrollbar view near ** PDFView **
73+ Scroll handle is replacement for ** ScrollBar ** from 1.x branch.
6674
67- 1 . in layout XML ( it's important that the parent view is ** RelativeLayout** ):
75+ If you want to use ** ScrollHandle ** , it's important that the parent view is ** RelativeLayout** .
6876
69- Vertically:
70- ``` xml
71- <RelativeLayout xmlns : android =" http://schemas.android.com/apk/res/android"
72- android : layout_width =" match_parent"
73- android : layout_height =" match_parent" >
74-
75- <com .github.barteksc.pdfviewer.PDFView
76- android : id =" @+id/pdfView"
77- android : layout_width =" match_parent"
78- android : layout_height =" match_parent"
79- android : layout_toLeftOf =" @+id/scrollBar" />
80-
81- <com .github.barteksc.pdfviewer.ScrollBar
82- android : id =" @+id/scrollBar"
83- android : layout_width =" wrap_content"
84- android : layout_height =" match_parent"
85- android : layout_alignParentRight =" true"
86- android : layout_alignParentEnd =" true" />
87-
88- </RelativeLayout >
89- ```
90- Horizontally:
91- ``` xml
92- <RelativeLayout xmlns : android =" http://schemas.android.com/apk/res/android"
93- android:layout_width=" match_parent"
94- android:layout_height=" match_parent"
95- xmlns:app=" http://schemas.android.com/apk/res-auto" >
96-
97- <com .github.barteksc.pdfviewer.PDFView
98- android : id =" @+id/pdfView"
99- android : layout_width =" match_parent"
100- android : layout_height =" match_parent" />
101-
102- <com .github.barteksc.pdfviewer.ScrollBar
103- android:id=" @+id/scrollBar"
104- android:layout_width=" match_parent"
105- android:layout_height=" wrap_content"
106- app:sb_horizontal=" true"
107- android:layout_alignParentBottom=" true" />
108-
109- </RelativeLayout >
110- ```
111- 2. in activity or fragment
112- ``` java
113-
114- @Override
115- protected void onCreate(Bundle savedInstanceState) {
116- super.onCreate(savedInstanceState);
117-
118- ...
119-
120- PDFView pdfView = (PDFView) findViewById(R.id.pdfView);
121- ScrollBar scrollBar = (ScrollBar) findViewById(R.id.scrollBar);
122- pdfView.setScrollBar(scrollBar);
123- }
124- ```
125-
126- `scrollBar.setHorizontal(true);` or `app:sb_horizontal="true"` may be used to set **ScrollBar** in horizontal mode.
127-
128-
129- Scrollbar styling:
130- ``` xml
131- <com .github.barteksc.pdfviewpager.view.ScrollBar
132- android : layout_width =" wrap_content"
133- android : layout_height =" match_parent"
134- app : sb_handlerColor =" ..." <!-- scrollbar handler color -->
135- app:sb_indicatorColor="..." <!-- background color of current page indicator -->
136- app:sb_indicatorTextColor="..." <!-- text color of current page indicator -->
137- app:sb_horizontal="true|false|reference" <!-- whether to set horizontal mode -->
138- android:background="..." <!-- scrollbar background -->
139- />
140- ```
77+ To use scroll handle just register it using method ` Configurator#scrollHandle() ` .
78+ This method accepts implementations of ** ScrollHandle** interface.
79+
80+ There is default implementation shipped with AndroidPdfViewer, and you can use it with
81+ ` .scrollHandle(new DefaultScrollHandle(this)) ` .
82+ ** DefaultScrollHandle** is placed on the right (when scrolling vertically) or on the bottom (when scrolling horizontally).
83+ By using constructor with second argument (` new DefaultScrollHandle(this, true) ` ), handle can be placed left or top.
84+
85+ You can also create custom scroll handles, just implement ** ScrollHandle** interface.
86+ All methods are documented as Javadoc comments on interface [ source] ( https://github.com/barteksc/AndroidPdfViewer/tree/master/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/scroll/ScrollHandle.java ) .
14187
142- ** ScrollBarPageIndicator** is added to scrollbar automatically and is shown while dragging scrollbar handler,
143- displaying number of page on current position. Its position is automatically calculated based on ** ScrollBar** 's position.
14488
14589## Additional options
14690
0 commit comments