pdfjs-dist 2.5.207 → 2.6.347
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.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/bower.json +1 -1
- package/build/pdf.js +867 -216
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +10214 -8547
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.js +2023 -1046
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.min.js +22 -0
- package/es5/build/pdf.worker.js +11136 -8144
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +8 -5
- package/es5/web/pdf_viewer.js +195 -51
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +24 -16
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +479 -43
- package/lib/core/cff_parser.js +643 -615
- package/lib/core/chunked_stream.js +64 -50
- package/lib/core/colorspace.js +126 -104
- package/lib/core/crypto.js +37 -0
- package/lib/core/document.js +128 -75
- package/lib/core/evaluator.js +3015 -2754
- package/lib/core/fonts.js +47 -46
- package/lib/core/function.js +79 -6
- package/lib/core/image.js +364 -357
- package/lib/core/image_utils.js +109 -8
- package/lib/core/jpg.js +8 -3
- package/lib/core/obj.js +255 -34
- package/lib/core/operator_list.js +17 -15
- package/lib/core/parser.js +40 -3
- package/lib/core/pattern.js +24 -11
- package/lib/core/primitives.js +112 -53
- package/lib/core/type1_parser.js +2 -0
- package/lib/core/worker.js +102 -37
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +51 -10
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +140 -54
- package/lib/display/canvas.js +215 -46
- package/lib/display/display_utils.js +55 -18
- package/lib/display/fetch_stream.js +6 -0
- package/lib/display/font_loader.js +26 -15
- package/lib/display/metadata.js +1 -7
- package/lib/display/network.js +0 -14
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/svg.js +1 -1
- package/lib/display/text_layer.js +4 -1
- package/lib/pdf.js +2 -2
- package/lib/pdf.worker.js +2 -2
- package/lib/shared/is_node.js +1 -1
- package/lib/shared/util.js +13 -10
- package/lib/test/unit/annotation_spec.js +520 -50
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +16 -6
- package/lib/test/unit/cmap_spec.js +4 -4
- package/lib/test/unit/colorspace_spec.js +216 -24
- package/lib/test/unit/crypto_spec.js +51 -4
- package/lib/test/unit/custom_spec.js +129 -1
- package/lib/test/unit/document_spec.js +112 -1
- package/lib/test/unit/evaluator_spec.js +29 -10
- package/lib/test/unit/jasmine-boot.js +1 -1
- package/lib/test/unit/metadata_spec.js +3 -3
- package/lib/test/unit/primitives_spec.js +242 -63
- package/lib/test/unit/test_utils.js +42 -89
- package/lib/test/unit/testreporter.js +17 -6
- package/lib/test/unit/util_spec.js +13 -12
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +13 -9
- package/lib/web/app.js +231 -26
- package/lib/web/app_options.js +1 -6
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +53 -4
- package/lib/web/download_manager.js +3 -10
- package/lib/web/firefox_print_service.js +32 -12
- package/lib/web/firefoxcom.js +20 -6
- package/lib/web/interfaces.js +1 -1
- package/lib/web/pdf_attachment_viewer.js +80 -38
- package/lib/web/pdf_find_controller.js +2 -1
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_outline_viewer.js +24 -57
- package/lib/web/pdf_page_view.js +29 -6
- package/lib/web/pdf_print_service.js +13 -11
- package/lib/web/pdf_sidebar.js +46 -25
- package/lib/web/pdf_thumbnail_view.js +16 -3
- package/lib/web/pdf_thumbnail_viewer.js +17 -1
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/preferences.js +1 -1
- package/lib/web/toolbar.js +1 -1
- package/lib/web/ui_utils.js +7 -1
- package/package.json +3 -1
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +8 -5
- package/web/pdf_viewer.js +109 -33
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +1 -9
- package/es5/web/images/texture.png +0 -0
- package/web/images/texture.png +0 -0
@@ -0,0 +1,208 @@
|
|
1
|
+
/**
|
2
|
+
* @licstart The following is the entire license notice for the
|
3
|
+
* Javascript code in this page
|
4
|
+
*
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
*
|
19
|
+
* @licend The above is the entire license notice for the
|
20
|
+
* Javascript code in this page
|
21
|
+
*/
|
22
|
+
"use strict";
|
23
|
+
|
24
|
+
Object.defineProperty(exports, "__esModule", {
|
25
|
+
value: true
|
26
|
+
});
|
27
|
+
exports.PDFLayerViewer = void 0;
|
28
|
+
|
29
|
+
var _base_tree_viewer = require("./base_tree_viewer.js");
|
30
|
+
|
31
|
+
class PDFLayerViewer extends _base_tree_viewer.BaseTreeViewer {
|
32
|
+
constructor(options) {
|
33
|
+
super(options);
|
34
|
+
this.l10n = options.l10n;
|
35
|
+
|
36
|
+
this.eventBus._on("resetlayers", this._resetLayers.bind(this));
|
37
|
+
|
38
|
+
this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
|
39
|
+
}
|
40
|
+
|
41
|
+
reset() {
|
42
|
+
super.reset();
|
43
|
+
this._optionalContentConfig = null;
|
44
|
+
this._pdfDocument = null;
|
45
|
+
}
|
46
|
+
|
47
|
+
_dispatchEvent(layersCount) {
|
48
|
+
this.eventBus.dispatch("layersloaded", {
|
49
|
+
source: this,
|
50
|
+
layersCount
|
51
|
+
});
|
52
|
+
}
|
53
|
+
|
54
|
+
_bindLink(element, {
|
55
|
+
groupId,
|
56
|
+
input
|
57
|
+
}) {
|
58
|
+
const setVisibility = () => {
|
59
|
+
this._optionalContentConfig.setVisibility(groupId, input.checked);
|
60
|
+
|
61
|
+
this.eventBus.dispatch("optionalcontentconfig", {
|
62
|
+
source: this,
|
63
|
+
promise: Promise.resolve(this._optionalContentConfig)
|
64
|
+
});
|
65
|
+
};
|
66
|
+
|
67
|
+
element.onclick = evt => {
|
68
|
+
if (evt.target === input) {
|
69
|
+
setVisibility();
|
70
|
+
return true;
|
71
|
+
} else if (evt.target !== element) {
|
72
|
+
return true;
|
73
|
+
}
|
74
|
+
|
75
|
+
input.checked = !input.checked;
|
76
|
+
setVisibility();
|
77
|
+
return false;
|
78
|
+
};
|
79
|
+
}
|
80
|
+
|
81
|
+
async _setNestedName(element, {
|
82
|
+
name = null
|
83
|
+
}) {
|
84
|
+
if (typeof name === "string") {
|
85
|
+
element.textContent = this._normalizeTextContent(name);
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
|
89
|
+
element.textContent = await this.l10n.get("additional_layers", null, "Additional Layers");
|
90
|
+
element.style.fontStyle = "italic";
|
91
|
+
}
|
92
|
+
|
93
|
+
_addToggleButton(div, {
|
94
|
+
name = null
|
95
|
+
}) {
|
96
|
+
super._addToggleButton(div, name === null);
|
97
|
+
}
|
98
|
+
|
99
|
+
_toggleAllTreeItems() {
|
100
|
+
if (!this._optionalContentConfig) {
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
super._toggleAllTreeItems();
|
105
|
+
}
|
106
|
+
|
107
|
+
render({
|
108
|
+
optionalContentConfig,
|
109
|
+
pdfDocument
|
110
|
+
}) {
|
111
|
+
if (this._optionalContentConfig) {
|
112
|
+
this.reset();
|
113
|
+
}
|
114
|
+
|
115
|
+
this._optionalContentConfig = optionalContentConfig || null;
|
116
|
+
this._pdfDocument = pdfDocument || null;
|
117
|
+
const groups = optionalContentConfig && optionalContentConfig.getOrder();
|
118
|
+
|
119
|
+
if (!groups) {
|
120
|
+
this._dispatchEvent(0);
|
121
|
+
|
122
|
+
return;
|
123
|
+
}
|
124
|
+
|
125
|
+
const fragment = document.createDocumentFragment(),
|
126
|
+
queue = [{
|
127
|
+
parent: fragment,
|
128
|
+
groups
|
129
|
+
}];
|
130
|
+
let layersCount = 0,
|
131
|
+
hasAnyNesting = false;
|
132
|
+
|
133
|
+
while (queue.length > 0) {
|
134
|
+
const levelData = queue.shift();
|
135
|
+
|
136
|
+
for (const groupId of levelData.groups) {
|
137
|
+
const div = document.createElement("div");
|
138
|
+
div.className = "treeItem";
|
139
|
+
const element = document.createElement("a");
|
140
|
+
div.appendChild(element);
|
141
|
+
|
142
|
+
if (typeof groupId === "object") {
|
143
|
+
hasAnyNesting = true;
|
144
|
+
|
145
|
+
this._addToggleButton(div, groupId);
|
146
|
+
|
147
|
+
this._setNestedName(element, groupId);
|
148
|
+
|
149
|
+
const itemsDiv = document.createElement("div");
|
150
|
+
itemsDiv.className = "treeItems";
|
151
|
+
div.appendChild(itemsDiv);
|
152
|
+
queue.push({
|
153
|
+
parent: itemsDiv,
|
154
|
+
groups: groupId.order
|
155
|
+
});
|
156
|
+
} else {
|
157
|
+
const group = optionalContentConfig.getGroup(groupId);
|
158
|
+
const input = document.createElement("input");
|
159
|
+
|
160
|
+
this._bindLink(element, {
|
161
|
+
groupId,
|
162
|
+
input
|
163
|
+
});
|
164
|
+
|
165
|
+
input.type = "checkbox";
|
166
|
+
input.id = groupId;
|
167
|
+
input.checked = group.visible;
|
168
|
+
const label = document.createElement("label");
|
169
|
+
label.setAttribute("for", groupId);
|
170
|
+
label.textContent = this._normalizeTextContent(group.name);
|
171
|
+
element.appendChild(input);
|
172
|
+
element.appendChild(label);
|
173
|
+
layersCount++;
|
174
|
+
}
|
175
|
+
|
176
|
+
levelData.parent.appendChild(div);
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
if (hasAnyNesting) {
|
181
|
+
this.container.classList.add("treeWithDeepNesting");
|
182
|
+
this._lastToggleIsShow = fragment.querySelectorAll(".treeItemsHidden").length === 0;
|
183
|
+
}
|
184
|
+
|
185
|
+
this.container.appendChild(fragment);
|
186
|
+
|
187
|
+
this._dispatchEvent(layersCount);
|
188
|
+
}
|
189
|
+
|
190
|
+
async _resetLayers() {
|
191
|
+
if (!this._optionalContentConfig) {
|
192
|
+
return;
|
193
|
+
}
|
194
|
+
|
195
|
+
const optionalContentConfig = await this._pdfDocument.getOptionalContentConfig();
|
196
|
+
this.eventBus.dispatch("optionalcontentconfig", {
|
197
|
+
source: this,
|
198
|
+
promise: Promise.resolve(optionalContentConfig)
|
199
|
+
});
|
200
|
+
this.render({
|
201
|
+
optionalContentConfig,
|
202
|
+
pdfDocument: this._pdfDocument
|
203
|
+
});
|
204
|
+
}
|
205
|
+
|
206
|
+
}
|
207
|
+
|
208
|
+
exports.PDFLayerViewer = PDFLayerViewer;
|
@@ -28,27 +28,19 @@ exports.PDFOutlineViewer = void 0;
|
|
28
28
|
|
29
29
|
var _pdf = require("../pdf");
|
30
30
|
|
31
|
-
|
31
|
+
var _base_tree_viewer = require("./base_tree_viewer.js");
|
32
32
|
|
33
|
-
class PDFOutlineViewer {
|
34
|
-
constructor({
|
35
|
-
|
36
|
-
linkService
|
37
|
-
eventBus
|
38
|
-
}) {
|
39
|
-
this.container = container;
|
40
|
-
this.linkService = linkService;
|
41
|
-
this.eventBus = eventBus;
|
42
|
-
this.reset();
|
33
|
+
class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
|
34
|
+
constructor(options) {
|
35
|
+
super(options);
|
36
|
+
this.linkService = options.linkService;
|
43
37
|
|
44
|
-
eventBus._on("toggleoutlinetree", this.
|
38
|
+
this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
|
45
39
|
}
|
46
40
|
|
47
41
|
reset() {
|
48
|
-
|
49
|
-
this.
|
50
|
-
this.container.textContent = "";
|
51
|
-
this.container.classList.remove("outlineWithDeepNesting");
|
42
|
+
super.reset();
|
43
|
+
this._outline = null;
|
52
44
|
}
|
53
45
|
|
54
46
|
_dispatchEvent(outlineCount) {
|
@@ -105,56 +97,30 @@ class PDFOutlineViewer {
|
|
105
97
|
count,
|
106
98
|
items
|
107
99
|
}) {
|
108
|
-
const
|
109
|
-
toggler.className = "outlineItemToggler";
|
110
|
-
|
111
|
-
if (count < 0 && Math.abs(count) === items.length) {
|
112
|
-
toggler.classList.add("outlineItemsHidden");
|
113
|
-
}
|
114
|
-
|
115
|
-
toggler.onclick = evt => {
|
116
|
-
evt.stopPropagation();
|
117
|
-
toggler.classList.toggle("outlineItemsHidden");
|
100
|
+
const hidden = count < 0 && Math.abs(count) === items.length;
|
118
101
|
|
119
|
-
|
120
|
-
const shouldShowAll = !toggler.classList.contains("outlineItemsHidden");
|
121
|
-
|
122
|
-
this._toggleOutlineItem(div, shouldShowAll);
|
123
|
-
}
|
124
|
-
};
|
125
|
-
|
126
|
-
div.insertBefore(toggler, div.firstChild);
|
127
|
-
}
|
128
|
-
|
129
|
-
_toggleOutlineItem(root, show = false) {
|
130
|
-
this.lastToggleIsShow = show;
|
131
|
-
|
132
|
-
for (const toggler of root.querySelectorAll(".outlineItemToggler")) {
|
133
|
-
toggler.classList.toggle("outlineItemsHidden", !show);
|
134
|
-
}
|
102
|
+
super._addToggleButton(div, hidden);
|
135
103
|
}
|
136
104
|
|
137
|
-
|
138
|
-
if (!this.
|
105
|
+
_toggleAllTreeItems() {
|
106
|
+
if (!this._outline) {
|
139
107
|
return;
|
140
108
|
}
|
141
109
|
|
142
|
-
|
110
|
+
super._toggleAllTreeItems();
|
143
111
|
}
|
144
112
|
|
145
113
|
render({
|
146
114
|
outline
|
147
115
|
}) {
|
148
|
-
|
149
|
-
|
150
|
-
if (this.outline) {
|
116
|
+
if (this._outline) {
|
151
117
|
this.reset();
|
152
118
|
}
|
153
119
|
|
154
|
-
this.
|
120
|
+
this._outline = outline || null;
|
155
121
|
|
156
122
|
if (!outline) {
|
157
|
-
this._dispatchEvent(
|
123
|
+
this._dispatchEvent(0);
|
158
124
|
|
159
125
|
return;
|
160
126
|
}
|
@@ -162,23 +128,24 @@ class PDFOutlineViewer {
|
|
162
128
|
const fragment = document.createDocumentFragment();
|
163
129
|
const queue = [{
|
164
130
|
parent: fragment,
|
165
|
-
items:
|
131
|
+
items: outline
|
166
132
|
}];
|
167
|
-
let
|
133
|
+
let outlineCount = 0,
|
134
|
+
hasAnyNesting = false;
|
168
135
|
|
169
136
|
while (queue.length > 0) {
|
170
137
|
const levelData = queue.shift();
|
171
138
|
|
172
139
|
for (const item of levelData.items) {
|
173
140
|
const div = document.createElement("div");
|
174
|
-
div.className = "
|
141
|
+
div.className = "treeItem";
|
175
142
|
const element = document.createElement("a");
|
176
143
|
|
177
144
|
this._bindLink(element, item);
|
178
145
|
|
179
146
|
this._setStyles(element, item);
|
180
147
|
|
181
|
-
element.textContent =
|
148
|
+
element.textContent = this._normalizeTextContent(item.title);
|
182
149
|
div.appendChild(element);
|
183
150
|
|
184
151
|
if (item.items.length > 0) {
|
@@ -187,7 +154,7 @@ class PDFOutlineViewer {
|
|
187
154
|
this._addToggleButton(div, item);
|
188
155
|
|
189
156
|
const itemsDiv = document.createElement("div");
|
190
|
-
itemsDiv.className = "
|
157
|
+
itemsDiv.className = "treeItems";
|
191
158
|
div.appendChild(itemsDiv);
|
192
159
|
queue.push({
|
193
160
|
parent: itemsDiv,
|
@@ -201,8 +168,8 @@ class PDFOutlineViewer {
|
|
201
168
|
}
|
202
169
|
|
203
170
|
if (hasAnyNesting) {
|
204
|
-
this.container.classList.add("
|
205
|
-
this.
|
171
|
+
this.container.classList.add("treeWithDeepNesting");
|
172
|
+
this._lastToggleIsShow = fragment.querySelectorAll(".treeItemsHidden").length === 0;
|
206
173
|
}
|
207
174
|
|
208
175
|
this.container.appendChild(fragment);
|
package/lib/web/pdf_page_view.js
CHANGED
@@ -48,10 +48,12 @@ class PDFPageView {
|
|
48
48
|
this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
|
49
49
|
this.viewport = defaultViewport;
|
50
50
|
this.pdfPageRotate = defaultViewport.rotation;
|
51
|
+
this._annotationStorage = options.annotationStorage || null;
|
52
|
+
this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
|
51
53
|
this.hasRestrictedScaling = false;
|
52
54
|
this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
|
53
55
|
this.imageResourcesPath = options.imageResourcesPath || "";
|
54
|
-
this.renderInteractiveForms = options.renderInteractiveForms
|
56
|
+
this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
|
55
57
|
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
56
58
|
this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
|
57
59
|
this.eventBus = options.eventBus;
|
@@ -98,6 +100,22 @@ class PDFPageView {
|
|
98
100
|
}
|
99
101
|
}
|
100
102
|
|
103
|
+
async _renderAnnotationLayer() {
|
104
|
+
let error = null;
|
105
|
+
|
106
|
+
try {
|
107
|
+
await this.annotationLayer.render(this.viewport, "display");
|
108
|
+
} catch (ex) {
|
109
|
+
error = ex;
|
110
|
+
} finally {
|
111
|
+
this.eventBus.dispatch("annotationlayerrendered", {
|
112
|
+
source: this,
|
113
|
+
pageNumber: this.id,
|
114
|
+
error
|
115
|
+
});
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
101
119
|
_resetZoomLayer(removeFromDOM = false) {
|
102
120
|
if (!this.zoomLayer) {
|
103
121
|
return;
|
@@ -165,13 +183,17 @@ class PDFPageView {
|
|
165
183
|
div.appendChild(this.loadingIconDiv);
|
166
184
|
}
|
167
185
|
|
168
|
-
update(scale, rotation) {
|
186
|
+
update(scale, rotation, optionalContentConfigPromise = null) {
|
169
187
|
this.scale = scale || this.scale;
|
170
188
|
|
171
189
|
if (typeof rotation !== "undefined") {
|
172
190
|
this.rotation = rotation;
|
173
191
|
}
|
174
192
|
|
193
|
+
if (optionalContentConfigPromise instanceof Promise) {
|
194
|
+
this._optionalContentConfigPromise = optionalContentConfigPromise;
|
195
|
+
}
|
196
|
+
|
175
197
|
const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
176
198
|
this.viewport = this.viewport.clone({
|
177
199
|
scale: this.scale * _ui_utils.CSS_UNITS,
|
@@ -305,7 +327,7 @@ class PDFPageView {
|
|
305
327
|
}
|
306
328
|
|
307
329
|
if (redrawAnnotations && this.annotationLayer) {
|
308
|
-
this.
|
330
|
+
this._renderAnnotationLayer();
|
309
331
|
}
|
310
332
|
}
|
311
333
|
|
@@ -444,10 +466,10 @@ class PDFPageView {
|
|
444
466
|
|
445
467
|
if (this.annotationLayerFactory) {
|
446
468
|
if (!this.annotationLayer) {
|
447
|
-
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
|
469
|
+
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this._annotationStorage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
|
448
470
|
}
|
449
471
|
|
450
|
-
this.
|
472
|
+
this._renderAnnotationLayer();
|
451
473
|
}
|
452
474
|
|
453
475
|
div.setAttribute("data-loaded", true);
|
@@ -534,7 +556,8 @@ class PDFPageView {
|
|
534
556
|
transform,
|
535
557
|
viewport: this.viewport,
|
536
558
|
enableWebGL: this.enableWebGL,
|
537
|
-
renderInteractiveForms: this.renderInteractiveForms
|
559
|
+
renderInteractiveForms: this.renderInteractiveForms,
|
560
|
+
optionalContentConfigPromise: this._optionalContentConfigPromise
|
538
561
|
};
|
539
562
|
const renderTask = this.pdfPage.render(renderContext);
|
540
563
|
|
@@ -30,15 +30,14 @@ var _ui_utils = require("./ui_utils.js");
|
|
30
30
|
|
31
31
|
var _app = require("./app.js");
|
32
32
|
|
33
|
-
var
|
33
|
+
var _viewer_compatibility = require("./viewer_compatibility.js");
|
34
34
|
|
35
35
|
let activeService = null;
|
36
36
|
let overlayManager = null;
|
37
37
|
|
38
|
-
function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
|
38
|
+
function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise) {
|
39
39
|
const scratchCanvas = activeService.scratchCanvas;
|
40
|
-
const
|
41
|
-
const PRINT_UNITS = PRINT_RESOLUTION / 72.0;
|
40
|
+
const PRINT_UNITS = printResolution / 72.0;
|
42
41
|
scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
|
43
42
|
scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
|
44
43
|
const width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
|
@@ -56,7 +55,9 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
|
|
56
55
|
scale: 1,
|
57
56
|
rotation: size.rotation
|
58
57
|
}),
|
59
|
-
intent: "print"
|
58
|
+
intent: "print",
|
59
|
+
annotationStorage: pdfDocument.annotationStorage,
|
60
|
+
optionalContentConfigPromise
|
60
61
|
};
|
61
62
|
return pdfPage.render(renderContext).promise;
|
62
63
|
}).then(function () {
|
@@ -67,12 +68,13 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
|
|
67
68
|
});
|
68
69
|
}
|
69
70
|
|
70
|
-
function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
|
71
|
+
function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise = null, l10n) {
|
71
72
|
this.pdfDocument = pdfDocument;
|
72
73
|
this.pagesOverview = pagesOverview;
|
73
74
|
this.printContainer = printContainer;
|
75
|
+
this._printResolution = printResolution || 150;
|
76
|
+
this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
|
74
77
|
this.l10n = l10n || _ui_utils.NullL10n;
|
75
|
-
this.disableCreateObjectURL = _app_options.AppOptions.get("disableCreateObjectURL");
|
76
78
|
this.currentPage = -1;
|
77
79
|
this.scratchCanvas = document.createElement("canvas");
|
78
80
|
}
|
@@ -136,7 +138,7 @@ PDFPrintService.prototype = {
|
|
136
138
|
|
137
139
|
const index = this.currentPage;
|
138
140
|
renderProgress(index, pageCount, this.l10n);
|
139
|
-
renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index]).then(this.useRenderedPage.bind(this)).then(function () {
|
141
|
+
renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise).then(this.useRenderedPage.bind(this)).then(function () {
|
140
142
|
renderNextPage(resolve, reject);
|
141
143
|
}, reject);
|
142
144
|
};
|
@@ -151,7 +153,7 @@ PDFPrintService.prototype = {
|
|
151
153
|
img.style.height = printItem.height;
|
152
154
|
const scratchCanvas = this.scratchCanvas;
|
153
155
|
|
154
|
-
if ("toBlob" in scratchCanvas && !
|
156
|
+
if ("toBlob" in scratchCanvas && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
|
155
157
|
scratchCanvas.toBlob(function (blob) {
|
156
158
|
img.src = URL.createObjectURL(blob);
|
157
159
|
});
|
@@ -302,12 +304,12 @@ function ensureOverlay() {
|
|
302
304
|
_app.PDFPrintServiceFactory.instance = {
|
303
305
|
supportsPrinting: true,
|
304
306
|
|
305
|
-
createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
|
307
|
+
createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n) {
|
306
308
|
if (activeService) {
|
307
309
|
throw new Error("The print service is created and active.");
|
308
310
|
}
|
309
311
|
|
310
|
-
activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
|
312
|
+
activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n);
|
311
313
|
return activeService;
|
312
314
|
}
|
313
315
|
|
package/lib/web/pdf_sidebar.js
CHANGED
@@ -62,9 +62,11 @@ class PDFSidebar {
|
|
62
62
|
this.thumbnailButton = elements.thumbnailButton;
|
63
63
|
this.outlineButton = elements.outlineButton;
|
64
64
|
this.attachmentsButton = elements.attachmentsButton;
|
65
|
+
this.layersButton = elements.layersButton;
|
65
66
|
this.thumbnailView = elements.thumbnailView;
|
66
67
|
this.outlineView = elements.outlineView;
|
67
68
|
this.attachmentsView = elements.attachmentsView;
|
69
|
+
this.layersView = elements.layersView;
|
68
70
|
this.eventBus = eventBus;
|
69
71
|
this.l10n = l10n;
|
70
72
|
this._disableNotification = disableNotification;
|
@@ -80,6 +82,7 @@ class PDFSidebar {
|
|
80
82
|
this.switchView(SidebarView.THUMBS);
|
81
83
|
this.outlineButton.disabled = false;
|
82
84
|
this.attachmentsButton.disabled = false;
|
85
|
+
this.layersButton.disabled = false;
|
83
86
|
}
|
84
87
|
|
85
88
|
get visibleView() {
|
@@ -98,6 +101,10 @@ class PDFSidebar {
|
|
98
101
|
return this.isOpen && this.active === SidebarView.ATTACHMENTS;
|
99
102
|
}
|
100
103
|
|
104
|
+
get isLayersViewVisible() {
|
105
|
+
return this.isOpen && this.active === SidebarView.LAYERS;
|
106
|
+
}
|
107
|
+
|
101
108
|
setInitialView(view = SidebarView.NONE) {
|
102
109
|
if (this.isInitialViewSet) {
|
103
110
|
return;
|
@@ -154,6 +161,13 @@ class PDFSidebar {
|
|
154
161
|
|
155
162
|
break;
|
156
163
|
|
164
|
+
case SidebarView.LAYERS:
|
165
|
+
if (this.layersButton.disabled) {
|
166
|
+
return false;
|
167
|
+
}
|
168
|
+
|
169
|
+
break;
|
170
|
+
|
157
171
|
default:
|
158
172
|
console.error(`PDFSidebar._switchView: "${view}" is not a valid view.`);
|
159
173
|
return false;
|
@@ -163,9 +177,11 @@ class PDFSidebar {
|
|
163
177
|
this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
|
164
178
|
this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
|
165
179
|
this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
|
180
|
+
this.layersButton.classList.toggle("toggled", view === SidebarView.LAYERS);
|
166
181
|
this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
|
167
182
|
this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
|
168
183
|
this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
|
184
|
+
this.layersView.classList.toggle("hidden", view !== SidebarView.LAYERS);
|
169
185
|
|
170
186
|
if (forceOpen && !this.isOpen) {
|
171
187
|
this.open();
|
@@ -270,7 +286,7 @@ class PDFSidebar {
|
|
270
286
|
return;
|
271
287
|
}
|
272
288
|
|
273
|
-
this.l10n.get("
|
289
|
+
this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(msg => {
|
274
290
|
this.toggleButton.title = msg;
|
275
291
|
});
|
276
292
|
|
@@ -288,6 +304,10 @@ class PDFSidebar {
|
|
288
304
|
case SidebarView.ATTACHMENTS:
|
289
305
|
this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
|
290
306
|
break;
|
307
|
+
|
308
|
+
case SidebarView.LAYERS:
|
309
|
+
this.layersButton.classList.add(UI_NOTIFICATION_CLASS);
|
310
|
+
break;
|
291
311
|
}
|
292
312
|
}
|
293
313
|
|
@@ -305,6 +325,10 @@ class PDFSidebar {
|
|
305
325
|
case SidebarView.ATTACHMENTS:
|
306
326
|
this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
|
307
327
|
break;
|
328
|
+
|
329
|
+
case SidebarView.LAYERS:
|
330
|
+
this.layersButton.classList.remove(UI_NOTIFICATION_CLASS);
|
331
|
+
break;
|
308
332
|
}
|
309
333
|
};
|
310
334
|
|
@@ -351,38 +375,35 @@ class PDFSidebar {
|
|
351
375
|
this.attachmentsButton.addEventListener("click", () => {
|
352
376
|
this.switchView(SidebarView.ATTACHMENTS);
|
353
377
|
});
|
378
|
+
this.layersButton.addEventListener("click", () => {
|
379
|
+
this.switchView(SidebarView.LAYERS);
|
380
|
+
});
|
381
|
+
this.layersButton.addEventListener("dblclick", () => {
|
382
|
+
this.eventBus.dispatch("resetlayers", {
|
383
|
+
source: this
|
384
|
+
});
|
385
|
+
});
|
354
386
|
|
355
|
-
|
356
|
-
|
357
|
-
this.outlineButton.disabled = !outlineCount;
|
387
|
+
const onTreeLoaded = (count, button, view) => {
|
388
|
+
button.disabled = !count;
|
358
389
|
|
359
|
-
if (
|
360
|
-
this._showUINotification(
|
361
|
-
} else if (this.active ===
|
390
|
+
if (count) {
|
391
|
+
this._showUINotification(view);
|
392
|
+
} else if (this.active === view) {
|
362
393
|
this.switchView(SidebarView.THUMBS);
|
363
394
|
}
|
395
|
+
};
|
396
|
+
|
397
|
+
this.eventBus._on("outlineloaded", evt => {
|
398
|
+
onTreeLoaded(evt.outlineCount, this.outlineButton, SidebarView.OUTLINE);
|
364
399
|
});
|
365
400
|
|
366
401
|
this.eventBus._on("attachmentsloaded", evt => {
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
this._showUINotification(SidebarView.ATTACHMENTS);
|
371
|
-
|
372
|
-
return;
|
373
|
-
}
|
374
|
-
|
375
|
-
Promise.resolve().then(() => {
|
376
|
-
if (this.attachmentsView.hasChildNodes()) {
|
377
|
-
return;
|
378
|
-
}
|
379
|
-
|
380
|
-
this.attachmentsButton.disabled = true;
|
402
|
+
onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, SidebarView.ATTACHMENTS);
|
403
|
+
});
|
381
404
|
|
382
|
-
|
383
|
-
|
384
|
-
}
|
385
|
-
});
|
405
|
+
this.eventBus._on("layersloaded", evt => {
|
406
|
+
onTreeLoaded(evt.layersCount, this.layersButton, SidebarView.LAYERS);
|
386
407
|
});
|
387
408
|
|
388
409
|
this.eventBus._on("presentationmodechanged", evt => {
|