@june24/expo-pdf-reader 0.1.13 → 0.1.18
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 +50 -50
- package/android/build.gradle +23 -23
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/expo/modules/pdfreader/ExpoPdfReaderModule.kt +74 -202
- package/android/src/main/java/expo/modules/pdfreader/ExpoPdfReaderView.kt +954 -934
- package/build/ExpoPdfReader.types.d.ts +77 -70
- package/build/ExpoPdfReader.types.d.ts.map +1 -1
- package/build/ExpoPdfReader.types.js.map +1 -1
- package/build/ExpoPdfReaderView.d.ts +3 -26
- package/build/ExpoPdfReaderView.d.ts.map +1 -1
- package/build/ExpoPdfReaderView.js +4 -102
- package/build/ExpoPdfReaderView.js.map +1 -1
- package/build/index.d.ts +4 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/expo-module.config.json +16 -16
- package/ios/ExpoPdfReader.podspec +27 -27
- package/ios/ExpoPdfReaderModule.swift +69 -170
- package/ios/ExpoPdfReaderView.swift +1048 -862
- package/package.json +39 -39
- package/src/ExpoPdfReader.types.ts +49 -99
- package/src/ExpoPdfReaderView.tsx +17 -136
- package/src/index.ts +12 -7
- package/tsconfig.json +9 -9
package/README.md
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
# expo-pdf-reader
|
|
2
|
-
|
|
3
|
-
A PDF reader for Expo.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install expo-pdf-reader
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { StyleSheet, View } from 'react-native';
|
|
15
|
-
import { ExpoPdfReaderView } from 'expo-pdf-reader';
|
|
16
|
-
|
|
17
|
-
export default function App() {
|
|
18
|
-
return (
|
|
19
|
-
<View style={styles.container}>
|
|
20
|
-
<ExpoPdfReaderView
|
|
21
|
-
style={styles.pdf}
|
|
22
|
-
url="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
|
|
23
|
-
/>
|
|
24
|
-
</View>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const styles = StyleSheet.create({
|
|
29
|
-
container: {
|
|
30
|
-
flex: 1,
|
|
31
|
-
backgroundColor: '#fff',
|
|
32
|
-
alignItems: 'center',
|
|
33
|
-
justifyContent: 'center',
|
|
34
|
-
},
|
|
35
|
-
pdf: {
|
|
36
|
-
flex: 1,
|
|
37
|
-
width: '100%',
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Configuration
|
|
43
|
-
|
|
44
|
-
### Android
|
|
45
|
-
|
|
46
|
-
No additional configuration required.
|
|
47
|
-
|
|
48
|
-
### iOS
|
|
49
|
-
|
|
50
|
-
No additional configuration required.
|
|
1
|
+
# expo-pdf-reader
|
|
2
|
+
|
|
3
|
+
A PDF reader for Expo.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install expo-pdf-reader
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { StyleSheet, View } from 'react-native';
|
|
15
|
+
import { ExpoPdfReaderView } from 'expo-pdf-reader';
|
|
16
|
+
|
|
17
|
+
export default function App() {
|
|
18
|
+
return (
|
|
19
|
+
<View style={styles.container}>
|
|
20
|
+
<ExpoPdfReaderView
|
|
21
|
+
style={styles.pdf}
|
|
22
|
+
url="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
|
|
23
|
+
/>
|
|
24
|
+
</View>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
container: {
|
|
30
|
+
flex: 1,
|
|
31
|
+
backgroundColor: '#fff',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
},
|
|
35
|
+
pdf: {
|
|
36
|
+
flex: 1,
|
|
37
|
+
width: '100%',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
### Android
|
|
45
|
+
|
|
46
|
+
No additional configuration required.
|
|
47
|
+
|
|
48
|
+
### iOS
|
|
49
|
+
|
|
50
|
+
No additional configuration required.
|
package/android/build.gradle
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
apply plugin: 'com.android.library'
|
|
2
|
-
apply plugin: 'kotlin-android'
|
|
3
|
-
|
|
4
|
-
group = 'expo.modules.pdfreader'
|
|
5
|
-
version = '0.1.1'
|
|
6
|
-
|
|
7
|
-
android {
|
|
8
|
-
compileSdkVersion 36
|
|
9
|
-
defaultConfig {
|
|
10
|
-
minSdkVersion 24
|
|
11
|
-
targetSdkVersion 36
|
|
12
|
-
versionCode 1
|
|
13
|
-
versionName "0.1.1"
|
|
14
|
-
}
|
|
15
|
-
lintOptions {
|
|
16
|
-
abortOnError false
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
dependencies {
|
|
21
|
-
implementation project(':expo-modules-core')
|
|
22
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.2.0"
|
|
23
|
-
}
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
3
|
+
|
|
4
|
+
group = 'expo.modules.pdfreader'
|
|
5
|
+
version = '0.1.1'
|
|
6
|
+
|
|
7
|
+
android {
|
|
8
|
+
compileSdkVersion 36
|
|
9
|
+
defaultConfig {
|
|
10
|
+
minSdkVersion 24
|
|
11
|
+
targetSdkVersion 36
|
|
12
|
+
versionCode 1
|
|
13
|
+
versionName "0.1.1"
|
|
14
|
+
}
|
|
15
|
+
lintOptions {
|
|
16
|
+
abortOnError false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
dependencies {
|
|
21
|
+
implementation project(':expo-modules-core')
|
|
22
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.2.0"
|
|
23
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<manifest package="expo.modules.pdfreader">
|
|
2
|
-
</manifest>
|
|
1
|
+
<manifest package="expo.modules.pdfreader">
|
|
2
|
+
</manifest>
|
|
@@ -1,202 +1,74 @@
|
|
|
1
|
-
package expo.modules.pdfreader
|
|
2
|
-
|
|
3
|
-
import expo.modules.kotlin.modules.Module
|
|
4
|
-
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
view.
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Prop("annotationColor") { view: ExpoPdfReaderView, color: String? ->
|
|
77
|
-
view.setAnnotationColor(color)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
Prop("annotationFontSize") { view: ExpoPdfReaderView, size: Double ->
|
|
81
|
-
view.setAnnotationFontSize(size)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
Prop("annotationText") { view: ExpoPdfReaderView, text: String ->
|
|
85
|
-
view.setAnnotationText(text)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
Prop("annotationStrokeWidth") { view: ExpoPdfReaderView, width: Double ->
|
|
89
|
-
view.setAnnotationStrokeWidth(width)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
Prop("initialAnnotations") { view: ExpoPdfReaderView, annotations: List<AnnotationData> ->
|
|
93
|
-
view.setAnnotations(annotations)
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
AsyncFunction("save") { viewTag: Int, promise: Promise ->
|
|
98
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
99
|
-
if (view == null) {
|
|
100
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
101
|
-
return@AsyncFunction
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
val path = view.savePdf()
|
|
106
|
-
promise.resolve(path)
|
|
107
|
-
} catch (e: Exception) {
|
|
108
|
-
promise.reject("ERR_SAVE_FAILED", "Failed to save PDF: ${e.message}", e)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
AsyncFunction("getAnnotations") { viewTag: Int, promise: Promise ->
|
|
113
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
114
|
-
if (view == null) {
|
|
115
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
116
|
-
return@AsyncFunction
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
promise.resolve(view.getAnnotations())
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
AsyncFunction("searchText") { viewTag: Int, text: String, promise: Promise ->
|
|
123
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
124
|
-
if (view == null) {
|
|
125
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
126
|
-
return@AsyncFunction
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
promise.resolve(view.searchText(text))
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
AsyncFunction("goToPage") { viewTag: Int, page: Int, promise: Promise ->
|
|
133
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
134
|
-
if (view == null) {
|
|
135
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
136
|
-
return@AsyncFunction
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
view.goToPage(page)
|
|
140
|
-
promise.resolve(null)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
AsyncFunction("undo") { viewTag: Int, promise: Promise ->
|
|
144
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
145
|
-
if (view == null) {
|
|
146
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
147
|
-
return@AsyncFunction
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
val success = view.undo()
|
|
151
|
-
promise.resolve(success)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
AsyncFunction("redo") { viewTag: Int, promise: Promise ->
|
|
155
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
156
|
-
if (view == null) {
|
|
157
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
158
|
-
return@AsyncFunction
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
val success = view.redo()
|
|
162
|
-
promise.resolve(success)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
AsyncFunction("zoomIn") { viewTag: Int, promise: Promise ->
|
|
166
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
167
|
-
if (view == null) {
|
|
168
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
169
|
-
return@AsyncFunction
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
val changed = view.zoomIn()
|
|
173
|
-
promise.resolve(changed)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
AsyncFunction("zoomOut") { viewTag: Int, promise: Promise ->
|
|
177
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
178
|
-
if (view == null) {
|
|
179
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
180
|
-
return@AsyncFunction
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
val changed = view.zoomOut()
|
|
184
|
-
promise.resolve(changed)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
AsyncFunction("renderThumbnail") { viewTag: Int, page: Int, width: Int, promise: Promise ->
|
|
188
|
-
val view = appContext.findView<ExpoPdfReaderView>(viewTag)
|
|
189
|
-
if (view == null) {
|
|
190
|
-
promise.reject("ERR_VIEW_NOT_FOUND", "Could not find view with tag $viewTag", null)
|
|
191
|
-
return@AsyncFunction
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
try {
|
|
195
|
-
val path = view.renderThumbnail(page, width)
|
|
196
|
-
promise.resolve(path)
|
|
197
|
-
} catch (e: Exception) {
|
|
198
|
-
promise.reject("ERR_THUMBNAIL_FAILED", "Failed to render thumbnail: ${e.message}", e)
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
1
|
+
package expo.modules.pdfreader
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
|
|
6
|
+
class ExpoPdfReaderModule : Module() {
|
|
7
|
+
override fun definition() = ModuleDefinition {
|
|
8
|
+
Name("ExpoPdfReader")
|
|
9
|
+
|
|
10
|
+
View(ExpoPdfReaderView::class) {
|
|
11
|
+
Events("onPageChange", "onAnnotationChange", "onUndoRedoStateChange", "onNotePress", "onTextPress")
|
|
12
|
+
|
|
13
|
+
Prop("url") { view: ExpoPdfReaderView, url: String? ->
|
|
14
|
+
view.setUrl(url)
|
|
15
|
+
}
|
|
16
|
+
Prop("displayMode") { view: ExpoPdfReaderView, mode: String ->
|
|
17
|
+
view.setDisplayMode(mode)
|
|
18
|
+
}
|
|
19
|
+
Prop("initialPage") { view: ExpoPdfReaderView, page: Int ->
|
|
20
|
+
view.setInitialPage(page)
|
|
21
|
+
}
|
|
22
|
+
Prop("tool") { view: ExpoPdfReaderView, tool: String? ->
|
|
23
|
+
view.setTool(tool)
|
|
24
|
+
}
|
|
25
|
+
Prop("strokeColor") { view: ExpoPdfReaderView, color: String ->
|
|
26
|
+
view.setStrokeColor(color)
|
|
27
|
+
}
|
|
28
|
+
Prop("strokeWidth") { view: ExpoPdfReaderView, width: Double ->
|
|
29
|
+
view.setStrokeWidth(width.toFloat())
|
|
30
|
+
}
|
|
31
|
+
Prop("textContent") { view: ExpoPdfReaderView, text: String ->
|
|
32
|
+
view.setTextContent(text)
|
|
33
|
+
}
|
|
34
|
+
Prop("textColor") { view: ExpoPdfReaderView, color: String ->
|
|
35
|
+
view.setTextColor(color)
|
|
36
|
+
}
|
|
37
|
+
Prop("textFontSize") { view: ExpoPdfReaderView, size: Double ->
|
|
38
|
+
view.setTextFontSize(size.toFloat())
|
|
39
|
+
}
|
|
40
|
+
// ЗАСВАР: Bool -> Boolean
|
|
41
|
+
Prop("textBold") { view: ExpoPdfReaderView, value: Boolean ->
|
|
42
|
+
view.setTextBold(value)
|
|
43
|
+
}
|
|
44
|
+
// ЗАСВАР: Bool -> Boolean
|
|
45
|
+
Prop("textItalic") { view: ExpoPdfReaderView, value: Boolean ->
|
|
46
|
+
view.setTextItalic(value)
|
|
47
|
+
}
|
|
48
|
+
Prop("noteColor") { view: ExpoPdfReaderView, color: String ->
|
|
49
|
+
view.setNoteColor(color)
|
|
50
|
+
}
|
|
51
|
+
Prop("initialAnnotations") { view: ExpoPdfReaderView, annotations: List<Map<String, Any>>? ->
|
|
52
|
+
if (annotations != null) {
|
|
53
|
+
view.setInitialAnnotations(annotations)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
AsyncFunction("undo") { view: ExpoPdfReaderView ->
|
|
58
|
+
view.undo()
|
|
59
|
+
}
|
|
60
|
+
AsyncFunction("redo") { view: ExpoPdfReaderView ->
|
|
61
|
+
view.redo()
|
|
62
|
+
}
|
|
63
|
+
AsyncFunction("setInitialPage") { view: ExpoPdfReaderView, page: Int ->
|
|
64
|
+
view.setInitialPage(page)
|
|
65
|
+
}
|
|
66
|
+
AsyncFunction("updateNote") { view: ExpoPdfReaderView, page: Int, index: Int, contents: String ->
|
|
67
|
+
view.updateNote(page, index, contents)
|
|
68
|
+
}
|
|
69
|
+
AsyncFunction("updateText") { view: ExpoPdfReaderView, page: Int, index: Int, contents: String ->
|
|
70
|
+
view.updateText(page, index, contents)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|