@tobyt/expo-pdf-markup 1.1.1 → 1.1.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/CHANGELOG.md +18 -0
- package/README.md +9 -6
- package/build/ExpoPdfMarkup.types.d.ts.map +1 -1
- package/build/ExpoPdfMarkup.types.js.map +1 -1
- package/build/ExpoPdfMarkupView.d.ts +1 -1
- package/build/ExpoPdfMarkupView.d.ts.map +1 -1
- package/build/ExpoPdfMarkupView.js +2 -1
- package/build/ExpoPdfMarkupView.js.map +1 -1
- package/build/ExpoPdfMarkupView.web.d.ts +2 -0
- package/build/ExpoPdfMarkupView.web.d.ts.map +1 -1
- package/build/ExpoPdfMarkupView.web.js +39 -36
- package/build/ExpoPdfMarkupView.web.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/pdfjs.d.ts +1 -0
- package/build/pdfjs.d.ts.map +1 -1
- package/build/pdfjs.js +3 -0
- package/build/pdfjs.js.map +1 -1
- package/build/pdfjs.web.d.ts +1 -1
- package/build/pdfjs.web.d.ts.map +1 -1
- package/build/pdfjs.web.js +1 -1
- package/build/pdfjs.web.js.map +1 -1
- package/build/web/annotationUtils.d.ts.map +1 -1
- package/build/web/annotationUtils.js +13 -5
- package/build/web/annotationUtils.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +113 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1648 -0
- package/docs/functions/ExpoPdfMarkupView.html +42 -0
- package/docs/functions/setPdfJsWorkerSrc.html +42 -0
- package/docs/hierarchy.html +29 -0
- package/docs/index.html +148 -0
- package/docs/modules.html +40 -0
- package/docs/types/Annotation.html +33 -0
- package/docs/types/AnnotationBounds.html +73 -0
- package/docs/types/AnnotationMode.html +33 -0
- package/docs/types/AnnotationPoint.html +61 -0
- package/docs/types/AnnotationsData.html +61 -0
- package/docs/types/ExpoPdfMarkupViewProps.html +184 -0
- package/docs/types/HighlightAnnotation.html +91 -0
- package/docs/types/InkAnnotation.html +91 -0
- package/docs/types/StampAnnotation.html +95 -0
- package/docs/types/StampDefinition.html +72 -0
- package/docs/types/TextAnnotation.html +110 -0
- package/docs/types/TextInputRequest.html +73 -0
- package/docs/types/UnderlineAnnotation.html +85 -0
- package/ios/AnnotationSerializer.swift +6 -34
- package/ios/ExpoPdfMarkupView+Ink.swift +2 -10
- package/ios/ExpoPdfMarkupView+Move.swift +4 -3
- package/ios/ExpoPdfMarkupView.swift +4 -3
- package/ios/InkPDFAnnotation.swift +45 -0
- package/ios/Tests/AnnotationSerializerTests.swift +26 -0
- package/metro.js +47 -20
- package/package.json +8 -8
- package/src/ExpoPdfMarkup.types.ts +2 -13
- package/src/ExpoPdfMarkupView.tsx +1 -1
- package/src/ExpoPdfMarkupView.web.tsx +26 -13
- package/src/index.ts +1 -1
- package/src/pdfjs.ts +4 -0
- package/src/pdfjs.web.ts +1 -1
- package/src/web/annotationUtils.ts +11 -5
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>UnderlineAnnotation | @tobyt/expo-pdf-markup - v1.1.1</title><meta name="description" content="Documentation for @tobyt/expo-pdf-markup"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar">
|
|
2
|
+
<div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@tobyt/expo-pdf-markup - v1.1.1</a>
|
|
3
|
+
<div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/>
|
|
4
|
+
<ul role="listbox" id="tsd-search-results"></ul>
|
|
5
|
+
<div id="tsd-search-status" aria-live="polite" aria-atomic="true">
|
|
6
|
+
<div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header>
|
|
7
|
+
<div class="container container-main">
|
|
8
|
+
<div class="col-content">
|
|
9
|
+
<div class="tsd-page-title">
|
|
10
|
+
<ul class="tsd-breadcrumb" aria-label="Breadcrumb">
|
|
11
|
+
<li><a href="" aria-current="page">UnderlineAnnotation</a></li></ul>
|
|
12
|
+
<h1>Type Alias UnderlineAnnotation</h1></div>
|
|
13
|
+
<div class="tsd-signature"><span class="tsd-signature-keyword">type</span> <span class="tsd-kind-type-alias">UnderlineAnnotation</span> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-symbol">{</span><br/> <a class="tsd-kind-property" href="#bounds">bounds</a><span class="tsd-signature-symbol">:</span> <a href="AnnotationBounds.html" class="tsd-signature-type tsd-kind-type-alias">AnnotationBounds</a><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#color">color</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#createdat">createdAt</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#id">id</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#page">page</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#type">type</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"underline"</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><aside class="tsd-sources">
|
|
14
|
+
<ul>
|
|
15
|
+
<li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L27">ExpoPdfMarkup.types.ts:27</a></li></ul></aside>
|
|
16
|
+
<section class="tsd-panel-group tsd-index-group">
|
|
17
|
+
<section class="tsd-panel tsd-index-panel">
|
|
18
|
+
<details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
|
|
19
|
+
<h5 class="tsd-index-heading uppercase">Index</h5></summary>
|
|
20
|
+
<div class="tsd-accordion-details">
|
|
21
|
+
<section class="tsd-index-section">
|
|
22
|
+
<h3 class="tsd-index-heading tsd-anchor-link" id="properties">Properties<a href="#properties" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
|
|
23
|
+
<div class="tsd-index-list"><a href="#bounds" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>bounds</span></a>
|
|
24
|
+
<a href="#color" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>color</span></a>
|
|
25
|
+
<a href="#createdat" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>created<wbr/>At?</span></a>
|
|
26
|
+
<a href="#id" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>id</span></a>
|
|
27
|
+
<a href="#page" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>page</span></a>
|
|
28
|
+
<a href="#type" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>type</span></a>
|
|
29
|
+
</div></section></div></details></section></section>
|
|
30
|
+
<details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
|
|
31
|
+
<h2 class="tsd-anchor-link" id="properties-1">Properties<a href="#properties-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2></summary>
|
|
32
|
+
<section>
|
|
33
|
+
<section class="tsd-panel tsd-member">
|
|
34
|
+
<h3 class="tsd-anchor-link" id="bounds"><span>bounds</span><a href="#bounds" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
|
|
35
|
+
<div class="tsd-signature"><span class="tsd-kind-property">bounds</span><span class="tsd-signature-symbol">:</span> <a href="AnnotationBounds.html" class="tsd-signature-type tsd-kind-type-alias">AnnotationBounds</a></div><aside class="tsd-sources">
|
|
36
|
+
<ul>
|
|
37
|
+
<li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L32">ExpoPdfMarkup.types.ts:32</a></li></ul></aside></section>
|
|
38
|
+
<section class="tsd-panel tsd-member">
|
|
39
|
+
<h3 class="tsd-anchor-link" id="color"><span>color</span><a href="#color" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
|
|
40
|
+
<div class="tsd-signature"><span class="tsd-kind-property">color</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
|
|
41
|
+
<ul>
|
|
42
|
+
<li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L31">ExpoPdfMarkup.types.ts:31</a></li></ul></aside></section>
|
|
43
|
+
<section class="tsd-panel tsd-member">
|
|
44
|
+
<h3 class="tsd-anchor-link" id="createdat"><code class="tsd-tag">Optional</code><span>created<wbr/>At</span><a href="#createdat" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
|
|
45
|
+
<div class="tsd-signature"><span class="tsd-kind-property">createdAt</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources">
|
|
46
|
+
<ul>
|
|
47
|
+
<li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L33">ExpoPdfMarkup.types.ts:33</a></li></ul></aside></section>
|
|
48
|
+
<section class="tsd-panel tsd-member">
|
|
49
|
+
<h3 class="tsd-anchor-link" id="id"><span>id</span><a href="#id" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
|
|
50
|
+
<div class="tsd-signature"><span class="tsd-kind-property">id</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
|
|
51
|
+
<ul>
|
|
52
|
+
<li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L28">ExpoPdfMarkup.types.ts:28</a></li></ul></aside></section>
|
|
53
|
+
<section class="tsd-panel tsd-member">
|
|
54
|
+
<h3 class="tsd-anchor-link" id="page"><span>page</span><a href="#page" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
|
|
55
|
+
<div class="tsd-signature"><span class="tsd-kind-property">page</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources">
|
|
56
|
+
<ul>
|
|
57
|
+
<li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L30">ExpoPdfMarkup.types.ts:30</a></li></ul></aside></section>
|
|
58
|
+
<section class="tsd-panel tsd-member">
|
|
59
|
+
<h3 class="tsd-anchor-link" id="type"><span>type</span><a href="#type" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
|
|
60
|
+
<div class="tsd-signature"><span class="tsd-kind-property">type</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"underline"</span></div><aside class="tsd-sources">
|
|
61
|
+
<ul>
|
|
62
|
+
<li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L29">ExpoPdfMarkup.types.ts:29</a></li></ul></aside></section></section></details></div>
|
|
63
|
+
<div class="col-sidebar">
|
|
64
|
+
<div class="page-menu">
|
|
65
|
+
<div class="tsd-navigation settings">
|
|
66
|
+
<details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
|
|
67
|
+
<h3>Settings</h3></summary>
|
|
68
|
+
<div class="tsd-accordion-details">
|
|
69
|
+
<div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span>
|
|
70
|
+
<ul id="tsd-filter-options">
|
|
71
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
|
|
72
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
|
|
73
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div>
|
|
74
|
+
<div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
|
|
75
|
+
<details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
|
|
76
|
+
<h3>On This Page</h3></summary>
|
|
77
|
+
<div class="tsd-accordion-details">
|
|
78
|
+
<details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary>
|
|
79
|
+
<div><a href="#bounds"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>bounds</span></a><a href="#color"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>color</span></a><a href="#createdat"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>created<wbr/>At</span></a><a href="#id"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>id</span></a><a href="#page"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>page</span></a><a href="#type"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>type</span></a></div></details></div></details></div>
|
|
80
|
+
<div class="site-menu">
|
|
81
|
+
<nav class="tsd-navigation"><a href="../modules.html">@tobyt/expo-pdf-markup - v1.1.1</a>
|
|
82
|
+
<ul class="tsd-small-nested-navigation" id="tsd-nav-container">
|
|
83
|
+
<li>Loading...</li></ul></nav></div></div></div><footer>
|
|
84
|
+
<p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>
|
|
85
|
+
<div class="overlay"></div></body></html>
|
|
@@ -97,9 +97,9 @@ enum AnnotationSerializer {
|
|
|
97
97
|
switch model.type {
|
|
98
98
|
case "ink":
|
|
99
99
|
model.lineWidth = annotation.border?.lineWidth ?? 2.0
|
|
100
|
-
if let
|
|
101
|
-
model.paths =
|
|
102
|
-
|
|
100
|
+
if let inkAnnotation = annotation as? InkPDFAnnotation {
|
|
101
|
+
model.paths = inkAnnotation.strokes.map { stroke in
|
|
102
|
+
stroke.map { ["x": $0.x, "y": $0.y] }
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
case "highlight", "underline":
|
|
@@ -209,23 +209,15 @@ enum AnnotationSerializer {
|
|
|
209
209
|
annotationBounds = combinedRect.insetBy(dx: -padding, dy: -padding)
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
let annotation =
|
|
212
|
+
let annotation = InkPDFAnnotation(bounds: annotationBounds, forType: .ink, withProperties: nil)
|
|
213
213
|
annotation.color = color
|
|
214
214
|
|
|
215
215
|
let border = PDFBorder()
|
|
216
216
|
border.lineWidth = lineWidth
|
|
217
217
|
annotation.border = border
|
|
218
218
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
for (index, point) in path.enumerated() {
|
|
222
|
-
if index == 0 {
|
|
223
|
-
bezierPath.move(to: CGPoint(x: point.x, y: point.y))
|
|
224
|
-
} else {
|
|
225
|
-
bezierPath.addLine(to: CGPoint(x: point.x, y: point.y))
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
annotation.add(bezierPath)
|
|
219
|
+
annotation.strokes = paths.map { path in
|
|
220
|
+
path.map { CGPoint(x: $0.x, y: $0.y) }
|
|
229
221
|
}
|
|
230
222
|
|
|
231
223
|
let createdAt = model.createdAt ?? Date().timeIntervalSince1970
|
|
@@ -294,24 +286,4 @@ enum AnnotationSerializer {
|
|
|
294
286
|
height: height
|
|
295
287
|
)
|
|
296
288
|
}
|
|
297
|
-
|
|
298
|
-
private static func pointsFromBezierPath(_ path: UIBezierPath) -> [CGPoint] {
|
|
299
|
-
var points: [CGPoint] = []
|
|
300
|
-
let cgPath = path.cgPath
|
|
301
|
-
cgPath.applyWithBlock { element in
|
|
302
|
-
switch element.pointee.type {
|
|
303
|
-
case .moveToPoint, .addLineToPoint:
|
|
304
|
-
points.append(element.pointee.points[0])
|
|
305
|
-
case .addQuadCurveToPoint:
|
|
306
|
-
points.append(element.pointee.points[1])
|
|
307
|
-
case .addCurveToPoint:
|
|
308
|
-
points.append(element.pointee.points[2])
|
|
309
|
-
case .closeSubpath:
|
|
310
|
-
break
|
|
311
|
-
@unknown default:
|
|
312
|
-
break
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return points
|
|
316
|
-
}
|
|
317
289
|
}
|
|
@@ -94,22 +94,14 @@ extension ExpoPdfMarkupView {
|
|
|
94
94
|
// and tight bounds calculations are fragile with coordinate transforms.
|
|
95
95
|
let annotationBounds = page.bounds(for: pdfView.displayBox)
|
|
96
96
|
|
|
97
|
-
let annotation =
|
|
97
|
+
let annotation = InkPDFAnnotation(bounds: annotationBounds, forType: .ink, withProperties: nil)
|
|
98
98
|
annotation.color = AnnotationSerializer.colorFromHex(annotationColor) ?? .red
|
|
99
99
|
|
|
100
100
|
let border = PDFBorder()
|
|
101
101
|
border.lineWidth = annotationLineWidth
|
|
102
102
|
annotation.border = border
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
for (index, point) in pdfPoints.enumerated() {
|
|
106
|
-
if index == 0 {
|
|
107
|
-
bezierPath.move(to: point)
|
|
108
|
-
} else {
|
|
109
|
-
bezierPath.addLine(to: point)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
annotation.add(bezierPath)
|
|
104
|
+
annotation.strokes = [pdfPoints]
|
|
113
105
|
|
|
114
106
|
let id = UUID().uuidString
|
|
115
107
|
AnnotationSerializer.tagAsModuleManaged(annotation, id: id, createdAt: Date().timeIntervalSince1970)
|
|
@@ -166,10 +166,11 @@ extension ExpoPdfMarkupView {
|
|
|
166
166
|
in documentView: UIView
|
|
167
167
|
) -> CGRect? {
|
|
168
168
|
let pdfRect: CGRect
|
|
169
|
-
if let
|
|
169
|
+
if let inkAnnotation = annotation as? InkPDFAnnotation, !inkAnnotation.strokes.isEmpty {
|
|
170
170
|
var combinedBounds = CGRect.null
|
|
171
|
-
for
|
|
172
|
-
|
|
171
|
+
for stroke in inkAnnotation.strokes {
|
|
172
|
+
guard let cgPath = InkPDFAnnotation.cgPath(for: stroke) else { continue }
|
|
173
|
+
combinedBounds = combinedBounds.union(cgPath.boundingBoxOfPath)
|
|
173
174
|
}
|
|
174
175
|
guard !combinedBounds.isNull else { return nil }
|
|
175
176
|
let padding = max(annotation.border?.lineWidth ?? 2.0, 10.0)
|
|
@@ -272,10 +272,11 @@ class ExpoPdfMarkupView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
272
272
|
for annotation in page.annotations.reversed() {
|
|
273
273
|
guard AnnotationSerializer.isModuleManaged(annotation) else { continue }
|
|
274
274
|
|
|
275
|
-
if let
|
|
275
|
+
if let inkAnnotation = annotation as? InkPDFAnnotation {
|
|
276
276
|
let tolerance = max(annotation.border?.lineWidth ?? 2.0, 10.0)
|
|
277
|
-
for
|
|
278
|
-
let
|
|
277
|
+
for stroke in inkAnnotation.strokes {
|
|
278
|
+
guard let cgPath = InkPDFAnnotation.cgPath(for: stroke) else { continue }
|
|
279
|
+
let hitPath = cgPath.copy(
|
|
279
280
|
strokingWithWidth: tolerance,
|
|
280
281
|
lineCap: .round,
|
|
281
282
|
lineJoin: .round,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import PDFKit
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
/// Renders freehand ink strokes as a PDFKit annotation, storing and drawing the stroke
|
|
5
|
+
/// geometry itself rather than going through `PDFAnnotation.add(_:)` / `.paths`. iOS 27 beta
|
|
6
|
+
/// has a PDFKit regression where those APIs silently drop ink stroke geometry (see report/),
|
|
7
|
+
/// so this class sidesteps them entirely — matching the pattern `StampPDFAnnotation` already
|
|
8
|
+
/// uses for its own custom-drawn content.
|
|
9
|
+
final class InkPDFAnnotation: PDFAnnotation {
|
|
10
|
+
var strokes: [[CGPoint]] = []
|
|
11
|
+
|
|
12
|
+
required init?(coder: NSCoder) {
|
|
13
|
+
super.init(coder: coder)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override init(bounds: CGRect, forType type: PDFAnnotationSubtype, withProperties properties: [AnyHashable: Any]?) {
|
|
17
|
+
super.init(bounds: bounds, forType: type, withProperties: properties)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override func draw(with _: PDFDisplayBox, in context: CGContext) {
|
|
21
|
+
guard !strokes.isEmpty else { return }
|
|
22
|
+
|
|
23
|
+
context.saveGState()
|
|
24
|
+
context.setStrokeColor((color ?? .red).cgColor)
|
|
25
|
+
context.setLineWidth(border?.lineWidth ?? 2.0)
|
|
26
|
+
context.setLineCap(.round)
|
|
27
|
+
context.setLineJoin(.round)
|
|
28
|
+
for stroke in strokes {
|
|
29
|
+
guard let path = Self.cgPath(for: stroke) else { continue }
|
|
30
|
+
context.addPath(path)
|
|
31
|
+
}
|
|
32
|
+
context.strokePath()
|
|
33
|
+
context.restoreGState()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static func cgPath(for points: [CGPoint]) -> CGPath? {
|
|
37
|
+
guard let first = points.first else { return nil }
|
|
38
|
+
let path = CGMutablePath()
|
|
39
|
+
path.move(to: first)
|
|
40
|
+
for point in points.dropFirst() {
|
|
41
|
+
path.addLine(to: point)
|
|
42
|
+
}
|
|
43
|
+
return path
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -168,6 +168,32 @@ final class AnnotationSerializerTests: XCTestCase {
|
|
|
168
168
|
XCTAssertEqual(result.type, "ink")
|
|
169
169
|
XCTAssertEqual(result.page, 0)
|
|
170
170
|
XCTAssertEqual(result.color, "#FF0000")
|
|
171
|
+
XCTAssertEqual(
|
|
172
|
+
result.decodedPaths,
|
|
173
|
+
[[AnnotationPoint(x: 10, y: 20), AnnotationPoint(x: 30, y: 40)]]
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
func testInkAnnotationStoresStrokesOnCustomSubclass() throws {
|
|
178
|
+
let model = AnnotationModel(
|
|
179
|
+
id: "ink-strokes-1",
|
|
180
|
+
type: "ink",
|
|
181
|
+
page: 0,
|
|
182
|
+
color: "#00FF00",
|
|
183
|
+
lineWidth: 4.0,
|
|
184
|
+
paths: [[["x": 1, "y": 2], ["x": 3, "y": 4]], [["x": 5, "y": 6]]],
|
|
185
|
+
createdAt: 1_741_340_000
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
let annotation = try XCTUnwrap(AnnotationSerializer.toPDFAnnotation(model))
|
|
189
|
+
let inkAnnotation = try XCTUnwrap(annotation as? InkPDFAnnotation)
|
|
190
|
+
|
|
191
|
+
// Regression coverage: on iOS 27 beta, PDFAnnotation.paths silently drops stroke
|
|
192
|
+
// geometry added via .add(_:), so ink annotations must not depend on it (report/).
|
|
193
|
+
XCTAssertEqual(
|
|
194
|
+
inkAnnotation.strokes,
|
|
195
|
+
[[CGPoint(x: 1, y: 2), CGPoint(x: 3, y: 4)], [CGPoint(x: 5, y: 6)]]
|
|
196
|
+
)
|
|
171
197
|
}
|
|
172
198
|
|
|
173
199
|
func testFreeTextColorRoundTrip() throws {
|
package/metro.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* This does two things:
|
|
12
12
|
* 1. Patches `import.meta` in pdfjs-dist source before Babel/hermes-parser
|
|
13
|
-
* sees it (pdfjs-dist
|
|
13
|
+
* sees it (pdfjs-dist uses it in a Node.js-only code path that is dead
|
|
14
14
|
* code in the browser, but Metro bundles as a non-module script so the
|
|
15
15
|
* browser's JS engine refuses to parse the bundle).
|
|
16
16
|
* 2. Copies the pdfjs worker file to <projectRoot>/public/pdf.worker.min.mjs
|
|
@@ -43,8 +43,9 @@ function upstream(projectRoot) {
|
|
|
43
43
|
|
|
44
44
|
module.exports.transform = function transform({ filename, src, options, plugins }) {
|
|
45
45
|
// Replace `import.meta` with `({})` in pdfjs-dist files before any parser
|
|
46
|
-
// sees the source. `({}).url` → undefined, which is harmless: the
|
|
47
|
-
//
|
|
46
|
+
// sees the source. `({}).url` → undefined, which is harmless: the only use
|
|
47
|
+
// (NodeCanvasFactory._createCanvas → createRequire(import.meta.url)) is
|
|
48
|
+
// Node.js-only dead code that never runs in the browser.
|
|
48
49
|
if (filename.includes('pdfjs-dist') && src.includes('import.meta')) {
|
|
49
50
|
src = src.replace(/import\.meta/g, '({})');
|
|
50
51
|
}
|
|
@@ -59,29 +60,55 @@ module.exports.withPdfMarkup = function withPdfMarkup(config) {
|
|
|
59
60
|
// 1. Swap in this file as the babel transformer so import.meta is patched.
|
|
60
61
|
config.transformer.babelTransformerPath = require.resolve('./metro.js');
|
|
61
62
|
|
|
62
|
-
// 2. Copy the pdfjs worker to <projectRoot>/public/ so it is served at
|
|
63
|
-
// /pdf.worker.min.mjs (same-origin). Only copies if not already present,
|
|
64
|
-
// so repeated Metro restarts are fast.
|
|
65
63
|
const projectRoot = config.projectRoot ?? process.cwd();
|
|
66
64
|
const publicDir = path.join(projectRoot, 'public');
|
|
67
|
-
const dest = path.join(publicDir, 'pdf.worker.min.mjs');
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
// Locate the installed pdfjs-dist so we can copy its runtime assets.
|
|
67
|
+
let pdfjsDir;
|
|
68
|
+
try {
|
|
69
|
+
pdfjsDir = path.dirname(require.resolve('pdfjs-dist/package.json'));
|
|
70
|
+
} catch {
|
|
71
|
+
console.warn(
|
|
72
|
+
'[expo-pdf-markup] Could not find pdfjs-dist. ' +
|
|
73
|
+
'Install it as a dependency to enable web PDF rendering.'
|
|
74
|
+
);
|
|
75
|
+
return config;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 2. Copy the pdfjs worker to <projectRoot>/public/ so it is served at
|
|
79
|
+
// /pdf.worker.min.mjs (same-origin). Only copies if not already present,
|
|
80
|
+
// so repeated Metro restarts are fast.
|
|
81
|
+
const workerDest = path.join(publicDir, 'pdf.worker.min.mjs');
|
|
82
|
+
if (!fs.existsSync(workerDest)) {
|
|
80
83
|
if (!fs.existsSync(publicDir)) {
|
|
81
84
|
fs.mkdirSync(publicDir, { recursive: true });
|
|
82
85
|
}
|
|
83
|
-
fs.copyFileSync(
|
|
84
|
-
console.log('[expo-pdf-markup] Copied pdfjs worker → ' +
|
|
86
|
+
fs.copyFileSync(path.join(pdfjsDir, 'build', 'pdf.worker.min.mjs'), workerDest);
|
|
87
|
+
console.log('[expo-pdf-markup] Copied pdfjs worker → ' + workerDest);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 3. Copy the pdfjs WebAssembly assets to <projectRoot>/public/wasm/ so they
|
|
91
|
+
// are served at /wasm/ (same-origin). pdfjs-dist v6 decodes JBIG2/CCITT
|
|
92
|
+
// fax, JPEG2000 and ICC data in WebAssembly and fetches these files at
|
|
93
|
+
// runtime; without them such image data (e.g. scanned pages, some music
|
|
94
|
+
// notation) renders blank. Copies any files not already present.
|
|
95
|
+
const wasmSrcDir = path.join(pdfjsDir, 'wasm');
|
|
96
|
+
const wasmDestDir = path.join(publicDir, 'wasm');
|
|
97
|
+
if (fs.existsSync(wasmSrcDir)) {
|
|
98
|
+
let copied = 0;
|
|
99
|
+
for (const file of fs.readdirSync(wasmSrcDir)) {
|
|
100
|
+
const dest = path.join(wasmDestDir, file);
|
|
101
|
+
if (!fs.existsSync(dest)) {
|
|
102
|
+
if (!fs.existsSync(wasmDestDir)) {
|
|
103
|
+
fs.mkdirSync(wasmDestDir, { recursive: true });
|
|
104
|
+
}
|
|
105
|
+
fs.copyFileSync(path.join(wasmSrcDir, file), dest);
|
|
106
|
+
copied++;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (copied > 0) {
|
|
110
|
+
console.log('[expo-pdf-markup] Copied ' + copied + ' pdfjs wasm file(s) → ' + wasmDestDir);
|
|
111
|
+
}
|
|
85
112
|
}
|
|
86
113
|
|
|
87
114
|
return config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tobyt/expo-pdf-markup",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "An Expo module for displaying and annotating PDFs",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"lint": "expo-module lint",
|
|
11
11
|
"lint:swift": "swiftlint lint ios/",
|
|
12
12
|
"lint:kotlin": "ktlint 'android/src/**/*.kt'",
|
|
13
|
-
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
14
|
-
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
|
|
13
|
+
"format": "node ./node_modules/prettier/bin/prettier.cjs --write \"src/**/*.{ts,tsx}\"",
|
|
14
|
+
"format:check": "node ./node_modules/prettier/bin/prettier.cjs --check \"src/**/*.{ts,tsx}\"",
|
|
15
15
|
"format:swift": "swiftformat ios/",
|
|
16
16
|
"format:swift:check": "swiftformat --lint ios/",
|
|
17
17
|
"format:kotlin": "ktlint --format 'android/src/**/*.kt'",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@changesets/cli": "^2.30.0",
|
|
56
|
-
"@types/react": "~19.2.
|
|
56
|
+
"@types/react": "~19.2.17",
|
|
57
57
|
"@types/react-test-renderer": "^19.1.0",
|
|
58
|
-
"expo": "~
|
|
59
|
-
"expo-module-scripts": "^
|
|
60
|
-
"pdfjs-dist": "^
|
|
61
|
-
"react-native": "0.
|
|
58
|
+
"expo": "~56.0.16",
|
|
59
|
+
"expo-module-scripts": "^56.0.3",
|
|
60
|
+
"pdfjs-dist": "^6.1.200",
|
|
61
|
+
"react-native": "^0.85.3",
|
|
62
62
|
"react-native-web": "^0.21.2",
|
|
63
63
|
"typedoc": "^0.28.17"
|
|
64
64
|
},
|
|
@@ -64,11 +64,7 @@ export type StampAnnotation = {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
export type Annotation =
|
|
67
|
-
|
|
|
68
|
-
| HighlightAnnotation
|
|
69
|
-
| UnderlineAnnotation
|
|
70
|
-
| TextAnnotation
|
|
71
|
-
| StampAnnotation;
|
|
67
|
+
InkAnnotation | HighlightAnnotation | UnderlineAnnotation | TextAnnotation | StampAnnotation;
|
|
72
68
|
|
|
73
69
|
export type AnnotationsData = {
|
|
74
70
|
version: 1;
|
|
@@ -76,14 +72,7 @@ export type AnnotationsData = {
|
|
|
76
72
|
};
|
|
77
73
|
|
|
78
74
|
export type AnnotationMode =
|
|
79
|
-
| '
|
|
80
|
-
| 'ink'
|
|
81
|
-
| 'highlight'
|
|
82
|
-
| 'underline'
|
|
83
|
-
| 'text'
|
|
84
|
-
| 'stamp'
|
|
85
|
-
| 'eraser'
|
|
86
|
-
| 'move';
|
|
75
|
+
'none' | 'ink' | 'highlight' | 'underline' | 'text' | 'stamp' | 'eraser' | 'move';
|
|
87
76
|
|
|
88
77
|
/**
|
|
89
78
|
* Recommended shape for describing a consumer-defined stamp set (e.g. domain-specific glyphs).
|
|
@@ -2,7 +2,7 @@ import { requireNativeModule, requireNativeView } from 'expo';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { findNodeHandle } from 'react-native';
|
|
4
4
|
|
|
5
|
-
import { ExpoPdfMarkupViewProps, TextInputRequest } from './ExpoPdfMarkup.types';
|
|
5
|
+
import type { ExpoPdfMarkupViewProps, TextInputRequest } from './ExpoPdfMarkup.types';
|
|
6
6
|
|
|
7
7
|
type NativeViewProps = Omit<ExpoPdfMarkupViewProps, 'onTextInputRequested'> & {
|
|
8
8
|
useJsTextDialog?: boolean;
|
|
@@ -36,6 +36,18 @@ export function setPdfJsWorkerSrc(url: string): void {
|
|
|
36
36
|
pdfjs.GlobalWorkerOptions.workerSrc = url;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// pdfjs-dist v6 decodes image data (JBIG2/CCITT fax, JPEG2000, ICC) in
|
|
40
|
+
// WebAssembly and must be told where the .wasm files live. withPdfMarkup() in
|
|
41
|
+
// metro.js copies them to public/wasm/. Relative URL so the worker resolves it
|
|
42
|
+
// regardless of the sub-path the app is hosted at. Override with
|
|
43
|
+
// setPdfJsWasmUrl() for a different bundler or CDN.
|
|
44
|
+
let wasmUrl = './wasm/';
|
|
45
|
+
|
|
46
|
+
/** Allow consumers to override the pdfjs WebAssembly directory URL before mounting the view. */
|
|
47
|
+
export function setPdfJsWasmUrl(url: string): void {
|
|
48
|
+
wasmUrl = url;
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
// ---------------------------------------------------------------------------
|
|
40
52
|
// Zoom constants
|
|
41
53
|
// ---------------------------------------------------------------------------
|
|
@@ -122,7 +134,7 @@ function PageView({
|
|
|
122
134
|
const ctx = canvas.getContext('2d');
|
|
123
135
|
if (!ctx) return;
|
|
124
136
|
const viewport = page.getViewport({ scale: meta.scale * dpr });
|
|
125
|
-
const task = page.render({ canvasContext: ctx, viewport });
|
|
137
|
+
const task = page.render({ canvas: null, canvasContext: ctx, viewport });
|
|
126
138
|
renderTaskRef.current = task;
|
|
127
139
|
try {
|
|
128
140
|
await task.promise;
|
|
@@ -162,6 +174,7 @@ function PageView({
|
|
|
162
174
|
ctx.beginPath();
|
|
163
175
|
for (let i = 0; i < liveInkPoints.length; i++) {
|
|
164
176
|
const pt = liveInkPoints[i];
|
|
177
|
+
if (!pt) continue;
|
|
165
178
|
if (i === 0) ctx.moveTo(pt.x, pt.y);
|
|
166
179
|
else ctx.lineTo(pt.x, pt.y);
|
|
167
180
|
}
|
|
@@ -378,10 +391,10 @@ function PageView({
|
|
|
378
391
|
annotationMode === 'move'
|
|
379
392
|
? 'grab'
|
|
380
393
|
: annotationMode === 'eraser'
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
394
|
+
? 'not-allowed'
|
|
395
|
+
: annotationMode === 'stamp'
|
|
396
|
+
? 'copy'
|
|
397
|
+
: 'crosshair';
|
|
385
398
|
|
|
386
399
|
return (
|
|
387
400
|
<div
|
|
@@ -512,8 +525,8 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
|
|
|
512
525
|
let pinchStart: { dist: number; zoom: number; midX: number; midY: number } | null = null;
|
|
513
526
|
|
|
514
527
|
function getTouchDist(touches: TouchList): number {
|
|
515
|
-
const dx = touches[0]
|
|
516
|
-
const dy = touches[0]
|
|
528
|
+
const dx = touches[0]!.clientX - touches[1]!.clientX;
|
|
529
|
+
const dy = touches[0]!.clientY - touches[1]!.clientY;
|
|
517
530
|
return Math.sqrt(dx * dx + dy * dy);
|
|
518
531
|
}
|
|
519
532
|
|
|
@@ -523,8 +536,8 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
|
|
|
523
536
|
pinchStart = {
|
|
524
537
|
dist: getTouchDist(e.touches),
|
|
525
538
|
zoom: zoomRef.current,
|
|
526
|
-
midX: (e.touches[0]
|
|
527
|
-
midY: (e.touches[0]
|
|
539
|
+
midX: (e.touches[0]!.clientX + e.touches[1]!.clientX) / 2 - rect.left,
|
|
540
|
+
midY: (e.touches[0]!.clientY + e.touches[1]!.clientY) / 2 - rect.top,
|
|
528
541
|
};
|
|
529
542
|
}
|
|
530
543
|
|
|
@@ -561,10 +574,10 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
|
|
|
561
574
|
|
|
562
575
|
async function load() {
|
|
563
576
|
try {
|
|
564
|
-
const task = pdfjs.getDocument(source);
|
|
577
|
+
const task = pdfjs.getDocument({ url: source, wasmUrl });
|
|
565
578
|
const loadedDoc = await task.promise;
|
|
566
579
|
if (cancelled || loadingSourceRef.current !== source) {
|
|
567
|
-
loadedDoc.destroy();
|
|
580
|
+
loadedDoc.loadingTask.destroy();
|
|
568
581
|
return;
|
|
569
582
|
}
|
|
570
583
|
const metas: PdfPageMeta[] = [];
|
|
@@ -573,7 +586,7 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
|
|
|
573
586
|
const pg = await loadedDoc.getPage(i);
|
|
574
587
|
if (cancelled) {
|
|
575
588
|
pg.cleanup();
|
|
576
|
-
loadedDoc.destroy();
|
|
589
|
+
loadedDoc.loadingTask.destroy();
|
|
577
590
|
return;
|
|
578
591
|
}
|
|
579
592
|
const viewport = pg.getViewport({ scale: 1 });
|
|
@@ -588,7 +601,7 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
|
|
|
588
601
|
});
|
|
589
602
|
pg.cleanup();
|
|
590
603
|
}
|
|
591
|
-
docRef.current?.destroy();
|
|
604
|
+
docRef.current?.loadingTask.destroy();
|
|
592
605
|
docRef.current = loadedDoc;
|
|
593
606
|
setDoc(loadedDoc);
|
|
594
607
|
setPageMetas(metas);
|
package/src/index.ts
CHANGED
package/src/pdfjs.ts
CHANGED
package/src/pdfjs.web.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { setPdfJsWorkerSrc } from './ExpoPdfMarkupView.web';
|
|
1
|
+
export { setPdfJsWorkerSrc, setPdfJsWasmUrl } from './ExpoPdfMarkupView.web';
|