Skip to content

Commit da4033e

Browse files
author
Zachary Wander
committed
Update README to describe this fork's status
1 parent ab22d76 commit da4033e

File tree

1 file changed

+62
-18
lines changed

1 file changed

+62
-18
lines changed

README.md

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,52 @@
1-
21
# WARNING!
3-
This fork was made in order to migrate the library to AndroidX. Add-ons and updates probably will not appear.
42

5-
[![Release](https://jitpack.io/v/TalbotGooday/AndroidPdfViewer.svg)](https://jitpack.io/#TalbotGooday/AndroidPdfViewer)
3+
This fork was made in order to migrate the library to AndroidX and switch to PdfiumAndroidKt.
4+
5+
Pull requests will be monitored for new features, but very little proactive maintenance will be done.
6+
7+
[![Release](https://jitpack.io/v/zacharee/AndroidPdfViewer.svg)](https://jitpack.io/#zacharee/AndroidPdfViewer)
68

79
Add to _build.gradle_:
10+
811
```groovy
912
allprojects {
10-
repositories {
11-
...
12-
maven { url 'https://jitpack.io' }
13-
}
13+
repositories {
14+
...
15+
maven { url 'https://jitpack.io' }
16+
}
1417
}
1518
```
19+
1620
Add the dependency
21+
22+
```groovy
23+
implementation 'com.github.zacharee:AndroidPdfViewer:Tag'
24+
```
25+
26+
Consider also depending directly on [PdfiumAndroidKt](https://github.com/johngray1965/PdfiumAndroidKt) in order to stay
27+
up-to-date on the actual PDF rendering logic
28+
1729
```groovy
18-
implementation 'com.github.TalbotGooday:AndroidPdfViewer:Tag'
30+
implementation 'io.legere:pdfiumandroid:Version'
1931
```
2032

2133
---
34+
2235
### Original description
36+
2337
# Android PdfViewer
2438

2539
__AndroidPdfViewer 1.x is available on [AndroidPdfViewerV1](https://github.com/barteksc/AndroidPdfViewerV1)
2640
repo, where can be developed independently. Version 1.x uses different engine for drawing document on canvas,
2741
so if you don't like 2.x version, try 1.x.__
2842

2943
Library for displaying PDF documents on Android, with `animations`, `gestures`, `zoom` and `double tap` support.
30-
It is based on [PdfiumAndroid](https://github.com/barteksc/PdfiumAndroid) for decoding PDF files. Works on API 11 (Android 3.0) and higher.
44+
It is based on [PdfiumAndroid](https://github.com/barteksc/PdfiumAndroid) for decoding PDF files. Works on API 11 (
45+
Android 3.0) and higher.
3146
Licensed under Apache License 2.0.
3247

3348
## What's new in 3.2.0-beta.1?
49+
3450
* Merge PR #714 with optimized page load
3551
* Merge PR #776 with fix for max & min zoom level
3652
* Merge PR #722 with fix for showing right position when view size changed
@@ -45,10 +61,12 @@ Licensed under Apache License 2.0.
4561
* Update Gradle and Gradle Plugin
4662

4763
## Changes in 3.0 API
64+
4865
* Replaced `Contants.PRELOAD_COUNT` with `PRELOAD_OFFSET`
4966
* Removed `PDFView#fitToWidth()` (variant without arguments)
5067
* Removed `Configurator#invalidPageColor(int)` method as invalid pages are not rendered
51-
* Removed page size parameters from `OnRenderListener#onInitiallyRendered(int)` method, as document may have different page sizes
68+
* Removed page size parameters from `OnRenderListener#onInitiallyRendered(int)` method, as document may have different
69+
page sizes
5270
* Removed `PDFView#setSwipeVertical()` method
5371

5472
## Installation
@@ -58,12 +76,13 @@ Add to _build.gradle_:
5876
`implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'`
5977

6078
or if you want to use more stable version:
61-
79+
6280
`implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'`
6381

6482
Library is available in jcenter repository, probably it'll be in Maven Central soon.
6583

6684
## ProGuard
85+
6786
If you are using ProGuard, add following rule to proguard config file:
6887

6988
```proguard
@@ -82,6 +101,7 @@ If you are using ProGuard, add following rule to proguard config file:
82101
## Load a PDF file
83102

84103
All available options with default values:
104+
85105
``` java
86106
pdfView.fromUri(Uri)
87107
or
@@ -134,46 +154,56 @@ pdfView.fromAsset(String)
134154

135155
Scroll handle is replacement for **ScrollBar** from 1.x branch.
136156

137-
From version 2.1.0 putting **PDFView** in **RelativeLayout** to use **ScrollHandle** is not required, you can use any layout.
157+
From version 2.1.0 putting **PDFView** in **RelativeLayout** to use **ScrollHandle** is not required, you can use any
158+
layout.
138159

139160
To use scroll handle just register it using method `Configurator#scrollHandle()`.
140161
This method accepts implementations of **ScrollHandle** interface.
141162

142163
There is default implementation shipped with AndroidPdfViewer, and you can use it with
143164
`.scrollHandle(new DefaultScrollHandle(this))`.
144-
**DefaultScrollHandle** is placed on the right (when scrolling vertically) or on the bottom (when scrolling horizontally).
165+
**DefaultScrollHandle** is placed on the right (when scrolling vertically) or on the bottom (when scrolling
166+
horizontally).
145167
By using constructor with second argument (`new DefaultScrollHandle(this, true)`), handle can be placed left or top.
146168

147169
You can also create custom scroll handles, just implement **ScrollHandle** interface.
148-
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).
170+
All methods are documented as Javadoc comments on
171+
interface [source](https://github.com/barteksc/AndroidPdfViewer/tree/master/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/scroll/ScrollHandle.java).
149172

150173
## Document sources
174+
151175
Version 2.3.0 introduced _document sources_, which are just providers for PDF documents.
152176
Every provider implements **DocumentSource** interface.
153177
Predefined providers are available in **com.github.barteksc.pdfviewer.source** package and can be used as
154178
samples for creating custom ones.
155179

156180
Predefined providers can be used with shorthand methods:
181+
157182
```
158183
pdfView.fromUri(Uri)
159184
pdfView.fromFile(File)
160185
pdfView.fromBytes(byte[])
161186
pdfView.fromStream(InputStream)
162187
pdfView.fromAsset(String)
163188
```
189+
164190
Custom providers may be used with `pdfView.fromSource(DocumentSource)` method.
165191

166192
## Links
193+
167194
Version 3.0.0 introduced support for links in PDF documents. By default, **DefaultLinkHandler**
168195
is used and clicking on link that references page in same document causes jump to destination page
169196
and clicking on link that targets some URI causes opening it in default application.
170197

171198
You can also create custom link handlers, just implement **LinkHandler** interface and set it using
172-
`Configurator#linkHandler(LinkHandler)` method. Take a look at [DefaultLinkHandler](https://github.com/barteksc/AndroidPdfViewer/tree/master/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/link/DefaultLinkHandler.java)
199+
`Configurator#linkHandler(LinkHandler)` method. Take a look
200+
at [DefaultLinkHandler](https://github.com/barteksc/AndroidPdfViewer/tree/master/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/link/DefaultLinkHandler.java)
173201
source to implement custom behavior.
174202

175203
## Pages fit policy
204+
176205
Since version 3.0.0, library supports fitting pages into the screen in 3 modes:
206+
177207
* WIDTH - width of widest page is equal to screen width
178208
* HEIGHT - height of highest page is equal to screen height
179209
* BOTH - based on widest and highest pages, every page is scaled to be fully visible on screen
@@ -185,10 +215,12 @@ Fit policy can be set using `Configurator#pageFitPolicy(FitPolicy)`. Default pol
185215
## Additional options
186216

187217
### Bitmap quality
218+
188219
By default, generated bitmaps are _compressed_ with `RGB_565` format to reduce memory consumption.
189220
Rendering with `ARGB_8888` can be forced by using `pdfView.useBestQuality(true)` method.
190221

191222
### Double tap zooming
223+
192224
There are three zoom levels: min (default 1), mid (default 1.75) and max (default 3). On first double tap,
193225
view is zoomed to mid level, on second to max level, and on third returns to min level.
194226
If you are between mid and max levels, double tapping causes zooming to max and so on.
@@ -202,24 +234,32 @@ void setMaxZoom(float zoom);
202234
```
203235

204236
## Possible questions
237+
205238
### Why resulting apk is so big?
239+
206240
Android PdfViewer depends on PdfiumAndroid, which is set of native libraries (almost 16 MB) for many architectures.
207241
Apk must contain all this libraries to run on every device available on market.
208242
Fortunately, Google Play allows us to upload multiple apks, e.g. one per every architecture.
209243
There is good article on automatically splitting your application into multiple apks,
210244
available [here](http://ph0b.com/android-studio-gradle-and-ndk-integration/).
211-
Most important section is _Improving multiple APKs creation and versionCode handling with APK Splits_, but whole article is worth reading.
245+
Most important section is _Improving multiple APKs creation and versionCode handling with APK Splits_, but whole article
246+
is worth reading.
212247
You only need to do this in your application, no need for forking PdfiumAndroid or so.
213248

214249
### Why I cannot open PDF from URL?
215-
Downloading files is long running process which must be aware of Activity lifecycle, must support some configuration,
250+
251+
Downloading files is long running process which must be aware of Activity lifecycle, must support some configuration,
216252
data cleanup and caching, so creating such module will probably end up as new library.
217253

218254
### How can I show last opened page after configuration change?
255+
219256
You have to store current page number and then set it with `pdfView.defaultPage(page)`, refer to sample app
220257

221258
### How can I fit document to screen width (eg. on orientation change)?
222-
Use `FitPolicy.WIDTH` policy or add following snippet when you want to fit desired page in document with different page sizes:
259+
260+
Use `FitPolicy.WIDTH` policy or add following snippet when you want to fit desired page in document with different page
261+
sizes:
262+
223263
``` java
224264
Configurator.onRender(new OnRenderListener() {
225265
@Override
@@ -230,7 +270,9 @@ Configurator.onRender(new OnRenderListener() {
230270
```
231271

232272
### How can I scroll through single pages like a ViewPager?
273+
233274
You can use a combination of the following settings to get scroll and fling behaviour similar to a ViewPager:
275+
234276
``` java
235277
.swipeHorizontal(true)
236278
.pageSnap(true)
@@ -239,11 +281,13 @@ You can use a combination of the following settings to get scroll and fling beha
239281
```
240282

241283
## One more thing
284+
242285
If you have any suggestions on making this lib better, write me, create issue or write some code and send pull request.
243286

244287
## License
245288

246289
Created with the help of android-pdfview by [Joan Zapata](http://joanzapata.com/)
290+
247291
```
248292
Copyright 2017 Bartosz Schiller
249293

0 commit comments

Comments
 (0)