@react-pdf-kit/viewer 2.0.1-rc.3 → 2.0.1-rc.5

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.
Files changed (83) hide show
  1. package/dist/{Combination-136ff99c.js → Combination-17ab8af1.js} +2 -2
  2. package/dist/assets/style.css +1 -1
  3. package/dist/components/layout/RPDefaultLayout.js +6 -6
  4. package/dist/components/layout/RPLayout.js +6 -6
  5. package/dist/components/layout/sidebar/RPSidebar.js +4 -4
  6. package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
  7. package/dist/components/layout/toolbar/DocumentDialog.js +3 -3
  8. package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
  9. package/dist/components/layout/toolbar/FileDownloadTool.js +6 -6
  10. package/dist/components/layout/toolbar/FileUploadTool.js +6 -6
  11. package/dist/components/layout/toolbar/FullScreenTool.js +6 -6
  12. package/dist/components/layout/toolbar/MenuItem.js +6 -6
  13. package/dist/components/layout/toolbar/MenuSeparator.js +6 -6
  14. package/dist/components/layout/toolbar/MostPageTool.js +6 -6
  15. package/dist/components/layout/toolbar/OtherTool.js +6 -6
  16. package/dist/components/layout/toolbar/Paginate.js +4 -4
  17. package/dist/components/layout/toolbar/PrintTool.js +6 -6
  18. package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
  19. package/dist/components/layout/toolbar/RPMoreOptions.js +6 -6
  20. package/dist/components/layout/toolbar/RPToolbar.js +6 -6
  21. package/dist/components/layout/toolbar/RPToolbarEnd.js +6 -6
  22. package/dist/components/layout/toolbar/RotateTool.js +6 -6
  23. package/dist/components/layout/toolbar/ScrollModeTool.js +6 -6
  24. package/dist/components/layout/toolbar/SearchCloseButton.js +4 -4
  25. package/dist/components/layout/toolbar/SearchResultNavigator.js +4 -4
  26. package/dist/components/layout/toolbar/SearchTool.js +6 -6
  27. package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
  28. package/dist/components/layout/toolbar/ThumbnailTool.js +4 -4
  29. package/dist/components/layout/toolbar/ToolbarDefault.js +6 -6
  30. package/dist/components/layout/toolbar/ToolbarLayout.js +6 -6
  31. package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
  32. package/dist/components/layout/toolbar/ZoomTool.js +6 -6
  33. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +5 -5
  34. package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
  35. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +6 -6
  36. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +4 -4
  37. package/dist/components/layout/toolbar/tools/FileUploadTool.js +4 -4
  38. package/dist/components/layout/toolbar/tools/FirstPageTool.js +6 -6
  39. package/dist/components/layout/toolbar/tools/FullScreenTool.js +4 -4
  40. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +4 -4
  41. package/dist/components/layout/toolbar/tools/InputPageTool.js +4 -4
  42. package/dist/components/layout/toolbar/tools/LastPageTool.js +6 -6
  43. package/dist/components/layout/toolbar/tools/NextPageTool.js +4 -4
  44. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
  45. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +4 -4
  46. package/dist/components/layout/toolbar/tools/PrintTool.js +4 -4
  47. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +4 -4
  48. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +4 -4
  49. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +4 -4
  50. package/dist/components/layout/toolbar/tools/SinglePageTool.js +4 -4
  51. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +4 -4
  52. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +4 -4
  53. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
  54. package/dist/components/layout/toolbar/tools/ZoomInTool.js +4 -4
  55. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +6 -6
  56. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +4 -4
  57. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +6 -6
  58. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +4 -4
  59. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
  60. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +6 -6
  61. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +6 -6
  62. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
  63. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +6 -6
  64. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +6 -6
  65. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +6 -6
  66. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +6 -6
  67. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +6 -6
  68. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +6 -6
  69. package/dist/components/ui/Checkbox.js +2 -2
  70. package/dist/components/ui/DropDown.js +6 -6
  71. package/dist/components/ui/RPTooltip.js +197 -411
  72. package/dist/{index-c0faa594.js → index-113053cf.js} +2 -2
  73. package/dist/index-11f3cd64.js +983 -0
  74. package/dist/{index-e3ee9457.js → index-23911b43.js} +6 -6
  75. package/dist/{index-655864a7.js → index-ada501c4.js} +1 -1
  76. package/dist/index-d0f0aa9a.js +1542 -0
  77. package/dist/main.js +6 -6
  78. package/dist/utils/hooks/useLicense.js +1 -1
  79. package/dist/utils/hooks/usePrint.js +67 -63
  80. package/dist/utils/injectPrintCSS.js +1 -1
  81. package/package.json +1 -1
  82. package/dist/floating-ui.react-dom-5ec29bd6.js +0 -1327
  83. package/dist/index-61f59539.js +0 -1198
