@papyrus-sdk/engine-native 0.2.10 → 0.2.11

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Papyrus Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,38 +1,38 @@
1
- # Papyrus Engine Native
2
-
3
- React Native native engine for PDF rendering (PDFKit on iOS, PDFium on Android),
4
- plus a WebView runtime for EPUB/TXT via `MobileDocumentEngine`.
5
-
6
- ## Install
7
-
8
- ```bash
9
- npm install @papyrus-sdk/engine-native @papyrus-sdk/core @papyrus-sdk/types
10
- ```
11
-
12
- `@papyrus-sdk/core` and `@papyrus-sdk/types` are required peer dependencies.
13
-
14
- For EPUB/TXT on mobile, also install:
15
-
16
- ```bash
17
- npm install react-native-webview
18
- ```
19
-
20
- ## Usage
21
-
22
- ```ts
23
- import { MobileDocumentEngine, PapyrusPageView } from '@papyrus-sdk/engine-native';
24
- import { findNodeHandle } from 'react-native';
25
-
26
- const engine = new MobileDocumentEngine();
27
- await engine.load({ type: 'pdf', source: { uri: 'https://example.com/book.pdf' } });
28
-
29
- // Render the first page into a native view
30
- const viewTag = findNodeHandle(pageViewRef.current);
31
- if (viewTag) {
32
- await engine.renderPage(0, viewTag, 2);
33
- }
34
- ```
35
-
36
- Notes:
37
- - Requires a native build (not Expo Go).
38
- - Use `PapyrusPageView` for native PDF rendering.
1
+ # Papyrus Engine Native
2
+
3
+ React Native native engine for PDF rendering (PDFKit on iOS, PDFium on Android),
4
+ plus a WebView runtime for EPUB/TXT via `MobileDocumentEngine`.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ npm install @papyrus-sdk/engine-native @papyrus-sdk/core @papyrus-sdk/types
10
+ ```
11
+
12
+ `@papyrus-sdk/core` and `@papyrus-sdk/types` are required peer dependencies.
13
+
14
+ For EPUB/TXT on mobile, also install:
15
+
16
+ ```bash
17
+ npm install react-native-webview
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```ts
23
+ import { MobileDocumentEngine, PapyrusPageView } from '@papyrus-sdk/engine-native';
24
+ import { findNodeHandle } from 'react-native';
25
+
26
+ const engine = new MobileDocumentEngine();
27
+ await engine.load({ type: 'pdf', source: { uri: 'https://example.com/book.pdf' } });
28
+
29
+ // Render the first page into a native view
30
+ const viewTag = findNodeHandle(pageViewRef.current);
31
+ if (viewTag) {
32
+ await engine.renderPage(0, viewTag, 2);
33
+ }
34
+ ```
35
+
36
+ Notes:
37
+ - Requires a native build (not Expo Go).
38
+ - Use `PapyrusPageView` for native PDF rendering.
@@ -1,42 +1,42 @@
1
- apply plugin: 'com.android.library'
2
-
3
- def safeExtGet(prop, fallback) {
4
- return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5
- }
6
-
7
- android {
8
- compileSdkVersion safeExtGet('compileSdkVersion', 35)
9
- ndkVersion safeExtGet('ndkVersion', '26.1.10909125')
10
- namespace 'com.papyrus.engine'
11
-
12
- defaultConfig {
13
- minSdkVersion safeExtGet('minSdkVersion', 21)
14
- targetSdkVersion safeExtGet('targetSdkVersion', 35)
15
- consumerProguardFiles 'consumer-rules.pro'
16
- externalNativeBuild {
17
- cmake {
18
- cppFlags "-std=c++17"
19
- }
20
- }
21
- }
22
-
23
- sourceSets {
24
- main {
25
- java.srcDirs = ['src/main/java']
26
- }
27
- }
28
-
29
- externalNativeBuild {
30
- cmake {
31
- path "src/main/cpp/CMakeLists.txt"
32
- }
33
- }
34
- }
35
-
36
- dependencies {
37
- implementation 'com.facebook.react:react-android'
38
- implementation('io.github.oothp:pdfium-android:1.9.5-beta01') {
39
- exclude group: 'com.android.support'
40
- }
41
- testImplementation 'junit:junit:4.13.2'
1
+ apply plugin: 'com.android.library'
2
+
3
+ def safeExtGet(prop, fallback) {
4
+ return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5
+ }
6
+
7
+ android {
8
+ compileSdkVersion safeExtGet('compileSdkVersion', 35)
9
+ ndkVersion safeExtGet('ndkVersion', '26.1.10909125')
10
+ namespace 'com.papyrus.engine'
11
+
12
+ defaultConfig {
13
+ minSdkVersion safeExtGet('minSdkVersion', 21)
14
+ targetSdkVersion safeExtGet('targetSdkVersion', 35)
15
+ consumerProguardFiles 'consumer-rules.pro'
16
+ externalNativeBuild {
17
+ cmake {
18
+ cppFlags "-std=c++17"
19
+ }
20
+ }
21
+ }
22
+
23
+ sourceSets {
24
+ main {
25
+ java.srcDirs = ['src/main/java']
26
+ }
27
+ }
28
+
29
+ externalNativeBuild {
30
+ cmake {
31
+ path "src/main/cpp/CMakeLists.txt"
32
+ }
33
+ }
34
+ }
35
+
36
+ dependencies {
37
+ implementation 'com.facebook.react:react-android'
38
+ implementation('io.github.oothp:pdfium-android:1.9.5-beta01') {
39
+ exclude group: 'com.android.support'
40
+ }
41
+ testImplementation 'junit:junit:4.13.2'
42
42
  }
@@ -1 +1 @@
1
- # Keep rules can be added here if needed.
1
+ # Keep rules can be added here if needed.
@@ -1,45 +1,45 @@
1
- cmake_minimum_required(VERSION 3.18.1)
2
- project(papyrus_text)
3
-
4
- option(PAPYRUS_OUTLINE_HOST_TESTS "Build host tests for the outline loader" OFF)
5
-
6
- function(papyrus_set_cxx17 target_name)
7
- set_target_properties(${target_name} PROPERTIES
8
- CXX_STANDARD 17
9
- CXX_STANDARD_REQUIRED YES
10
- )
11
- endfunction()
12
-
13
- if(ANDROID)
14
- add_library(papyrus_text SHARED
15
- papyrus_text_search.cpp
16
- papyrus_outline.cpp
17
- papyrus_outline_loader.cpp
18
- )
19
-
20
- papyrus_set_cxx17(papyrus_text)
21
- target_compile_options(papyrus_text PRIVATE -Wall -Werror)
22
- target_link_options(papyrus_text PRIVATE "-Wl,-z,max-page-size=16384")
23
-
24
- find_library(log-lib log)
25
- find_library(android-lib android)
26
- find_library(dl-lib dl)
27
-
28
- target_link_libraries(papyrus_text
29
- ${log-lib}
30
- ${android-lib}
31
- ${dl-lib}
32
- )
33
- endif()
34
-
35
- if(PAPYRUS_OUTLINE_HOST_TESTS)
36
- enable_testing()
37
-
38
- add_executable(papyrus_outline_loader_test
39
- papyrus_outline_loader.cpp
40
- papyrus_outline_loader_test.cpp
41
- )
42
-
43
- papyrus_set_cxx17(papyrus_outline_loader_test)
44
- add_test(NAME papyrus_outline_loader_test COMMAND papyrus_outline_loader_test)
1
+ cmake_minimum_required(VERSION 3.18.1)
2
+ project(papyrus_text)
3
+
4
+ option(PAPYRUS_OUTLINE_HOST_TESTS "Build host tests for the outline loader" OFF)
5
+
6
+ function(papyrus_set_cxx17 target_name)
7
+ set_target_properties(${target_name} PROPERTIES
8
+ CXX_STANDARD 17
9
+ CXX_STANDARD_REQUIRED YES
10
+ )
11
+ endfunction()
12
+
13
+ if(ANDROID)
14
+ add_library(papyrus_text SHARED
15
+ papyrus_text_search.cpp
16
+ papyrus_outline.cpp
17
+ papyrus_outline_loader.cpp
18
+ )
19
+
20
+ papyrus_set_cxx17(papyrus_text)
21
+ target_compile_options(papyrus_text PRIVATE -Wall -Werror)
22
+ target_link_options(papyrus_text PRIVATE "-Wl,-z,max-page-size=16384")
23
+
24
+ find_library(log-lib log)
25
+ find_library(android-lib android)
26
+ find_library(dl-lib dl)
27
+
28
+ target_link_libraries(papyrus_text
29
+ ${log-lib}
30
+ ${android-lib}
31
+ ${dl-lib}
32
+ )
33
+ endif()
34
+
35
+ if(PAPYRUS_OUTLINE_HOST_TESTS)
36
+ enable_testing()
37
+
38
+ add_executable(papyrus_outline_loader_test
39
+ papyrus_outline_loader.cpp
40
+ papyrus_outline_loader_test.cpp
41
+ )
42
+
43
+ papyrus_set_cxx17(papyrus_outline_loader_test)
44
+ add_test(NAME papyrus_outline_loader_test COMMAND papyrus_outline_loader_test)
45
45
  endif()
@@ -1,173 +1,173 @@
1
- #include "papyrus_outline_loader.h"
2
-
3
- #include <jni.h>
4
- #include <android/log.h>
5
- #include <dlfcn.h>
6
-
7
- #include <cstring>
8
- #include <vector>
9
-
10
- #define LOG_TAG "PapyrusOutline"
11
- #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
12
-
13
- namespace {
14
-
15
- OutlineLoaderState g_outline_loader = {};
16
-
17
- void *OutlineDlopen(void *, const char *filename, int flags) {
18
- return dlopen(filename, flags);
19
- }
20
-
21
- OutlineLoaderDeps::PdfiumSymbol OutlineDlsym(void *, void *handle, const char *symbol_name) {
22
- void *raw_symbol = dlsym(handle, symbol_name);
23
- OutlineLoaderDeps::PdfiumSymbol symbol = nullptr;
24
- static_assert(sizeof(symbol) == sizeof(raw_symbol),
25
- "Expected dlsym results to match function pointer size");
26
- std::memcpy(&symbol, &raw_symbol, sizeof(symbol));
27
- return symbol;
28
- }
29
-
30
- int OutlineDlclose(void *, void *handle) {
31
- return dlclose(handle);
32
- }
33
-
34
- const OutlineLoaderDeps kOutlineLoaderDeps = {
35
- nullptr,
36
- &OutlineDlopen,
37
- &OutlineDlsym,
38
- &OutlineDlclose,
39
- "libmodpdfium.so",
40
- RTLD_LAZY,
41
- };
42
-
43
- bool LoadPdfium() {
44
- const OutlineLoadAttemptResult result =
45
- EnsureOutlinePdfiumLoaded(&g_outline_loader, &kOutlineLoaderDeps);
46
- if (!result.loaded && result.transitioned_to_unsupported) {
47
- LOGE("Failed to load required PDFium symbols for outline");
48
- }
49
- return result.loaded;
50
- }
51
-
52
- PdfiumOutlineFns &OutlineFns() {
53
- return g_outline_loader.fns;
54
- }
55
-
56
- jstring GetBookmarkTitle(JNIEnv *env, FPDF_BOOKMARK bookmark) {
57
- unsigned long length = OutlineFns().bookmarkGetTitle(bookmark, nullptr, 0);
58
- if (length <= 2) {
59
- return env->NewStringUTF("");
60
- }
61
-
62
- std::vector<unsigned short> buffer((length / 2) + 1, 0);
63
- unsigned long written = OutlineFns().bookmarkGetTitle(bookmark, buffer.data(), length);
64
- int chars = written > 0 ? static_cast<int>(written / 2) - 1
65
- : static_cast<int>(length / 2) - 1;
66
- if (chars <= 0) {
67
- return env->NewStringUTF("");
68
- }
69
-
70
- return env->NewString(reinterpret_cast<const jchar *>(buffer.data()), chars);
71
- }
72
-
73
- jobjectArray BuildOutlineItems(JNIEnv *env,
74
- FPDF_DOCUMENT doc,
75
- FPDF_BOOKMARK parent,
76
- jclass item_class,
77
- jmethodID ctor) {
78
- std::vector<jobject> items;
79
-
80
- for (FPDF_BOOKMARK child = OutlineFns().bookmarkGetFirstChild(doc, parent); child;
81
- child = OutlineFns().bookmarkGetNextSibling(doc, child)) {
82
- jstring title = GetBookmarkTitle(env, child);
83
- int page_index = -1;
84
- FPDF_DEST dest = OutlineFns().bookmarkGetDest(doc, child);
85
- if (dest != nullptr) {
86
- page_index = OutlineFns().destGetPageIndex(doc, dest);
87
- }
88
-
89
- jobjectArray children = BuildOutlineItems(env, doc, child, item_class, ctor);
90
- jobject item = env->NewObject(item_class, ctor, title, page_index, children);
91
-
92
- if (title != nullptr) {
93
- env->DeleteLocalRef(title);
94
- }
95
- if (children != nullptr) {
96
- env->DeleteLocalRef(children);
97
- }
98
-
99
- if (item != nullptr) {
100
- items.push_back(item);
101
- }
102
- }
103
-
104
- jobjectArray array =
105
- env->NewObjectArray(static_cast<jsize>(items.size()), item_class, nullptr);
106
- for (jsize i = 0; i < static_cast<jsize>(items.size()); i++) {
107
- env->SetObjectArrayElement(array, i, items[i]);
108
- }
109
-
110
- return array;
111
- }
112
-
113
- jobjectArray BuildOutline(JNIEnv *env, FPDF_DOCUMENT doc) {
114
- jclass item_class = env->FindClass("com/papyrus/engine/PapyrusOutlineItem");
115
- if (item_class == nullptr) {
116
- return nullptr;
117
- }
118
-
119
- jmethodID ctor = env->GetMethodID(
120
- item_class, "<init>", "(Ljava/lang/String;I[Lcom/papyrus/engine/PapyrusOutlineItem;)V");
121
- if (ctor == nullptr) {
122
- return nullptr;
123
- }
124
-
125
- return BuildOutlineItems(env, doc, nullptr, item_class, ctor);
126
- }
127
-
128
- } // namespace
129
-
130
- extern "C" JNIEXPORT jboolean JNICALL
131
- Java_com_papyrus_engine_PapyrusOutline_nativeIsOutlineSupported(JNIEnv *, jclass) {
132
- return LoadPdfium() ? JNI_TRUE : JNI_FALSE;
133
- }
134
-
135
- extern "C" JNIEXPORT jobjectArray JNICALL
136
- Java_com_papyrus_engine_PapyrusOutline_nativeGetOutline(JNIEnv *env, jclass, jlong docPtr) {
137
- if (!LoadPdfium()) {
138
- return nullptr;
139
- }
140
- if (!docPtr) {
141
- return nullptr;
142
- }
143
-
144
- FPDF_DOCUMENT doc = reinterpret_cast<FPDF_DOCUMENT>(docPtr);
145
- return BuildOutline(env, doc);
146
- }
147
-
148
- extern "C" JNIEXPORT jobjectArray JNICALL
149
- Java_com_papyrus_engine_PapyrusOutline_nativeGetOutlineFile(JNIEnv *env,
150
- jclass,
151
- jstring filePath) {
152
- if (!LoadPdfium()) {
153
- return nullptr;
154
- }
155
- if (filePath == nullptr) {
156
- return nullptr;
157
- }
158
-
159
- const char *path = env->GetStringUTFChars(filePath, nullptr);
160
- if (path == nullptr) {
161
- return nullptr;
162
- }
163
-
164
- FPDF_DOCUMENT doc = OutlineFns().loadDocument(path, nullptr);
165
- env->ReleaseStringUTFChars(filePath, path);
166
- if (doc == nullptr) {
167
- return nullptr;
168
- }
169
-
170
- jobjectArray result = BuildOutline(env, doc);
171
- OutlineFns().closeDocument(doc);
172
- return result;
1
+ #include "papyrus_outline_loader.h"
2
+
3
+ #include <jni.h>
4
+ #include <android/log.h>
5
+ #include <dlfcn.h>
6
+
7
+ #include <cstring>
8
+ #include <vector>
9
+
10
+ #define LOG_TAG "PapyrusOutline"
11
+ #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
12
+
13
+ namespace {
14
+
15
+ OutlineLoaderState g_outline_loader = {};
16
+
17
+ void *OutlineDlopen(void *, const char *filename, int flags) {
18
+ return dlopen(filename, flags);
19
+ }
20
+
21
+ OutlineLoaderDeps::PdfiumSymbol OutlineDlsym(void *, void *handle, const char *symbol_name) {
22
+ void *raw_symbol = dlsym(handle, symbol_name);
23
+ OutlineLoaderDeps::PdfiumSymbol symbol = nullptr;
24
+ static_assert(sizeof(symbol) == sizeof(raw_symbol),
25
+ "Expected dlsym results to match function pointer size");
26
+ std::memcpy(&symbol, &raw_symbol, sizeof(symbol));
27
+ return symbol;
28
+ }
29
+
30
+ int OutlineDlclose(void *, void *handle) {
31
+ return dlclose(handle);
32
+ }
33
+
34
+ const OutlineLoaderDeps kOutlineLoaderDeps = {
35
+ nullptr,
36
+ &OutlineDlopen,
37
+ &OutlineDlsym,
38
+ &OutlineDlclose,
39
+ "libmodpdfium.so",
40
+ RTLD_LAZY,
41
+ };
42
+
43
+ bool LoadPdfium() {
44
+ const OutlineLoadAttemptResult result =
45
+ EnsureOutlinePdfiumLoaded(&g_outline_loader, &kOutlineLoaderDeps);
46
+ if (!result.loaded && result.transitioned_to_unsupported) {
47
+ LOGE("Failed to load required PDFium symbols for outline");
48
+ }
49
+ return result.loaded;
50
+ }
51
+
52
+ PdfiumOutlineFns &OutlineFns() {
53
+ return g_outline_loader.fns;
54
+ }
55
+
56
+ jstring GetBookmarkTitle(JNIEnv *env, FPDF_BOOKMARK bookmark) {
57
+ unsigned long length = OutlineFns().bookmarkGetTitle(bookmark, nullptr, 0);
58
+ if (length <= 2) {
59
+ return env->NewStringUTF("");
60
+ }
61
+
62
+ std::vector<unsigned short> buffer((length / 2) + 1, 0);
63
+ unsigned long written = OutlineFns().bookmarkGetTitle(bookmark, buffer.data(), length);
64
+ int chars = written > 0 ? static_cast<int>(written / 2) - 1
65
+ : static_cast<int>(length / 2) - 1;
66
+ if (chars <= 0) {
67
+ return env->NewStringUTF("");
68
+ }
69
+
70
+ return env->NewString(reinterpret_cast<const jchar *>(buffer.data()), chars);
71
+ }
72
+
73
+ jobjectArray BuildOutlineItems(JNIEnv *env,
74
+ FPDF_DOCUMENT doc,
75
+ FPDF_BOOKMARK parent,
76
+ jclass item_class,
77
+ jmethodID ctor) {
78
+ std::vector<jobject> items;
79
+
80
+ for (FPDF_BOOKMARK child = OutlineFns().bookmarkGetFirstChild(doc, parent); child;
81
+ child = OutlineFns().bookmarkGetNextSibling(doc, child)) {
82
+ jstring title = GetBookmarkTitle(env, child);
83
+ int page_index = -1;
84
+ FPDF_DEST dest = OutlineFns().bookmarkGetDest(doc, child);
85
+ if (dest != nullptr) {
86
+ page_index = OutlineFns().destGetPageIndex(doc, dest);
87
+ }
88
+
89
+ jobjectArray children = BuildOutlineItems(env, doc, child, item_class, ctor);
90
+ jobject item = env->NewObject(item_class, ctor, title, page_index, children);
91
+
92
+ if (title != nullptr) {
93
+ env->DeleteLocalRef(title);
94
+ }
95
+ if (children != nullptr) {
96
+ env->DeleteLocalRef(children);
97
+ }
98
+
99
+ if (item != nullptr) {
100
+ items.push_back(item);
101
+ }
102
+ }
103
+
104
+ jobjectArray array =
105
+ env->NewObjectArray(static_cast<jsize>(items.size()), item_class, nullptr);
106
+ for (jsize i = 0; i < static_cast<jsize>(items.size()); i++) {
107
+ env->SetObjectArrayElement(array, i, items[i]);
108
+ }
109
+
110
+ return array;
111
+ }
112
+
113
+ jobjectArray BuildOutline(JNIEnv *env, FPDF_DOCUMENT doc) {
114
+ jclass item_class = env->FindClass("com/papyrus/engine/PapyrusOutlineItem");
115
+ if (item_class == nullptr) {
116
+ return nullptr;
117
+ }
118
+
119
+ jmethodID ctor = env->GetMethodID(
120
+ item_class, "<init>", "(Ljava/lang/String;I[Lcom/papyrus/engine/PapyrusOutlineItem;)V");
121
+ if (ctor == nullptr) {
122
+ return nullptr;
123
+ }
124
+
125
+ return BuildOutlineItems(env, doc, nullptr, item_class, ctor);
126
+ }
127
+
128
+ } // namespace
129
+
130
+ extern "C" JNIEXPORT jboolean JNICALL
131
+ Java_com_papyrus_engine_PapyrusOutline_nativeIsOutlineSupported(JNIEnv *, jclass) {
132
+ return LoadPdfium() ? JNI_TRUE : JNI_FALSE;
133
+ }
134
+
135
+ extern "C" JNIEXPORT jobjectArray JNICALL
136
+ Java_com_papyrus_engine_PapyrusOutline_nativeGetOutline(JNIEnv *env, jclass, jlong docPtr) {
137
+ if (!LoadPdfium()) {
138
+ return nullptr;
139
+ }
140
+ if (!docPtr) {
141
+ return nullptr;
142
+ }
143
+
144
+ FPDF_DOCUMENT doc = reinterpret_cast<FPDF_DOCUMENT>(docPtr);
145
+ return BuildOutline(env, doc);
146
+ }
147
+
148
+ extern "C" JNIEXPORT jobjectArray JNICALL
149
+ Java_com_papyrus_engine_PapyrusOutline_nativeGetOutlineFile(JNIEnv *env,
150
+ jclass,
151
+ jstring filePath) {
152
+ if (!LoadPdfium()) {
153
+ return nullptr;
154
+ }
155
+ if (filePath == nullptr) {
156
+ return nullptr;
157
+ }
158
+
159
+ const char *path = env->GetStringUTFChars(filePath, nullptr);
160
+ if (path == nullptr) {
161
+ return nullptr;
162
+ }
163
+
164
+ FPDF_DOCUMENT doc = OutlineFns().loadDocument(path, nullptr);
165
+ env->ReleaseStringUTFChars(filePath, path);
166
+ if (doc == nullptr) {
167
+ return nullptr;
168
+ }
169
+
170
+ jobjectArray result = BuildOutline(env, doc);
171
+ OutlineFns().closeDocument(doc);
172
+ return result;
173
173
  }