@react-pdf-kit/viewer 2.10.0-beta.1 → 2.10.0-rc.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.
@@ -3,7 +3,7 @@ import { LicenseType as t } from "../types.js";
3
3
  import { appConsole as n } from "../appConsole.js";
4
4
  import { useCallback as r, useEffect as i, useState as a } from "react";
5
5
  //#region lib/utils/hooks/useLicense.ts
6
- var o = /* @__PURE__ */ new Date("2026-09-23T08:51:26.281Z"), s = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx\ngr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b\nHLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y\nBm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W\nvXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD\nvzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR\nkwIDAQAB\n-----END PUBLIC KEY-----", c = "Please visit https://app.react-pdf-kit.dev to generate a new license key.", l = {
6
+ var o = /* @__PURE__ */ new Date("2026-09-30T02:34:03.299Z"), s = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx\ngr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b\nHLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y\nBm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W\nvXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD\nvzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR\nkwIDAQAB\n-----END PUBLIC KEY-----", c = "Please visit https://app.react-pdf-kit.dev to generate a new license key.", l = {
7
7
  invalidLicense: `You are currently using without a valid license. ${c}`,
8
8
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${c}`,
9
9
  expired: `Your license key has expired. ${c}`,
@@ -86,10 +86,26 @@ var p = () => {
86
86
  subtree: !0
87
87
  });
88
88
  });
89
- }, []), j = (e, t) => {
89
+ }, []), j = async (e) => {
90
+ let t = document.createElement("iframe");
91
+ t.title = "PDF print document", t.style.cssText = "position:fixed;width:0;height:0;border:0;", document.body.appendChild(t);
92
+ try {
93
+ let n = t.contentWindow, r = t.contentDocument;
94
+ if (!n || !r) throw Error("Unable to create PDF print document");
95
+ for (let e of ["rp-viewer-styles", "rp-print-style"]) {
96
+ let t = document.getElementById(e);
97
+ t && r.head.appendChild(t.cloneNode(!0));
98
+ }
99
+ r.documentElement.classList.add("rp-print-html-printing"), r.body.classList.add("rp-print-xfa-printing"), r.body.appendChild(e), n.addEventListener("afterprint", () => {
100
+ D(), t.remove();
101
+ }, { once: !0 }), await new Promise((e) => setTimeout(e, 0)), n.focus(), n.print();
102
+ } catch (e) {
103
+ throw t.remove(), e;
104
+ }
105
+ }, M = (e, t) => {
90
106
  let n = document.createElement("img"), r = document.createElement("div"), i = document.createElement("div");
91
107
  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) => {
108
+ }, N = (e) => {
93
109
  let t = e.allXfaHtml;
94
110
  if (!t?.children?.length) return [];
95
111
  let i = new n(e, () => {}), a = Math.round(l.PDF_TO_CSS_UNITS * 100) / 100;
@@ -108,7 +124,7 @@ var p = () => {
108
124
  intent: "print"
109
125
  }), n;
110
126
  });
111
- }, N = (e, t) => {
127
+ }, P = (e, t) => {
112
128
  let n = document.createElement("div");
113
129
  n.classList.add("rp-print-zone");
114
130
  let r = document.createElement("style"), i = t.get(1);
@@ -117,7 +133,7 @@ var p = () => {
117
133
  r.innerHTML = `@page { size: ${e}pt ${t}pt; margin: 0; }`;
118
134
  }
119
135
  return n.appendChild(r), n.append(...e), n;
120
- }, P = i(async (t) => {
136
+ }, F = i(async (t) => {
121
137
  if (!p) return;
122
138
  D();
123
139
  let n = t && "visibleDefaultProgress" in t ? t : void 0;
@@ -125,16 +141,16 @@ var p = () => {
125
141
  let r = document.createElement("canvas"), i = [];
126
142
  try {
127
143
  if (p.isPureXfa) {
128
- if (i.push(...M(p)), T.current) {
144
+ if (i.push(...N(p)), T.current) {
129
145
  D();
130
146
  return;
131
147
  }
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({
148
+ let e = P(i, m);
149
+ g({
134
150
  loadedPages: i.length,
135
151
  totalPages: i.length,
136
152
  percentage: 100
137
- }), v(!0), await A();
153
+ }), v(!0), await j(e);
138
154
  return;
139
155
  }
140
156
  let t = e(p, () => p.getOptionalContentConfig({ intent: "print" })), n = Promise.resolve(p.annotationStorage.print ?? void 0), a = m.size;
@@ -156,7 +172,7 @@ var p = () => {
156
172
  D();
157
173
  return;
158
174
  }
159
- let c = j(r, s);
175
+ let c = M(r, s);
160
176
  i.push(c), g({
161
177
  loadedPages: e,
162
178
  totalPages: a,
@@ -167,7 +183,7 @@ var p = () => {
167
183
  D();
168
184
  return;
169
185
  }
170
- let o = N(i, m);
186
+ let o = P(i, m);
171
187
  document.body.appendChild(o), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), v(!0), await A();
172
188
  } catch (e) {
173
189
  b(!0), e instanceof Error && S(e);
@@ -179,8 +195,9 @@ var p = () => {
179
195
  m,
180
196
  T,
181
197
  D,
182
- N,
183
- A
198
+ P,
199
+ A,
200
+ j
184
201
  ]);
185
202
  return a(() => {
186
203
  let e = () => {
@@ -190,7 +207,7 @@ var p = () => {
190
207
  window.removeEventListener("afterprint", e, !0);
191
208
  };
192
209
  }, [E, D]), {
193
- print: P,
210
+ print: F,
194
211
  cancel: O,
195
212
  progress: h,
196
213
  isComplete: _,
@@ -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 > *: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);
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, .rp-print-xfa-printing { background: rgb(0 0 0 / 0) none; height: 100% !important; margin: 0 !important; display: block !important; }\n .rp-print-body-printing * { display: none; }\n .rp-print-xfa-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 { display: block; 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.10.0-beta.1",
3
+ "version": "2.10.0-rc.0",
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": [