ng2-pdfjs-viewer 26.2.0 → 26.3.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/LICENSE +1 -31
- package/README.md +2 -3
- package/fesm2022/ng2-pdfjs-viewer.mjs +40 -14
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
# Apache License, Version 2.0 with Commons Clause License Condition v 1.0
|
|
2
|
-
|
|
3
|
-
===============================================================================
|
|
4
|
-
|
|
5
|
-
COMMONS CLAUSE LICENSE CONDITION
|
|
6
|
-
|
|
7
|
-
The Software is provided to you by the Licensor under the License, as defined
|
|
8
|
-
below, subject to the following condition.
|
|
9
|
-
|
|
10
|
-
Without limiting other conditions in the License, the grant of rights under
|
|
11
|
-
the License will not include, and the License does not grant to you, the right
|
|
12
|
-
to Sell the Software. For purposes of the foregoing, "Sell" means practicing
|
|
13
|
-
any or all of the rights granted to you under the License to provide to third
|
|
14
|
-
parties, for a fee or other consideration (including without limitation fees
|
|
15
|
-
for hosting or consulting/ support services related to the Software), a product
|
|
16
|
-
or service whose value derives, entirely or substantially, from the Software.
|
|
17
|
-
Any license notice or attribution required by the License must also include
|
|
18
|
-
this Commons Clause License Condition notice.
|
|
19
|
-
|
|
20
|
-
Software: ng2-pdfjs-viewer
|
|
21
|
-
Copyright (c) 2018-2025 Aneesh Goapalakrishnan
|
|
22
|
-
Licensor: Aneesh Goapalakrishnan <codehippie1@gmail.com>
|
|
23
|
-
|
|
24
|
-
This software is dual-licensed under the Apache License 2.0 and the Commons
|
|
25
|
-
Clause License Condition. The Commons Clause modifies the Apache License 2.0
|
|
26
|
-
to prevent commercial competitors from selling products or services that are
|
|
27
|
-
substantially derived from this software.
|
|
28
|
-
|
|
29
|
-
===============================================================================
|
|
30
|
-
|
|
31
1
|
Apache License
|
|
32
2
|
Version 2.0, January 2004
|
|
33
3
|
http://www.apache.org/licenses/
|
|
@@ -216,7 +186,7 @@ substantially derived from this software.
|
|
|
216
186
|
same "printed page" as the copyright notice for easier
|
|
217
187
|
identification within third-party archives.
|
|
218
188
|
|
|
219
|
-
Copyright 2018-
|
|
189
|
+
Copyright 2018-2026 Aneesh Goapalakrishnan
|
|
220
190
|
|
|
221
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
222
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
[](https://github.com/intbot/ng2-pdfjs-viewer/security/code-scanning)
|
|
15
15
|
[](https://angular.dev)
|
|
16
16
|
[](https://github.com/mozilla/pdf.js)
|
|
17
|
-
[](https://github.com/intbot/ng2-pdfjs-viewer/blob/master/LICENSE)
|
|
18
18
|
[](https://github.com/intbot/ng2-pdfjs-viewer)
|
|
19
19
|
[](https://stackblitz.com/github/intbot/ng2-pdfjs-viewer/tree/master/examples/quickstart)
|
|
20
20
|
[](https://codesandbox.io/p/sandbox/github/intbot/ng2-pdfjs-viewer/tree/master/examples/quickstart)
|
|
@@ -240,8 +240,7 @@ Using it somewhere that won't show up in public code — an internal tool, a hos
|
|
|
240
240
|
|
|
241
241
|
## 📄 License
|
|
242
242
|
|
|
243
|
-
[Apache-2.0
|
|
244
|
-
Clause restricts selling the software itself as a hosted/commercial product.
|
|
243
|
+
[Apache-2.0](https://github.com/intbot/ng2-pdfjs-viewer/blob/master/LICENSE). Use, modify, self-host, or ship it inside a commercial product — the Apache 2.0 grant is perpetual, irrevocable, and carries an express patent license.
|
|
245
244
|
|
|
246
245
|
## 🙏 Acknowledgments
|
|
247
246
|
|
|
@@ -150,6 +150,32 @@ class ActionQueueManager {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// Property normalization between component inputs and PDF.js viewer values
|
|
153
|
+
// Mode/name lists shared by the to- and from-viewer transforms. PDF.js encodes
|
|
154
|
+
// scroll and spread modes as integer enums, so for those the array index is the
|
|
155
|
+
// enum value and the order here doubles as the numeric->name map (keep it in
|
|
156
|
+
// sync with PDF.js). Declaring each list once keeps the input whitelist and the
|
|
157
|
+
// index map from drifting apart, and hoisting them to module scope avoids
|
|
158
|
+
// re-allocating the array on every viewer state-sync event.
|
|
159
|
+
const ZOOM_NAMES = [
|
|
160
|
+
"auto",
|
|
161
|
+
"page-fit",
|
|
162
|
+
"page-width",
|
|
163
|
+
"page-actual",
|
|
164
|
+
];
|
|
165
|
+
const CURSOR_MODES = ["select", "hand", "zoom"];
|
|
166
|
+
const SCROLL_MODES = [
|
|
167
|
+
"vertical",
|
|
168
|
+
"horizontal",
|
|
169
|
+
"wrapped",
|
|
170
|
+
"page",
|
|
171
|
+
];
|
|
172
|
+
const SPREAD_MODES = ["none", "odd", "even"];
|
|
173
|
+
const PAGE_MODES = [
|
|
174
|
+
"none",
|
|
175
|
+
"thumbs",
|
|
176
|
+
"bookmarks",
|
|
177
|
+
"attachments",
|
|
178
|
+
];
|
|
153
179
|
// Lowercase + whitelist with fallback
|
|
154
180
|
const pick = (value, allowed, fallback) => {
|
|
155
181
|
const v = value ? value.toLowerCase() : "";
|
|
@@ -162,9 +188,7 @@ class PropertyTransformers {
|
|
|
162
188
|
return "auto";
|
|
163
189
|
const v = zoom.toLowerCase();
|
|
164
190
|
// Named zooms normalize to lowercase; numeric strings pass through
|
|
165
|
-
return
|
|
166
|
-
? v
|
|
167
|
-
: zoom;
|
|
191
|
+
return ZOOM_NAMES.includes(v) ? v : zoom;
|
|
168
192
|
},
|
|
169
193
|
fromViewer: (viewerZoom) => {
|
|
170
194
|
if (typeof viewerZoom === "string")
|
|
@@ -180,31 +204,29 @@ class PropertyTransformers {
|
|
|
180
204
|
fromViewer: (viewerRotation) => typeof viewerRotation === "number" ? viewerRotation : 0,
|
|
181
205
|
};
|
|
182
206
|
static transformCursor = {
|
|
183
|
-
toViewer: (cursor) => pick(cursor,
|
|
207
|
+
toViewer: (cursor) => pick(cursor, CURSOR_MODES, "select"),
|
|
184
208
|
fromViewer: (viewerCursor) => typeof viewerCursor === "string" ? viewerCursor : "select",
|
|
185
209
|
};
|
|
186
210
|
static transformScroll = {
|
|
187
|
-
toViewer: (scroll) => pick(scroll,
|
|
211
|
+
toViewer: (scroll) => pick(scroll, SCROLL_MODES, "vertical"),
|
|
188
212
|
fromViewer: (viewerScroll) => {
|
|
189
|
-
const modes = ["vertical", "horizontal", "wrapped", "page"];
|
|
190
213
|
if (typeof viewerScroll === "number") {
|
|
191
|
-
return
|
|
214
|
+
return SCROLL_MODES[viewerScroll] || "vertical";
|
|
192
215
|
}
|
|
193
216
|
return typeof viewerScroll === "string" ? viewerScroll : "vertical";
|
|
194
217
|
},
|
|
195
218
|
};
|
|
196
219
|
static transformSpread = {
|
|
197
|
-
toViewer: (spread) => pick(spread,
|
|
220
|
+
toViewer: (spread) => pick(spread, SPREAD_MODES, "none"),
|
|
198
221
|
fromViewer: (viewerSpread) => {
|
|
199
|
-
const modes = ["none", "odd", "even"];
|
|
200
222
|
if (typeof viewerSpread === "number") {
|
|
201
|
-
return
|
|
223
|
+
return SPREAD_MODES[viewerSpread] || "none";
|
|
202
224
|
}
|
|
203
225
|
return typeof viewerSpread === "string" ? viewerSpread : "none";
|
|
204
226
|
},
|
|
205
227
|
};
|
|
206
228
|
static transformPageMode = {
|
|
207
|
-
toViewer: (pageMode) => pick(pageMode,
|
|
229
|
+
toViewer: (pageMode) => pick(pageMode, PAGE_MODES, "none"),
|
|
208
230
|
fromViewer: (viewerPageMode) => typeof viewerPageMode === "string" ? viewerPageMode : "none",
|
|
209
231
|
};
|
|
210
232
|
}
|
|
@@ -1992,11 +2014,15 @@ class PdfJsViewerComponent {
|
|
|
1992
2014
|
// Embedded views for pageOverlayTpl, keyed by page number. Views are
|
|
1993
2015
|
// attached to ApplicationRef so bindings inside stay live.
|
|
1994
2016
|
overlayViews = new Map();
|
|
1995
|
-
mountPageOverlay(pageNumber) {
|
|
2017
|
+
mountPageOverlay(pageNumber, knownPageEl) {
|
|
1996
2018
|
if (!this.pageOverlayTpl || this.externalWindow)
|
|
1997
2019
|
return;
|
|
1998
2020
|
const doc = this.iframe?.nativeElement?.contentDocument;
|
|
1999
|
-
|
|
2021
|
+
// Callers iterating already-rendered pages pass the element they hold, so
|
|
2022
|
+
// we skip re-finding it by selector (saves one DOM query per page on large
|
|
2023
|
+
// documents); the per-page render path passes nothing and looks it up.
|
|
2024
|
+
const pageEl = knownPageEl ??
|
|
2025
|
+
doc?.querySelector(`.pdfViewer .page[data-page-number="${pageNumber}"]`);
|
|
2000
2026
|
if (!pageEl || pageEl.querySelector(":scope > .ng2-page-overlay")) {
|
|
2001
2027
|
return;
|
|
2002
2028
|
}
|
|
@@ -2038,7 +2064,7 @@ class PdfJsViewerComponent {
|
|
|
2038
2064
|
.forEach((el) => {
|
|
2039
2065
|
const pageNumber = Number(el.getAttribute("data-page-number"));
|
|
2040
2066
|
if (pageNumber > 0) {
|
|
2041
|
-
this.mountPageOverlay(pageNumber);
|
|
2067
|
+
this.mountPageOverlay(pageNumber, el);
|
|
2042
2068
|
}
|
|
2043
2069
|
});
|
|
2044
2070
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng2-pdfjs-viewer",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.3.0",
|
|
4
4
|
"description": "The most comprehensive Angular PDF viewer, powered by Mozilla PDF.js 6 — view, annotate, sign, fill forms, search, and read aloud from one component. 8.3M+ downloads, mobile-first, production-ready.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aneesh Goapalakrishnan",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"accessibility",
|
|
55
55
|
"open-source"
|
|
56
56
|
],
|
|
57
|
-
"license": "Apache-2.0
|
|
57
|
+
"license": "Apache-2.0",
|
|
58
58
|
"readme": "README.md",
|
|
59
59
|
"exports": {
|
|
60
60
|
"./package.json": {
|