@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 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.
@@ -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
- import expo.modules.kotlin.Promise
6
- import expo.modules.kotlin.records.Field
7
- import expo.modules.kotlin.records.Record
8
-
9
- class AnnotationData : Record {
10
- @Field
11
- var type: String = "pen"
12
- @Field
13
- var color: String = "#000000"
14
- @Field
15
- var page: Int = 0
16
- @Field
17
- var points: List<List<Map<String, Double>>> = emptyList()
18
- @Field
19
- var width: Double = 10.0
20
- @Field
21
- var text: String = ""
22
- @Field
23
- var fontSize: Double = 16.0
24
- @Field
25
- var x: Double = 0.0
26
- @Field
27
- var y: Double = 0.0
28
- }
29
-
30
- class SearchResultData : Record {
31
- @Field
32
- var page: Int = 0
33
- @Field
34
- var x: Double = 0.0
35
- @Field
36
- var y: Double = 0.0
37
- @Field
38
- var width: Double = 0.0
39
- @Field
40
- var height: Double = 0.0
41
- @Field
42
- var textSnippet: String = ""
43
- }
44
-
45
- class ExpoPdfReaderModule : Module() {
46
- override fun definition() = ModuleDefinition {
47
- Name("ExpoPdfReader")
48
-
49
- View(ExpoPdfReaderView::class) {
50
- Events("onAnnotationChange", "onPageChange", "onScroll")
51
-
52
- Prop("url") { view: ExpoPdfReaderView, url: String ->
53
- view.setUrl(url)
54
- }
55
-
56
- Prop("displayMode") { view: ExpoPdfReaderView, mode: String ->
57
- view.setDisplayMode(mode)
58
- }
59
-
60
- Prop("initialPage") { view: ExpoPdfReaderView, page: Int ->
61
- view.setInitialPage(page)
62
- }
63
-
64
- Prop("minZoom") { view: ExpoPdfReaderView, value: Double ->
65
- view.setMinZoom(value)
66
- }
67
-
68
- Prop("maxZoom") { view: ExpoPdfReaderView, value: Double ->
69
- view.setMaxZoom(value)
70
- }
71
-
72
- Prop("annotationTool") { view: ExpoPdfReaderView, tool: String ->
73
- view.setAnnotationTool(tool)
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
+ }