react-native-pdf 7.0.1 → 7.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -168,6 +168,14 @@ react-native run-ios
|
|
|
168
168
|
### ChangeLog
|
|
169
169
|
<details>
|
|
170
170
|
<summary>ChangeLog details</summary>
|
|
171
|
+
v7.0.3
|
|
172
|
+
1. Fixed: RefObject types, and setPage not working in android (#985)
|
|
173
|
+
|
|
174
|
+
v7.0.2
|
|
175
|
+
1. Fixed: `Loaded page is null` error when `bookmarks` is 0 (#978)
|
|
176
|
+
2. Feature: agp 7.3+ fully supported (#980)
|
|
177
|
+
3. Fixed: Downgrade pdfiumandroid version to 1.0.32
|
|
178
|
+
|
|
171
179
|
v7.0.1
|
|
172
180
|
1. Fixed: not rendering on iOS
|
|
173
181
|
2. Added: Android 16 KB Page Size support
|
package/android/build.gradle
CHANGED
|
@@ -30,6 +30,19 @@ repositories {
|
|
|
30
30
|
|
|
31
31
|
apply plugin: 'com.android.library'
|
|
32
32
|
|
|
33
|
+
def supportsNamespace() {
|
|
34
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
35
|
+
def major = parsed[0].toInteger()
|
|
36
|
+
def minor = parsed[1].toInteger()
|
|
37
|
+
|
|
38
|
+
// Namespace support was added in 7.3.0
|
|
39
|
+
if (major == 7 && minor >= 3) {
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return major >= 8
|
|
44
|
+
}
|
|
45
|
+
|
|
33
46
|
def resolveReactNativeDirectory() {
|
|
34
47
|
def reactNativeLocation = safeExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
|
|
35
48
|
if (reactNativeLocation != null) {
|
|
@@ -80,9 +93,13 @@ if (isNewArchitectureEnabled()) {
|
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
android {
|
|
83
|
-
|
|
84
|
-
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
|
96
|
+
if (supportsNamespace()) {
|
|
85
97
|
namespace "org.wonday.pdf"
|
|
98
|
+
sourceSets {
|
|
99
|
+
main {
|
|
100
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
86
103
|
}
|
|
87
104
|
compileSdkVersion safeExtGet('compileSdkVersion', 31)
|
|
88
105
|
|
|
@@ -126,6 +143,6 @@ dependencies {
|
|
|
126
143
|
// The repo from zacharee is based on PdfiumAndroidKt, a much newer fork of PdfiumAndroid, with better maintenance and updated native libraries.
|
|
127
144
|
implementation 'com.github.zacharee:AndroidPdfViewer:4.0.1'
|
|
128
145
|
// Depend on PdfiumAndroidKt directly so this can be updated independently of AndroidPdfViewer as updates are provided.
|
|
129
|
-
implementation 'io.legere:pdfiumandroid:1.0.
|
|
146
|
+
implementation 'io.legere:pdfiumandroid:1.0.32'
|
|
130
147
|
implementation 'com.google.code.gson:gson:2.13.2'
|
|
131
148
|
}
|
|
@@ -89,10 +89,6 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
89
89
|
private int oldW = 0;
|
|
90
90
|
private int oldH = 0;
|
|
91
91
|
|
|
92
|
-
private int totalPages = 0;
|
|
93
|
-
private int[] pagesArrays;
|
|
94
|
-
private int bookmarks = 0;
|
|
95
|
-
|
|
96
92
|
public PdfView(Context context, AttributeSet set){
|
|
97
93
|
super(context, set);
|
|
98
94
|
}
|
|
@@ -251,7 +247,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
251
247
|
if (originalWidth == 0) {
|
|
252
248
|
originalWidth = pageWidth;
|
|
253
249
|
}
|
|
254
|
-
|
|
250
|
+
|
|
255
251
|
if (lastPageWidth>0 && lastPageHeight>0 && (pageWidth!=lastPageWidth || pageHeight!=lastPageHeight)) {
|
|
256
252
|
// maybe change by other instance, restore zoom setting
|
|
257
253
|
Constants.Pinch.MINIMUM_ZOOM = this.minScale;
|
|
@@ -287,36 +283,19 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
287
283
|
this.drawPdf();
|
|
288
284
|
}
|
|
289
285
|
|
|
286
|
+
private int getPdfPageCount(File pdfFile) throws IOException {
|
|
287
|
+
ParcelFileDescriptor fileDescriptor =
|
|
288
|
+
ParcelFileDescriptor.open(pdfFile, ParcelFileDescriptor.MODE_READ_ONLY);
|
|
289
|
+
PdfRenderer renderer = new PdfRenderer(fileDescriptor);
|
|
290
|
+
int pageCount = renderer.getPageCount();
|
|
291
|
+
renderer.close();
|
|
292
|
+
fileDescriptor.close();
|
|
293
|
+
return pageCount;
|
|
294
|
+
}
|
|
295
|
+
|
|
290
296
|
public void drawPdf() {
|
|
291
297
|
showLog(format("drawPdf path:%s %s", this.path, this.page));
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (file.exists()) {
|
|
295
|
-
try {
|
|
296
|
-
ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
|
|
297
|
-
PdfRenderer pdfRenderer = new PdfRenderer(fileDescriptor);
|
|
298
|
-
this.totalPages = pdfRenderer.getPageCount();
|
|
299
|
-
int[] pagesArrays = new int[this.totalPages];
|
|
300
|
-
if (this.enableRTL) {
|
|
301
|
-
if(this.page>0){
|
|
302
|
-
this.page= this.bookmarks-1;
|
|
303
|
-
}else{
|
|
304
|
-
this.page=this.totalPages;
|
|
305
|
-
}
|
|
306
|
-
for (int i = totalPages-1; i>=0; i--) {
|
|
307
|
-
pagesArrays[i] =totalPages-1- i;
|
|
308
|
-
}
|
|
309
|
-
this.pagesArrays = pagesArrays;
|
|
310
|
-
|
|
311
|
-
}else{
|
|
312
|
-
this.pagesArrays = null;
|
|
313
|
-
this.page=this.bookmarks-1;
|
|
314
|
-
}
|
|
315
|
-
} catch (IOException e) {
|
|
316
|
-
Log.e("error", "error read PDF", e);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
298
|
+
|
|
320
299
|
if (this.path != null){
|
|
321
300
|
|
|
322
301
|
// set scale
|
|
@@ -342,9 +321,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
342
321
|
configurator = this.fromUri(getURI(this.path));
|
|
343
322
|
}
|
|
344
323
|
|
|
345
|
-
configurator
|
|
346
|
-
.pages(this.pagesArrays)
|
|
347
|
-
.defaultPage(this.page)
|
|
324
|
+
configurator.defaultPage(this.page-1)
|
|
348
325
|
.swipeHorizontal(this.horizontal)
|
|
349
326
|
.onPageChange(this)
|
|
350
327
|
.onLoad(this)
|
|
@@ -361,7 +338,24 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
361
338
|
.enableSwipe(!this.singlePage && this.scrollEnabled)
|
|
362
339
|
.enableDoubletap(!this.singlePage && this.enableDoubleTapZoom)
|
|
363
340
|
.enableAnnotationRendering(this.enableAnnotationRendering)
|
|
364
|
-
.linkHandler(this)
|
|
341
|
+
.linkHandler(this)
|
|
342
|
+
;
|
|
343
|
+
|
|
344
|
+
if (enableRTL) {
|
|
345
|
+
try {
|
|
346
|
+
int pageCount = getPdfPageCount(new File(this.path));
|
|
347
|
+
int[] reversedPages = new int[pageCount];
|
|
348
|
+
for (int i=0; i<pageCount; i++) {
|
|
349
|
+
reversedPages[i] = pageCount-1 - i;
|
|
350
|
+
}
|
|
351
|
+
configurator.pages(reversedPages);
|
|
352
|
+
if(this.page != 1){
|
|
353
|
+
this.page = pageCount;
|
|
354
|
+
}
|
|
355
|
+
} catch (IOException e) {
|
|
356
|
+
Log.e("error", "error while reading PDF", e);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
365
359
|
|
|
366
360
|
if (this.singlePage) {
|
|
367
361
|
configurator.pages(this.page-1);
|
|
@@ -384,14 +378,13 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
384
378
|
|
|
385
379
|
// page start from 1
|
|
386
380
|
public void setPage(int page) {
|
|
387
|
-
this.page = page;
|
|
388
|
-
this.
|
|
381
|
+
this.page = Math.max(page, 1);
|
|
382
|
+
this.handlePage(this.page - 1);
|
|
389
383
|
}
|
|
390
384
|
|
|
391
|
-
public void setEnableRTL(boolean enableRTL){
|
|
392
|
-
this.enableRTL= enableRTL;
|
|
393
|
-
|
|
394
|
-
}
|
|
385
|
+
public void setEnableRTL(boolean enableRTL) {
|
|
386
|
+
this.enableRTL = enableRTL;
|
|
387
|
+
}
|
|
395
388
|
|
|
396
389
|
public void setScale(float scale) {
|
|
397
390
|
this.scale = scale;
|
package/index.d.ts
CHANGED
|
@@ -65,6 +65,10 @@ export interface PdfProps {
|
|
|
65
65
|
onPressLink?: (url: string) => void,
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
export interface PdfRef {
|
|
69
|
+
setPage(pageNumber: number): void
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare const Pdf: React.ForwardRefExoticComponent<PdfProps & React.RefAttributes<PdfRef>>
|
|
69
73
|
|
|
70
74
|
export default Pdf;
|