Skip to content

Commit 78f4f44

Browse files
chore(mobile): update react-native-pdf-jsi to 6.1.0
react-native-pdf-jsi 6 replaces the viewer component, so the Android PDF preview moves to the 6.x props (zero-based initialPage, onLinkPress). Both hunks of our 5.0.0 patch are fixed upstream, and the async-storage and blob-util peers that 5.x needed are removed. 6.1.1 cannot build Android: it downloads PDFium from a GitHub release asset that was never published. Stay on 6.1.0, which still bundles PDFium, and patch in 6.1.1's iOS fix for the NitroPdfJsi-Swift.h build failure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7078dcb commit 78f4f44

8 files changed

Lines changed: 66 additions & 137 deletions

File tree

‎apps/mobile/app.config.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ const config: ExpoConfig = {
326326
},
327327
plugins: [
328328
"expo-asset",
329-
"react-native-pdf-jsi",
329+
// iOS previews PDFs in a WebView; keep the plugin from exposing Documents in the Files app.
330+
["react-native-pdf-jsi", { iosFileSharing: false }],
330331
[
331332
"expo-font",
332333
{

‎apps/mobile/package.json‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"@pierre/diffs": "catalog:",
6464
"@pierre/highlights": "catalog:",
6565
"@react-native-ai/apple": "0.12.0",
66-
"@react-native-async-storage/async-storage": "3.1.1",
6766
"@react-native-menu/menu": "^2.0.0",
6867
"@react-navigation/elements": "2.9.45",
6968
"@react-navigation/native": "7.5.1",
@@ -121,13 +120,12 @@
121120
"react": "catalog:",
122121
"react-dom": "catalog:",
123122
"react-native": "0.88.1",
124-
"react-native-blob-util": "0.25.1",
125123
"react-native-enriched-markdown": "file:deps/react-native-enriched-markdown-1.2.0-t3.18-497fbe63.tgz",
126124
"react-native-gesture-handler": "~3.5.0",
127125
"react-native-image-viewing": "^0.2.2",
128126
"react-native-keyboard-controller": "1.23.0",
129127
"react-native-nitro-modules": "0.37.2",
130-
"react-native-pdf-jsi": "5.0.0",
128+
"react-native-pdf-jsi": "6.1.0",
131129
"react-native-reanimated": "4.7.1",
132130
"react-native-safe-area-context": "~5.11.1",
133131
"react-native-screens": "file:deps/react-native-screens-5.0.0-t3.48.tgz",

‎apps/mobile/src/components/PdfPreview.android.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ export function PdfPreview(props: { readonly uri: string }) {
7272
return (
7373
<Pdf
7474
source={{ uri: localUri }}
75-
page={pdfInitialPage(props.uri)}
76-
fitPolicy={0}
77-
trustAllCerts={false}
75+
initialPage={pdfInitialPage(props.uri) - 1}
7876
enableAnnotationRendering
7977
enableDoubleTapZoom
80-
onPressLink={(href) => {
78+
onLinkPress={({ url: href }) => {
8179
const url = pdfLinkUrl(href, props.uri);
8280
if (url !== null) void tryOpenExternalUrl(url, "file-preview");
8381
}}

‎patches/[email protected]‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎patches/[email protected]‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
diff --git a/ios/RNPDFPdf/HybridPdfDocument.swift b/ios/RNPDFPdf/HybridPdfDocument.swift
2+
--- a/ios/RNPDFPdf/HybridPdfDocument.swift
3+
+++ b/ios/RNPDFPdf/HybridPdfDocument.swift
4+
@@ -800,9 +800,13 @@ enum HybridPdfShared {
5+
}
6+
7+
/// Lookup for RNPDFPdfPageView.mm, which cannot import the Swift module header.
8+
+/// Must stay internal and C-typed: public declarations are emitted into NitroPdfJsi-Swift.h,
9+
+/// which Nitro includes from plain C++ where Objective-C types do not exist.
10+
+/// Returns a +1 retained PDFDocument; the caller takes ownership with __bridge_transfer.
11+
@_cdecl("RNPDFSharedDocument")
12+
-public func RNPDFSharedDocument(_ path: NSString) -> PDFDocument? {
13+
- HybridPdfShared.find(path as String)
14+
+func RNPDFSharedDocument(_ path: UnsafePointer<CChar>) -> UnsafeMutableRawPointer? {
15+
+ guard let document = HybridPdfShared.find(String(cString: path)) else { return nil }
16+
+ return Unmanaged.passRetained(document).toOpaque()
17+
}
18+
19+
enum HybridPdfPaths {
20+
diff --git a/ios/RNPDFPdf/RNPDFPdfPageView.mm b/ios/RNPDFPdf/RNPDFPdfPageView.mm
21+
--- a/ios/RNPDFPdf/RNPDFPdfPageView.mm
22+
+++ b/ios/RNPDFPdf/RNPDFPdfPageView.mm
23+
@@ -10,8 +10,8 @@
24+
25+
using namespace facebook::react;
26+
27+
-/// Defined in HybridPdfDocument.swift.
28+
-extern "C" PDFDocument *_Nullable RNPDFSharedDocument(NSString *path);
29+
+/// Defined in HybridPdfDocument.swift. Returns a +1 retained PDFDocument or NULL.
30+
+extern "C" void *_Nullable RNPDFSharedDocument(const char *path);
31+
32+
@interface RNPDFPdfPageView () <RCTRNPDFPdfPageViewViewProtocol>
33+
@end
34+
@@ -89,7 +89,8 @@ - (void)render
35+
BOOL annotations = _annotations;
36+
CGFloat screenScale = self.traitCollection.displayScale > 0 ? self.traitCollection.displayScale : 2;
37+
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
38+
- PDFDocument *document = RNPDFSharedDocument(path);
39+
+ void *raw = RNPDFSharedDocument(path.UTF8String);
40+
+ PDFDocument *document = raw ? (__bridge_transfer PDFDocument *)raw : nil;
41+
NSString *code = nil;
42+
NSString *message = nil;
43+
UIImage *image = nil;

‎pnpm-lock.yaml‎

Lines changed: 14 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ overrides:
123123
react-native-gesture-handler: 3.5.0
124124
react-native-reanimated: 4.7.1
125125
react-native-keyboard-controller: 1.23.0
126-
react-native-pdf-jsi: 5.0.0
126+
react-native-pdf-jsi: 6.1.0
127127
react-native-webview: 14.0.1
128128
react-native-svg: 15.16.1
129129
app-builder-lib: 26.16.1
@@ -244,9 +244,11 @@ patchedDependencies:
244244
245245
# Screens v5 stack, split and tab screens leave at once, like legacy screens. Exiting animations
246246
# inside one otherwise hold its removal for a later mount, after its stack has moved on.
247+
# iOS: 6.1.1's fix for the NitroPdfJsi-Swift.h build failure (upstream #44). 6.1.1 itself
248+
# cannot build Android: it downloads PDFium from a release asset that was never published.
249+
247250
248251
249-
250252
# Android: a nested WebView hands a vertical drag to its scrolling parent at the page's edge.
251253
252254
# Android: a Compose host that requests layout in a mount (a new screen's app bar) is laid out

‎third-party-licenses.config.json‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -339,33 +339,6 @@
339339
"copyrights": ["Copyright (c) Junyoung Choi <[email protected]>"]
340340
}
341341
},
342-
{
343-
"name": "@react-native-async-storage/async-storage",
344-
"version": "3.1.1",
345-
"sourceUrl": "https://github.com/react-native-async-storage/async-storage",
346-
"generatedNotice": {
347-
"licenseId": "MIT",
348-
"copyrights": ["Copyright (c) 2025 Krzysztof Borowy"]
349-
}
350-
},
351-
{
352-
"name": "deprecated-react-native-prop-types",
353-
"version": "2.3.0",
354-
"sourceUrl": "https://github.com/facebookarchive/react-native-deprecated-modules",
355-
"generatedNotice": {
356-
"licenseId": "MIT",
357-
"copyrights": ["Copyright (c) Meta Platforms, Inc. and affiliates."]
358-
}
359-
},
360-
{
361-
"name": "@react-native/normalize-color",
362-
"version": "2.1.0",
363-
"sourceUrl": "https://github.com/facebook/react-native",
364-
"generatedNotice": {
365-
"licenseId": "MIT",
366-
"copyrights": ["Copyright (c) Meta Platforms, Inc. and affiliates."]
367-
}
368-
},
369342
{
370343
"name": "@bufbuild/protobuf",
371344
"version": "1.10.0",

0 commit comments

Comments
 (0)