package/dist/main.js CHANGED
@@ -135,17 +135,17 @@ import "./contexts/IconContext.js";
135
135
  import "./contexts/ToolbarComponentContext.js";
136
136
  import "./contexts/ViewportContext.js";
137
137
  import "./components/ui/RPTooltip.js";
138
- import "./index-c0faa594.js";
138
+ import "./index-113053cf.js";
139
139
  import "react-dom";
140
- import "./index-e3ee9457.js";
141
- import "./floating-ui.react-dom-5ec29bd6.js";
142
- import "./index-655864a7.js";
140
+ import "./index-23911b43.js";
141
+ import "./index-d0f0aa9a.js";
142
+ import "./index-ada501c4.js";
143
143
  import "./components/layout/toolbar/RPToolbarEnd.js";
144
144
  import "./components/layout/toolbar/FileUploadTool.js";
145
145
  import "./components/icons/FileUploadDefaultIcon.js";
146
146
  import "./components/layout/toolbar/MenuItem.js";
147
- import "./index-61f59539.js";
148
- import "./Combination-136ff99c.js";
147
+ import "./index-11f3cd64.js";
148
+ import "./Combination-17ab8af1.js";
149
149
  import "./components/layout/toolbar/DarkModeTool.js";
150
150
  import "./components/icons/MoonIcon.js";
151
151
  import "./components/icons/SunIcon.js";
