@react-pdf-kit/viewer 2.9.2 → 2.10.0-beta.0
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/dist/AnnotationLayer-lagF0zYo.js +116 -0
- package/dist/{Button-DBu3SaMk.js → Button-B_yuVBQ_.js} +1 -1
- package/dist/{Checkbox-CSIEUyO8.js → Checkbox-BVARFFLh.js} +2 -2
- package/dist/{Combination-11kyhTGt.js → Combination-ILTe_xfZ.js} +2 -2
- package/dist/{Container-BuamPhw4.js → Container-CY9sCoDd.js} +1 -1
- package/dist/{DocumentDialog-cRr9sSSH.js → DocumentDialog-CYKsfOE1.js} +4 -4
- package/dist/{DropDown-CM6xEwZC.js → DropDown-DEnDtOIT.js} +2 -2
- package/dist/{Input-Dpo1Xfxe.js → Input-CVjTHdhy.js} +1 -1
- package/dist/{LoaderIcon-B3ddfd0D.js → LoaderIcon-SD35XFV2.js} +1 -1
- package/dist/{LoadingIndicator-0E8WHnSN.js → LoadingIndicator-SLpllUQ1.js} +1 -1
- package/dist/{MenuItem-lItnKNd5.js → MenuItem-DEd62cAM.js} +2 -2
- package/dist/{MenuSeparator-CaFxd8b5.js → MenuSeparator-BVQWugN3.js} +1 -1
- package/dist/{PasswordModal-CxHFn0pB.js → PasswordModal-BCjtXHN4.js} +1 -1
- package/dist/{RPDropFileZone-Bq1bzWmO.js → RPDropFileZone-lI-AmN-1.js} +3 -3
- package/dist/{RPPages-BZwgKgfJ.js → RPPages-BVSFaPUT.js} +2 -2
- package/dist/{RPTooltip-QWwWh4HW.js → RPTooltip-KdCUxOyM.js} +3 -3
- package/dist/TextHighlightLayer-BMhYl-9Q.js +162 -0
- package/dist/{TextLayer-Bp1CDIIa.js → TextLayer-CUtANGvL.js} +2 -2
- package/dist/{Thumbnail-BXMk0OWF.js → Thumbnail-BDGp0xdd.js} +3 -3
- package/dist/{Thumbnails-BIuN8LZ8.js → Thumbnails-C6maORBh.js} +1 -1
- package/dist/XfaLayer.module-w4FOd2dm.js +4 -0
- package/dist/assets/XfaLayer.css +1 -0
- package/dist/assets/style.js +1 -1
- package/dist/components/RPController.js +1 -1
- package/dist/components/RPDropFileZone.js +1 -1
- package/dist/components/RPPages.js +1 -1
- package/dist/components/RPProvider.js +1 -1
- package/dist/components/icons/DarkPdfIcon.js +1 -1
- package/dist/components/icons/LightPdfIcon.js +1 -1
- package/dist/components/icons/LoaderIcon.js +1 -1
- package/dist/components/layout/Container.js +1 -1
- package/dist/components/layout/LayoutContainer.js +2 -2
- package/dist/components/layout/LayoutWrapper.js +1 -1
- package/dist/components/layout/RPDefaultLayout.js +5 -5
- package/dist/components/layout/RPLayout.js +5 -5
- package/dist/components/layout/SkipLink.js +1 -1
- package/dist/components/layout/WrapperLayout.js +1 -1
- package/dist/components/layout/sidebar/CustomThumbnailElement.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +4 -4
- package/dist/components/layout/sidebar/RPSplitter.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/DarkModeTool.js +2 -2
- package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
- package/dist/components/layout/toolbar/DocumentProperties.js +3 -3
- package/dist/components/layout/toolbar/FileDownloadTool.js +3 -3
- package/dist/components/layout/toolbar/FileUploadTool.js +3 -3
- package/dist/components/layout/toolbar/FullScreenTool.js +3 -3
- package/dist/components/layout/toolbar/MenuItem.js +1 -1
- package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +5 -5
- package/dist/components/layout/toolbar/OtherTool.js +7 -7
- package/dist/components/layout/toolbar/Paginate.js +4 -4
- package/dist/components/layout/toolbar/PrintTool.js +3 -3
- package/dist/components/layout/toolbar/PropertyItem.js +1 -1
- package/dist/components/layout/toolbar/RPMenuItem.js +3 -3
- package/dist/components/layout/toolbar/RPMoreOptions.js +7 -7
- package/dist/components/layout/toolbar/RPToolbar.js +2 -2
- package/dist/components/layout/toolbar/RotateTool.js +5 -5
- package/dist/components/layout/toolbar/ScrollModeTool.js +3 -3
- package/dist/components/layout/toolbar/SearchCloseButton.js +3 -3
- package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -3
- package/dist/components/layout/toolbar/SearchTool.js +7 -7
- package/dist/components/layout/toolbar/SelectionModeTool.js +4 -4
- package/dist/components/layout/toolbar/ThumbnailTool.js +2 -2
- package/dist/components/layout/toolbar/ToolbarCustom.js +4 -4
- package/dist/components/layout/toolbar/ToolbarDefault.js +4 -4
- package/dist/components/layout/toolbar/ViewModeTool.js +4 -4
- package/dist/components/layout/toolbar/ZoomTool.js +8 -8
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +3 -3
- package/dist/components/layout/toolbar/tools/DualPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/InputPageTool.js +3 -3
- package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/NextPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PrintTool.js +2 -2
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +2 -2
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +3 -3
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +2 -2
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +2 -2
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +7 -7
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +2 -2
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +5 -5
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +5 -5
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +3 -3
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +4 -4
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +4 -4
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/CanvasLayer.js +1 -1
- package/dist/components/page/RPPage.js +54 -52
- package/dist/components/page/TextHighlightLayer.js +1 -1
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/components/page/XfaLayer.js +49 -0
- package/dist/components/ui/Button.js +1 -1
- package/dist/components/ui/Checkbox.js +1 -1
- package/dist/components/ui/DropDown.js +1 -1
- package/dist/components/ui/Input.js +1 -1
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/PasswordModal.js +1 -1
- package/dist/components/ui/RPTooltip.js +1 -1
- package/dist/contexts/LoaderContext.js +1 -1
- package/dist/contexts/RenderQueueProvider.js +46 -43
- package/dist/{dist-CNbFpoT1.js → dist-BgFO-PWQ.js} +1 -1
- package/dist/{dist-VbpVNBs6.js → dist-CtoH1CMU.js} +4 -4
- package/dist/{dist-B2hwhF6G.js → dist-D6Fk7CTS.js} +3 -3
- package/dist/{dist-BfuBBQ14.js → dist-SBjhcXgf.js} +1 -1
- package/dist/icons.js +3 -3
- package/dist/{main-DCzVrq0G.js → main-DrddwgsH.js} +3 -3
- package/dist/main.js +4 -4
- package/dist/{style-dcYpxEeL.js → style-DW_uCDpt.js} +1 -1
- package/dist/types/components/page/XfaLayer.d.ts +6 -0
- package/dist/types/utils/pdfOperationTracker.d.ts +20 -0
- package/dist/utils/annotations.js +72 -71
- package/dist/utils/hooks/useFileDownload.js +10 -6
- package/dist/utils/hooks/useHighlight.js +43 -42
- package/dist/utils/hooks/useLicense.js +2 -2
- package/dist/utils/hooks/useLoadPdf.js +66 -64
- package/dist/utils/hooks/usePdfProperties.js +33 -32
- package/dist/utils/hooks/usePrint.js +123 -88
- package/dist/utils/hooks/useSearch.js +84 -83
- package/dist/utils/hooks/useWatermark.js +1 -1
- package/dist/utils/injectPrintCSS.js +1 -1
- package/dist/utils/link_service.js +33 -17
- package/dist/utils/pdfOperationTracker.js +27 -4
- package/package.json +1 -1
- package/dist/AnnotationLayer-oDu2B4X1.js +0 -114
- package/dist/TextHighlightLayer-3vIZbRyL.js +0 -157
- /package/dist/{CanvasLayer-C3gb8EXu.js → CanvasLayer-DkVH-tX2.js} +0 -0
- /package/dist/{CustomThumbnailElement-C2quEICO.js → CustomThumbnailElement-BxTSbzpP.js} +0 -0
- /package/dist/{DarkPdfIcon-B5ehd9CV.js → DarkPdfIcon-2aDGWxuA.js} +0 -0
- /package/dist/{LightPdfIcon-DL8MYtWQ.js → LightPdfIcon-LatCGY0T.js} +0 -0
- /package/dist/{MostPageTool.module-BRVv-sGz.js → MostPageTool.module-BP2BMoK8.js} +0 -0
- /package/dist/{OtherTool.module-BQY9Nfqz.js → OtherTool.module-CMbI70sn.js} +0 -0
- /package/dist/{Paginate.module-DhE7N8AA.js → Paginate.module-DxXyYoYp.js} +0 -0
- /package/dist/{PropertyItem-evJWWmWZ.js → PropertyItem-CmRC2e5Z.js} +0 -0
- /package/dist/{RPLayout.module-BH5r8dDc.js → RPLayout.module-DLX1UwA3.js} +0 -0
- /package/dist/{RPSplitter-C63X9M8w.js → RPSplitter-DGnDuwsT.js} +0 -0
- /package/dist/{RPToolbar.module-BwqWLviy.js → RPToolbar.module-ODOa9FwW.js} +0 -0
- /package/dist/{RotateTool.module-DH5yWbvM.js → RotateTool.module-BHFeo1yn.js} +0 -0
- /package/dist/{SearchTool.module-DY8Ucfb_.js → SearchTool.module-BQDBENlo.js} +0 -0
- /package/dist/{SkipLink-Dj83gZdk.js → SkipLink-mnqFQj0O.js} +0 -0
- /package/dist/{ToolbarLayout.module-Zo715dbb.js → ToolbarLayout.module-BC9eQ9LN.js} +0 -0
- /package/dist/{WrapperLayout-Dcd9l9xH.js → WrapperLayout-NjsBnUaz.js} +0 -0
- /package/dist/{ZoomTool.module-BrIPy8pO.js → ZoomTool.module-DO-r2IDy.js} +0 -0
- /package/dist/{clsx-DSGuh5YW.js → clsx-BD2qMUU1.js} +0 -0
- /package/dist/{dist-CgoP608h.js → dist-DjD1zIE0.js} +0 -0
- /package/dist/{lib-CSInlR9T.js → lib-DTkzWIMS.js} +0 -0
- /package/dist/{useWatermark-CvAAf66v.js → useWatermark-DlRNcg9p.js} +0 -0
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isPdfDocumentDestroyedError as e, runPdfOperation as t } from "../pdfOperationTracker.js";
|
|
2
|
+
import { convertPDFDate as n } from "../convertPdfDate.js";
|
|
3
|
+
import { formatFileSize as r } from "../formatFileSize.js";
|
|
4
|
+
import { useCallback as i, useEffect as a, useState as o } from "react";
|
|
4
5
|
//#region lib/utils/hooks/usePdfProperties.ts
|
|
5
|
-
var
|
|
6
|
-
let [
|
|
7
|
-
if (!
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
pdfVersion: i.PDFFormatVersion
|
|
6
|
+
var s = (s, c, l) => {
|
|
7
|
+
let [u, d] = o(), f = i(async () => {
|
|
8
|
+
if (!(!c || !s)) try {
|
|
9
|
+
let e = await t(c, () => c.getMetadata()), i = c.numPages, a = e?.info, o = await t(c, () => c.getDownloadInfo()), s = 0;
|
|
10
|
+
o && (s = o.length);
|
|
11
|
+
let u = n(a.CreationDate), f = n(a.ModDate);
|
|
12
|
+
d({
|
|
13
|
+
pageCount: i,
|
|
14
|
+
filename: l || "",
|
|
15
|
+
fileSize: r(s),
|
|
16
|
+
title: a.Title,
|
|
17
|
+
author: a.Author,
|
|
18
|
+
subject: a.Subject,
|
|
19
|
+
keywords: a.Keywords || "",
|
|
20
|
+
creator: a.Creator,
|
|
21
|
+
createdOn: u?.toISOString() || "",
|
|
22
|
+
modifiedOn: f?.toISOString() || "",
|
|
23
|
+
pdfProducer: a.Producer,
|
|
24
|
+
pdfVersion: a.PDFFormatVersion
|
|
25
25
|
});
|
|
26
|
-
} catch (
|
|
27
|
-
|
|
26
|
+
} catch (t) {
|
|
27
|
+
if (e(t)) return;
|
|
28
|
+
console.log("properties err", t);
|
|
28
29
|
}
|
|
29
30
|
}, [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
c,
|
|
32
|
+
l,
|
|
33
|
+
s
|
|
33
34
|
]);
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
}, [
|
|
35
|
+
return a(() => {
|
|
36
|
+
f();
|
|
37
|
+
}, [f]), u;
|
|
37
38
|
};
|
|
38
39
|
//#endregion
|
|
39
|
-
export {
|
|
40
|
+
export { s as usePdfProperties };
|
|
@@ -1,69 +1,72 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { runPdfOperation as e } from "../pdfOperationTracker.js";
|
|
3
|
+
import { useDocumentContext as t } from "../../contexts/RPDocumentContext.js";
|
|
4
|
+
import { SimpleLinkService as n } from "../link_service.js";
|
|
5
|
+
import { t as r } from "../../XfaLayer.module-w4FOd2dm.js";
|
|
6
|
+
import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
|
|
7
|
+
import { AnnotationMode as c, PixelsPerInch as l, RenderingCancelledException as u, XfaLayer as d, getXfaPageViewport as f } from "pdfjs-dist";
|
|
5
8
|
//#region lib/utils/hooks/usePrint.ts
|
|
6
|
-
var
|
|
7
|
-
let { pdf:
|
|
9
|
+
var p = () => {
|
|
10
|
+
let { pdf: p, pages: m } = t(), [h, g] = s({
|
|
8
11
|
loadedPages: 0,
|
|
9
12
|
totalPages: 0,
|
|
10
13
|
percentage: 0
|
|
11
|
-
}), [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, [
|
|
15
|
-
let
|
|
14
|
+
}), [_, v] = s(!1), [y, b] = s(!1), [x, S] = s(null), [C, w] = s(void 0), T = o(!1);
|
|
15
|
+
a(() => {
|
|
16
|
+
T.current;
|
|
17
|
+
}, [T]);
|
|
18
|
+
let E = i(() => {
|
|
16
19
|
document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
|
|
17
20
|
let e = document.querySelector(".rp-print-zone");
|
|
18
21
|
e && e.remove();
|
|
19
|
-
}, []),
|
|
20
|
-
|
|
22
|
+
}, []), D = i(() => {
|
|
23
|
+
T.current = !1, v(!1), b(!1), S(null), w(void 0), g({
|
|
21
24
|
loadedPages: 0,
|
|
22
25
|
totalPages: 0,
|
|
23
26
|
percentage: 0
|
|
24
27
|
});
|
|
25
|
-
}, []),
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
if (
|
|
29
|
-
|
|
28
|
+
}, []), O = () => {
|
|
29
|
+
T.current = !0;
|
|
30
|
+
}, k = async ({ scratchCanvas: t, pdfDocument: n, pageNumber: r, viewerPdfPage: i, printResolution: a, optionalContentConfigPromise: o, printAnnotationStoragePromise: s }) => {
|
|
31
|
+
if (T.current) {
|
|
32
|
+
D();
|
|
30
33
|
return;
|
|
31
34
|
}
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
let [
|
|
37
|
-
if (
|
|
38
|
-
|
|
35
|
+
let d = a / l.PDF;
|
|
36
|
+
t.width = Math.floor(i.width * d), t.height = Math.floor(i.height * d);
|
|
37
|
+
let f = t.getContext("2d");
|
|
38
|
+
f.save(), f.fillStyle = "rgb(255, 255, 255)", f.fillRect(0, 0, t.width, t.height), f.restore();
|
|
39
|
+
let [p, m] = await Promise.all([e(n, () => n.getPage(r)), s]);
|
|
40
|
+
if (T.current) {
|
|
41
|
+
D();
|
|
39
42
|
return;
|
|
40
43
|
}
|
|
41
|
-
let
|
|
42
|
-
canvas:
|
|
43
|
-
canvasContext:
|
|
44
|
+
let h = {
|
|
45
|
+
canvas: t,
|
|
46
|
+
canvasContext: f,
|
|
44
47
|
transform: [
|
|
45
|
-
|
|
48
|
+
d,
|
|
46
49
|
0,
|
|
47
50
|
0,
|
|
48
|
-
|
|
51
|
+
d,
|
|
49
52
|
0,
|
|
50
53
|
0
|
|
51
54
|
],
|
|
52
|
-
viewport:
|
|
55
|
+
viewport: p.getViewport({
|
|
53
56
|
scale: 1,
|
|
54
|
-
rotation:
|
|
57
|
+
rotation: i.rotation
|
|
55
58
|
}),
|
|
56
59
|
intent: "print",
|
|
57
|
-
annotationMode:
|
|
58
|
-
optionalContentConfigPromise:
|
|
59
|
-
printAnnotationStorage:
|
|
60
|
+
annotationMode: c.ENABLE_STORAGE,
|
|
61
|
+
optionalContentConfigPromise: o,
|
|
62
|
+
printAnnotationStorage: m
|
|
60
63
|
};
|
|
61
64
|
try {
|
|
62
|
-
return
|
|
65
|
+
return p.render(h).promise;
|
|
63
66
|
} catch (e) {
|
|
64
|
-
throw e instanceof
|
|
67
|
+
throw e instanceof u || console.error(e), e;
|
|
65
68
|
}
|
|
66
|
-
},
|
|
69
|
+
}, A = i(() => {
|
|
67
70
|
let e = window.print;
|
|
68
71
|
return new Promise((t) => {
|
|
69
72
|
let n = (t) => {
|
|
@@ -83,10 +86,29 @@ var c = () => {
|
|
|
83
86
|
subtree: !0
|
|
84
87
|
});
|
|
85
88
|
});
|
|
86
|
-
}, []),
|
|
87
|
-
let
|
|
88
|
-
return
|
|
89
|
-
},
|
|
89
|
+
}, []), j = (e, t) => {
|
|
90
|
+
let n = document.createElement("img"), r = document.createElement("div"), i = document.createElement("div");
|
|
91
|
+
return r.classList.add("rp-print-page"), i.classList.add("rp-print-page-content"), i.style.width = `${t.width}pt`, i.style.height = `${t.height}pt`, n.src = e.toDataURL(), i.appendChild(n), r.appendChild(i), r;
|
|
92
|
+
}, M = (e) => {
|
|
93
|
+
let t = e.allXfaHtml;
|
|
94
|
+
if (!t?.children?.length) return [];
|
|
95
|
+
let i = new n(e, () => {}), a = Math.round(l.PDF_TO_CSS_UNITS * 100) / 100;
|
|
96
|
+
return t.children.map((t) => {
|
|
97
|
+
let n = document.createElement("div");
|
|
98
|
+
n.classList.add("rp-print-page", "rp-print-xfa-page");
|
|
99
|
+
let o = document.createElement("div");
|
|
100
|
+
o.className = r["rp-xfa-layer"];
|
|
101
|
+
let s = document.createElement("div");
|
|
102
|
+
return o.appendChild(s), n.appendChild(o), d.render({
|
|
103
|
+
div: s,
|
|
104
|
+
viewport: f(t, { scale: a }).clone({ dontFlip: !0 }),
|
|
105
|
+
xfaHtml: t,
|
|
106
|
+
annotationStorage: e.annotationStorage,
|
|
107
|
+
linkService: i,
|
|
108
|
+
intent: "print"
|
|
109
|
+
}), n;
|
|
110
|
+
});
|
|
111
|
+
}, N = (e, t) => {
|
|
90
112
|
let n = document.createElement("div");
|
|
91
113
|
n.classList.add("rp-print-zone");
|
|
92
114
|
let r = document.createElement("style"), i = t.get(1);
|
|
@@ -95,74 +117,87 @@ var c = () => {
|
|
|
95
117
|
r.innerHTML = `@page { size: ${e}pt ${t}pt; margin: 0; }`;
|
|
96
118
|
}
|
|
97
119
|
return n.appendChild(r), n.append(...e), n;
|
|
98
|
-
},
|
|
99
|
-
if (!
|
|
100
|
-
|
|
101
|
-
let
|
|
102
|
-
|
|
103
|
-
let
|
|
120
|
+
}, P = i(async (t) => {
|
|
121
|
+
if (!p) return;
|
|
122
|
+
D();
|
|
123
|
+
let n = t && "visibleDefaultProgress" in t ? t : void 0;
|
|
124
|
+
n?.visibleDefaultProgress === void 0 ? w(!0) : w(n.visibleDefaultProgress);
|
|
125
|
+
let r = document.createElement("canvas"), i = [];
|
|
104
126
|
try {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
if (p.isPureXfa) {
|
|
128
|
+
if (i.push(...M(p)), T.current) {
|
|
129
|
+
D();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
let e = N(i, m);
|
|
133
|
+
document.body.appendChild(e), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), g({
|
|
134
|
+
loadedPages: i.length,
|
|
135
|
+
totalPages: i.length,
|
|
136
|
+
percentage: 100
|
|
137
|
+
}), v(!0), await A();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
let t = e(p, () => p.getOptionalContentConfig({ intent: "print" })), n = Promise.resolve(p.annotationStorage.print ?? void 0), a = m.size;
|
|
141
|
+
for (let [e, o] of m) {
|
|
142
|
+
if (T.current) {
|
|
143
|
+
D();
|
|
110
144
|
return;
|
|
111
145
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
146
|
+
let s = o.page.getViewport({ scale: 1 });
|
|
147
|
+
if (await k({
|
|
148
|
+
scratchCanvas: r,
|
|
149
|
+
pdfDocument: p,
|
|
150
|
+
pageNumber: e,
|
|
151
|
+
viewerPdfPage: s,
|
|
117
152
|
printResolution: 150,
|
|
118
|
-
optionalContentConfigPromise:
|
|
119
|
-
printAnnotationStoragePromise:
|
|
120
|
-
}),
|
|
121
|
-
|
|
153
|
+
optionalContentConfigPromise: t,
|
|
154
|
+
printAnnotationStoragePromise: n
|
|
155
|
+
}), T.current) {
|
|
156
|
+
D();
|
|
122
157
|
return;
|
|
123
158
|
}
|
|
124
|
-
let
|
|
125
|
-
|
|
126
|
-
loadedPages:
|
|
127
|
-
totalPages:
|
|
128
|
-
percentage: parseFloat((
|
|
159
|
+
let c = j(r, s);
|
|
160
|
+
i.push(c), g({
|
|
161
|
+
loadedPages: e,
|
|
162
|
+
totalPages: a,
|
|
163
|
+
percentage: parseFloat((i.length / a * 100).toFixed(2))
|
|
129
164
|
});
|
|
130
165
|
}
|
|
131
|
-
if (
|
|
132
|
-
|
|
166
|
+
if (T.current) {
|
|
167
|
+
D();
|
|
133
168
|
return;
|
|
134
169
|
}
|
|
135
|
-
let
|
|
136
|
-
document.body.appendChild(
|
|
170
|
+
let o = N(i, m);
|
|
171
|
+
document.body.appendChild(o), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), v(!0), await A();
|
|
137
172
|
} catch (e) {
|
|
138
|
-
|
|
173
|
+
b(!0), e instanceof Error && S(e);
|
|
139
174
|
} finally {
|
|
140
|
-
|
|
175
|
+
r.height = 0, r.width = 0;
|
|
141
176
|
}
|
|
142
177
|
}, [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
S,
|
|
178
|
+
p,
|
|
179
|
+
m,
|
|
180
|
+
T,
|
|
147
181
|
D,
|
|
148
|
-
|
|
182
|
+
N,
|
|
183
|
+
A
|
|
149
184
|
]);
|
|
150
|
-
return
|
|
185
|
+
return a(() => {
|
|
151
186
|
let e = () => {
|
|
152
|
-
|
|
187
|
+
D(), E();
|
|
153
188
|
};
|
|
154
189
|
return window.addEventListener("afterprint", e, !0), () => {
|
|
155
190
|
window.removeEventListener("afterprint", e, !0);
|
|
156
191
|
};
|
|
157
|
-
}, [
|
|
158
|
-
print:
|
|
159
|
-
cancel:
|
|
160
|
-
progress:
|
|
161
|
-
isComplete:
|
|
162
|
-
isError:
|
|
163
|
-
error:
|
|
164
|
-
showDefaultProgress:
|
|
192
|
+
}, [E, D]), {
|
|
193
|
+
print: P,
|
|
194
|
+
cancel: O,
|
|
195
|
+
progress: h,
|
|
196
|
+
isComplete: _,
|
|
197
|
+
isError: y,
|
|
198
|
+
error: x,
|
|
199
|
+
showDefaultProgress: C
|
|
165
200
|
};
|
|
166
201
|
};
|
|
167
202
|
//#endregion
|
|
168
|
-
export {
|
|
203
|
+
export { p as usePrint };
|
|
@@ -1,125 +1,126 @@
|
|
|
1
1
|
import { ScrollMode as e } from "../types.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
2
|
+
import { runPdfOperation as t } from "../pdfOperationTracker.js";
|
|
3
|
+
import { useDocumentContext as n } from "../../contexts/RPDocumentContext.js";
|
|
4
|
+
import { useScrollModeContext as r } from "../../contexts/ScrollModeContext.js";
|
|
5
|
+
import { useViewModeContext as i } from "../../contexts/ViewModeContext.js";
|
|
6
|
+
import { useVirtualScrollContext as a } from "../../contexts/VirtualScrollContext.js";
|
|
7
|
+
import { useLayoutContainer as o } from "../../contexts/LayoutContainerContext.js";
|
|
8
|
+
import { useZoomContext as s } from "../../contexts/ZoomContext.js";
|
|
9
|
+
import { usePagesRotateContext as c } from "../../contexts/PagesRotateContext.js";
|
|
10
|
+
import { useDimensionPagesContext as l } from "../../contexts/DimensionPagesContext.js";
|
|
11
|
+
import { useSmoothScrollContext as u } from "../../contexts/SmoothScrollContext.js";
|
|
12
|
+
import { buildDocumentLayout as d, getPagePlacement as f } from "../documentLayout.js";
|
|
13
|
+
import { r as p } from "../../PaginationContext-DIzsZhFd.js";
|
|
14
|
+
import { findMatches as m } from "../highlight.js";
|
|
15
|
+
import { getWordPositionInPage as h } from "../getWordPositionInPage.js";
|
|
16
|
+
import { useCallback as g, useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
16
17
|
//#region lib/utils/hooks/useSearch.ts
|
|
17
|
-
var
|
|
18
|
-
let [
|
|
18
|
+
var x = (x = {}, S = "") => {
|
|
19
|
+
let [C, w] = b(S), [T, E] = b(!1), { pdf: D, pages: O } = n(), { widths: k, heights: A } = l(), j = y(!C), { currentZoom: M } = s(), [N, P] = b([]), { setFocusedPage: F } = p(), { viewMode: I } = i(), { pageRotate: L } = c(), [R, z] = b(0), { pageScrollElementRef: B, virtualScrollableElementRef: V } = a(), { scrollMode: H } = r(), { pagesRef: U } = o(), { scrollBehavior: W } = u(), G = y({}), K = y(0), q = v(() => R === 0 ? null : N[R - 1], [R, N]), J = v(() => N.length, [N]), Y = g((t) => {
|
|
19
20
|
if (t === 0) return;
|
|
20
|
-
let n =
|
|
21
|
-
if (!n || !
|
|
22
|
-
let r =
|
|
23
|
-
if (!r || !
|
|
24
|
-
let i =
|
|
25
|
-
if (
|
|
26
|
-
let a =
|
|
21
|
+
let n = N[t - 1];
|
|
22
|
+
if (!n || !O) return;
|
|
23
|
+
let r = V || B;
|
|
24
|
+
if (!r || !U) return;
|
|
25
|
+
let i = O.get(n.page);
|
|
26
|
+
if (H === e.PAGE_SCROLLING && F(n.page), !i) return;
|
|
27
|
+
let a = d({
|
|
27
28
|
pageDimensions: {
|
|
28
|
-
widths:
|
|
29
|
-
heights:
|
|
29
|
+
widths: k,
|
|
30
|
+
heights: A
|
|
30
31
|
},
|
|
31
32
|
viewportWidth: r.clientWidth,
|
|
32
33
|
viewportHeight: r.clientHeight,
|
|
33
|
-
scrollMode:
|
|
34
|
-
viewMode:
|
|
34
|
+
scrollMode: H,
|
|
35
|
+
viewMode: I,
|
|
35
36
|
focusedPage: n.page
|
|
36
|
-
}), o =
|
|
37
|
+
}), o = f(a, n.page);
|
|
37
38
|
if (!o) return;
|
|
38
39
|
let s = {
|
|
39
|
-
height:
|
|
40
|
-
width:
|
|
41
|
-
}, c =
|
|
40
|
+
height: A[n.page - 1],
|
|
41
|
+
width: k[n.page - 1]
|
|
42
|
+
}, c = L[n.page], { leftInPage: l, topInPage: u } = h(s, U, n.rect, M, c), p = a.offsetLeft + o.left + l, m = a.offsetTop + o.top + u, g = {
|
|
42
43
|
left: Math.max(p, 0),
|
|
43
|
-
top: Math.max(
|
|
44
|
+
top: Math.max(m, 0)
|
|
44
45
|
};
|
|
45
46
|
r.scrollTo({
|
|
46
47
|
...g,
|
|
47
|
-
behavior:
|
|
48
|
+
behavior: W
|
|
48
49
|
});
|
|
49
50
|
}, [
|
|
50
|
-
D,
|
|
51
|
-
P,
|
|
52
51
|
O,
|
|
52
|
+
F,
|
|
53
53
|
k,
|
|
54
|
+
A,
|
|
55
|
+
H,
|
|
56
|
+
I,
|
|
54
57
|
V,
|
|
55
|
-
F,
|
|
56
58
|
B,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
U,
|
|
60
|
+
N,
|
|
59
61
|
M,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
U
|
|
62
|
+
L,
|
|
63
|
+
W
|
|
63
64
|
]);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}, [
|
|
67
|
-
let
|
|
68
|
-
|
|
65
|
+
_(() => {
|
|
66
|
+
R && Y(R);
|
|
67
|
+
}, [R]);
|
|
68
|
+
let X = g(() => {
|
|
69
|
+
z((e) => {
|
|
69
70
|
let t;
|
|
70
|
-
return t =
|
|
71
|
-
}),
|
|
72
|
-
}, [
|
|
73
|
-
|
|
71
|
+
return t = J ? e + 1 > J ? 1 : e + 1 : 0, K.current = t, t;
|
|
72
|
+
}), K.current === 1 && Y(K.current);
|
|
73
|
+
}, [J, Y]), Z = g(() => {
|
|
74
|
+
z((e) => {
|
|
74
75
|
let t;
|
|
75
|
-
return t =
|
|
76
|
-
}),
|
|
77
|
-
}, [
|
|
76
|
+
return t = J ? e - 1 <= 0 ? J : e - 1 : 0, K.current = t, t;
|
|
77
|
+
}), K.current === 1 && Y(K.current);
|
|
78
|
+
}, [J, Y]), Q = g(async (e) => {
|
|
78
79
|
if (!e) return {};
|
|
79
|
-
let
|
|
80
|
-
for (let
|
|
81
|
-
if (
|
|
82
|
-
let
|
|
83
|
-
|
|
80
|
+
let n = e.numPages, r = {};
|
|
81
|
+
for (let i = 1; i <= n; i++) {
|
|
82
|
+
if (j.current) throw "close pop over";
|
|
83
|
+
let n = await t(e, () => e.getPage(i));
|
|
84
|
+
r[i.toString()] = await t(e, () => n.getTextContent());
|
|
84
85
|
}
|
|
85
|
-
return
|
|
86
|
+
return r;
|
|
86
87
|
}, []);
|
|
87
|
-
return
|
|
88
|
-
if (!
|
|
89
|
-
|
|
88
|
+
return _(() => {
|
|
89
|
+
if (!C) {
|
|
90
|
+
j.current = !0, P([]), z(0);
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
j.current = !1, E(!0), P([]), z(0), Q(D).then((e) => {
|
|
94
|
+
G.current = e;
|
|
94
95
|
let t = Object.keys(e).reduce((t, n) => {
|
|
95
|
-
let r =
|
|
96
|
+
let r = m([C], e[n], Number(n) - 1, x).map((e, t) => ({
|
|
96
97
|
...e,
|
|
97
98
|
page: Number(n),
|
|
98
99
|
pageMatchIdx: t
|
|
99
100
|
}));
|
|
100
101
|
return [...t, ...r];
|
|
101
102
|
}, []);
|
|
102
|
-
|
|
103
|
+
P(t), z(+!!t.length);
|
|
103
104
|
}).catch(() => {
|
|
104
|
-
|
|
105
|
-
}).finally(() =>
|
|
105
|
+
P([]), z(0);
|
|
106
|
+
}).finally(() => E(!1));
|
|
106
107
|
}, [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
C,
|
|
109
|
+
Q,
|
|
110
|
+
D,
|
|
111
|
+
x
|
|
111
112
|
]), {
|
|
112
|
-
search:
|
|
113
|
-
setSearch:
|
|
114
|
-
loading:
|
|
115
|
-
matches:
|
|
116
|
-
totalMatches:
|
|
117
|
-
currentMatchPosition:
|
|
118
|
-
currentMatch:
|
|
119
|
-
nextMatch:
|
|
120
|
-
prevMatch:
|
|
121
|
-
setCurrentMatchPosition:
|
|
113
|
+
search: C,
|
|
114
|
+
setSearch: w,
|
|
115
|
+
loading: T,
|
|
116
|
+
matches: N,
|
|
117
|
+
totalMatches: J,
|
|
118
|
+
currentMatchPosition: R,
|
|
119
|
+
currentMatch: q,
|
|
120
|
+
nextMatch: X,
|
|
121
|
+
prevMatch: Z,
|
|
122
|
+
setCurrentMatchPosition: z
|
|
122
123
|
};
|
|
123
124
|
};
|
|
124
125
|
//#endregion
|
|
125
|
-
export {
|
|
126
|
+
export { x as useSearch };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../useWatermark-
|
|
1
|
+
import { t as e } from "../../useWatermark-DlRNcg9p.js";
|
|
2
2
|
export { e as useWatermark };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
function e() {
|
|
3
3
|
if (typeof document > "u" || document.getElementById("rp-print-style")) return;
|
|
4
4
|
let e = document.createElement("style");
|
|
5
|
-
e.id = "rp-print-style", e.textContent = "\n @page { margin: 0; }\n\n .rp-print-zone { display: none; }\n\n @media print {\n .rp-print-html-printing { height: 100%; }\n .rp-print-body-printing { background: rgb(0 0 0 / 0) none; height: 100% !important; margin: 0 !important; display: block !important; }\n .rp-print-body-printing
|
|
5
|
+
e.id = "rp-print-style", e.textContent = "\n @page { margin: 0; }\n\n .rp-print-zone { display: none; }\n\n @media print {\n .rp-print-html-printing { height: 100%; }\n .rp-print-body-printing { background: rgb(0 0 0 / 0) none; height: 100% !important; margin: 0 !important; display: block !important; }\n .rp-print-body-printing > *:not(.rp-print-zone) { display: none; }\n .rp-print-zone { display: block; height: 100%; }\n .rp-print-page { display: flex; align-items: center; flex-direction: column; justify-content: center; height: 100%; width: 100%; page-break-after: always; page-break-inside: avoid; }\n .rp-print-page:last-child { page-break-after: auto; }\n .rp-print-page-content { position: relative; flex: 0 0 auto; }\n .rp-print-page:not(.rp-print-xfa-page) img, .rp-print-page canvas { display: block; max-width: 100%; max-height: 100%; direction: ltr; }\n .rp-print-page.rp-print-xfa-page { display: block; position: relative; }\n .rp-print-xfa-page .xfaPage { position: absolute; }\n }\n ", document.head.appendChild(e);
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { e as injectPrintCSS };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { isPdfDestroyed as e, isPdfDocumentDestroyedError as t, runPdfOperation as n } from "./pdfOperationTracker.js";
|
|
1
2
|
//#region lib/utils/link_service.ts
|
|
2
|
-
var
|
|
3
|
+
var r = class {
|
|
3
4
|
externalLinkEnabled;
|
|
4
5
|
pdfDocument;
|
|
5
6
|
constructor(e, t) {
|
|
@@ -19,26 +20,41 @@ var e = class {
|
|
|
19
20
|
get isInPresentationMode() {
|
|
20
21
|
return !1;
|
|
21
22
|
}
|
|
22
|
-
async goToDestination(
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
25
|
-
|
|
23
|
+
async goToDestination(r) {
|
|
24
|
+
let i, a;
|
|
25
|
+
if (typeof r == "string") {
|
|
26
|
+
let a = this.pdfDocument;
|
|
27
|
+
if (!a || e(a)) return;
|
|
28
|
+
try {
|
|
29
|
+
i = await n(a, () => a.getDestination(r));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (t(e)) return;
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
} else i = await r;
|
|
35
|
+
if (!Array.isArray(i)) {
|
|
36
|
+
console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${r}".`);
|
|
26
37
|
return;
|
|
27
38
|
}
|
|
28
|
-
let [
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
let [o] = i;
|
|
40
|
+
if (o && typeof o == "object") {
|
|
41
|
+
if (a = this.pdfDocument?.cachedPageNumber(o), !a) {
|
|
42
|
+
let i = this.pdfDocument;
|
|
43
|
+
if (!i || e(i)) return;
|
|
44
|
+
try {
|
|
45
|
+
a = (await n(i, () => i.getPageIndex(o)) || 0) + 1;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (t(e)) return;
|
|
48
|
+
console.error(`goToDestination: "${o}" is not a valid page reference, for dest="${r}".`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
35
51
|
}
|
|
36
|
-
} else Number.isInteger(
|
|
37
|
-
if (!
|
|
38
|
-
console.error(`goToDestination: "${
|
|
52
|
+
} else Number.isInteger(o) && (a = o + 1);
|
|
53
|
+
if (!a || a < 1 || a > this.pagesCount) {
|
|
54
|
+
console.error(`goToDestination: "${a}" is not a valid page number, for dest="${r}".`);
|
|
39
55
|
return;
|
|
40
56
|
}
|
|
41
|
-
this.goToPage(
|
|
57
|
+
this.goToPage(a);
|
|
42
58
|
}
|
|
43
59
|
goToPage(e) {}
|
|
44
60
|
goToXY(e, t, n, r = {}) {}
|
|
@@ -57,4 +73,4 @@ var e = class {
|
|
|
57
73
|
cachePageRef(e, t) {}
|
|
58
74
|
};
|
|
59
75
|
//#endregion
|
|
60
|
-
export {
|
|
76
|
+
export { r as SimpleLinkService };
|