@@ -1,6 +1,6 @@
1
1
  import { useState as E, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2026-02-24T10:07:57.864Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2026-02-27T08:05:26.900Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
4
  invalidLicense: `You are currently using without a valid license. ${d}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
6
  expired: `Your license key has expired. ${d}`,
@@ -1,6 +1,6 @@
1
- import { useState as m, useRef as X, useEffect as D, useCallback as g } from "react";
2
- import { useDocumentContext as k } from "../../contexts/RPDocumentContext.js";
3
- import { PixelsPerInch as q, AnnotationMode as O, RenderingCancelledException as U } from "pdfjs-dist";
1
+ import { useState as g, useRef as k, useEffect as D, useCallback as P } from "react";
2
+ import { useDocumentContext as q } from "../../contexts/RPDocumentContext.js";
3
+ import { PixelsPerInch as V, AnnotationMode as O, RenderingCancelledException as U } from "pdfjs-dist";
4
4
  import "react/jsx-runtime";
5
5
  import "./useLoadPdf.js";
6
6
  import "../types.js";
@@ -13,82 +13,82 @@ import "./usePdfProperties.js";
13
13
  import "../convertPdfDate.js";
14
14
  import "../formatFileSize.js";
15
15
  const re = () => {
16
- const { pdf: p, pages: f } = k(), [R, E] = m({
16
+ const { pdf: l, pages: f } = q(), [R, E] = g({
17
17
  loadedPages: 0,
18
18
  totalPages: 0,
19
19
  percentage: 0
20
- }), [T, y] = m(!1), [A, b] = m(!1), [Z, C] = m(null), [M, P] = m(void 0), o = X(!1);
20
+ }), [T, y] = g(!1), [A, b] = g(!1), [Z, C] = g(null), [M, w] = g(void 0), i = k(!1);
21
21
  D(() => {
22
- o.current;
23
- }, [o]);
24
- const S = g(() => {
22
+ i.current;
23
+ }, [i]);
24
+ const S = P(() => {
25
25
  document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
26
26
  const e = document.querySelector(".rp-print-zone");
27
27
  e && e.remove();
28
- }, []), i = g(() => {
29
- o.current = !1, y(!1), b(!1), C(null), P(void 0), E({
28
+ }, []), s = P(() => {
29
+ i.current = !1, y(!1), b(!1), C(null), w(void 0), E({
30
30
  loadedPages: 0,
31
31
  totalPages: 0,
32
32
  percentage: 0
33
33
  });
34
34
  }, []), F = () => {
35
- o.current = !0;
35
+ i.current = !0;
36
36
  }, I = async ({
37
37
  scratchCanvas: e,
38
38
  pdfDocument: n,
39
39
  pageNumber: t,
40
40
  viewerPdfPage: r,
41
- printResolution: s,
42
- optionalContentConfigPromise: l,
43
- printAnnotationStoragePromise: w
41
+ printResolution: o,
42
+ optionalContentConfigPromise: c,
43
+ printAnnotationStoragePromise: u
44
44
  }) => {
45
- if (o.current) {
46
- i();
45
+ if (i.current) {
46
+ s();
47
47
  return;
48
48
  }
49
- const a = s / q.PDF;
49
+ const a = o / V.PDF;
50
50
  e.width = Math.floor(r.width * a), e.height = Math.floor(r.height * a);
51
- const c = e.getContext("2d");
52
- c.save(), c.fillStyle = "rgb(255, 255, 255)", c.fillRect(0, 0, e.width, e.height), c.restore();
53
- const [u, h] = await Promise.all([
51
+ const p = e.getContext("2d");
52
+ p.save(), p.fillStyle = "rgb(255, 255, 255)", p.fillRect(0, 0, e.width, e.height), p.restore();
53
+ const [m, h] = await Promise.all([
54
54
  n.getPage(t),
55
- w
55
+ u
56
56
  ]);
57
- if (o.current) {
58
- i();
57
+ if (i.current) {
58
+ s();
59
59
  return;
60
60
  }
61
61
  const v = {
62
62
  canvas: e,
63
- canvasContext: c,
63
+ canvasContext: p,
64
64
  transform: [a, 0, 0, a, 0, 0],
65
- viewport: u.getViewport({ scale: 1, rotation: r.rotation }),
65
+ viewport: m.getViewport({ scale: 1, rotation: r.rotation }),
66
66
  intent: "print",
67
67
  annotationMode: O.ENABLE_STORAGE,
68
- optionalContentConfigPromise: l,
68
+ optionalContentConfigPromise: c,
69
69
  printAnnotationStorage: h
70
70
  };
71
71
  try {
72
- return u.render(v).promise;
72
+ return m.render(v).promise;
73
73
  } catch (d) {
74
74
  throw d instanceof U || console.error(d), d;
75
75
  }
76
- }, L = g(() => {
76
+ }, L = P(() => {
77
77
  const e = window.print;
78
78
  return new Promise((n) => {
79
- const t = (l) => {
79
+ const t = (c) => {
80
80
  setTimeout(() => {
81
- e.call(window), setTimeout(() => l(), 20);
81
+ e.call(window), setTimeout(() => c(), 20);
82
82
  }, 0);
83
83
  };
84
84
  if (document.querySelector(".rp-print-zone")) {
85
85
  t(n);
86
86
  return;
87
87
  }
88
- const s = new MutationObserver(() => {
89
- document.querySelector(".rp-print-zone") && (t(n), s.disconnect());
88
+ const o = new MutationObserver(() => {
89
+ document.querySelector(".rp-print-zone") && (t(n), o.disconnect());
90
90
  });
91
- s.observe(document.body, { childList: !0, subtree: !0 });
91
+ o.observe(document.body, { childList: !0, subtree: !0 });
92
92
  });
93
93
  }, []), z = (e) => {
94
94
  const n = document.createElement("img"), t = document.createElement("div");
@@ -96,70 +96,74 @@ const re = () => {
96
96
  }, x = (e, n) => {
97
97
  const t = document.createElement("div");
98
98
  t.classList.add("rp-print-zone");
99
- const r = document.createElement("style");
100
- return n.get(1) && (r.innerHTML = "@page { size: 100% 100%; margin: 0; }"), t.appendChild(r), t.append(...e), t;
101
- }, N = g(
99
+ const r = document.createElement("style"), o = n.get(1);
100
+ if (o) {
101
+ const c = o.page.getViewport({ scale: 1 }), { width: u, height: a } = c;
102
+ r.innerHTML = `@page { size: ${u}pt ${a}pt; margin: 0; }`;
103
+ }
104
+ return t.appendChild(r), t.append(...e), t;
105
+ }, N = P(
102
106
  async (e) => {
103
- if (!p)
107
+ if (!l)
104
108
  return;
105
- i();
109
+ s();
106
110
  const n = e && "visibleDefaultProgress" in e ? e : void 0;
107
- (n == null ? void 0 : n.visibleDefaultProgress) !== void 0 ? P(n.visibleDefaultProgress) : P(!0);
111
+ (n == null ? void 0 : n.visibleDefaultProgress) !== void 0 ? w(n.visibleDefaultProgress) : w(!0);
108
112
  const t = document.createElement("canvas"), r = [];
109
113
  try {
110
- p.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
111
- const l = p.getOptionalContentConfig({ intent: "print" }), w = Promise.resolve(
112
- p.annotationStorage.print ?? void 0
114
+ l.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
115
+ const c = l.getOptionalContentConfig({ intent: "print" }), u = Promise.resolve(
116
+ l.annotationStorage.print ?? void 0
113
117
  ), a = f.size;
114
- for (const [u, h] of f) {
115
- if (o.current) {
116
- i();
118
+ for (const [m, h] of f) {
119
+ if (i.current) {
120
+ s();
117
121
  return;
118
122
  }
119
123
  const v = h.page.getViewport({ scale: 1 });
120
124
  if (await I({
121
125
  scratchCanvas: t,
122
- pdfDocument: p,
123
- pageNumber: u,
126
+ pdfDocument: l,
127
+ pageNumber: m,
124
128
  viewerPdfPage: v,
125
129
  printResolution: 150,
126
- optionalContentConfigPromise: l,
127
- printAnnotationStoragePromise: w
128
- }), o.current) {
129
- i();
130
+ optionalContentConfigPromise: c,
131
+ printAnnotationStoragePromise: u
132
+ }), i.current) {
133
+ s();
130
134
  return;
131
135
  }
132
136
  const d = z(t);
133
137
  r.push(d);
134
- const V = parseFloat((r.length / a * 100).toFixed(2));
138
+ const X = parseFloat((r.length / a * 100).toFixed(2));
135
139
  E({
136
- loadedPages: u,
140
+ loadedPages: m,
137
141
  totalPages: a,
138
- percentage: V
142
+ percentage: X
139
143
  });
140
144
  }
141
- if (o.current) {
142
- i();
145
+ if (i.current) {
146
+ s();
143
147
  return;
144
148
  }
145
- const c = x(r, f);
146
- document.body.appendChild(c), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), y(!0), await L();
147
- } catch (s) {
148
- b(!0), s instanceof Error && C(s);
149
+ const p = x(r, f);
150
+ document.body.appendChild(p), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), y(!0), await L();
151
+ } catch (o) {
152
+ b(!0), o instanceof Error && C(o);
149
153
  } finally {
150
154
  t.height = 0, t.width = 0;
151
155
  }
152
156
  },
153
- [p, f, o, i, x, L]
157
+ [l, f, i, s, x, L]
154
158
  );
155
159
  return D(() => {
156
160
  const e = () => {
157
- i(), S();
161
+ s(), S();
158
162
  };
159
163
  return window.addEventListener("afterprint", e, !0), () => {
160
164
  window.removeEventListener("afterprint", e, !0);
161
165
  };
162
- }, [S, i]), {
166
+ }, [S, s]), {
163
167
  print: N,
164
168
  cancel: F,
165
169
  progress: R,
@@ -12,7 +12,7 @@ function e() {
12
12
  .rp-print-zone { display: block; height: 100%; }
13
13
  .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; }
14
14
  .rp-print-page:last-child { page-break-after: auto; }
15
- .rp-print-page img, .rp-print-page canvas { display: block; height: 100%; width: 100%; direction: ltr; }
15
+ .rp-print-page img, .rp-print-page canvas { display: block !important; width: 100% !important; height: auto !important; max-height: 100% !important; direction: ltr !important; }
16
16
  }
17
17
  `, document.head.appendChild(t);
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.0.1-rc.3",
3
+ "version": "2.0.1-rc.5",
4
4
  "private": false,
5
5
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
6
6
  "keywords": [