pdfjs-dist 2.4.456 → 2.5.207
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 +4447 -4379
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +8549 -8507
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.js +14755 -14540
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.worker.js +9830 -9469
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/web/pdf_viewer.css +5 -9
- package/es5/web/pdf_viewer.js +157 -172
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +107 -93
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/README.md +2 -2
- package/lib/core/ccitt.js +7 -7
- package/lib/core/cff_parser.js +1 -1
- package/lib/core/chunked_stream.js +5 -5
- package/lib/core/cmap.js +13 -0
- package/lib/core/document.js +22 -18
- package/lib/core/evaluator.js +285 -247
- package/lib/core/font_renderer.js +7 -7
- package/lib/core/fonts.js +163 -147
- package/lib/core/function.js +4 -5
- package/lib/core/glyphlist.js +4523 -4523
- package/lib/core/image.js +19 -44
- package/lib/core/image_utils.js +123 -47
- package/lib/core/jpeg_stream.js +2 -116
- package/lib/core/jpg.js +47 -55
- package/lib/core/jpx.js +6 -6
- package/lib/core/metrics.js +2916 -2916
- package/lib/core/obj.js +18 -7
- package/lib/core/operator_list.js +5 -0
- package/lib/core/parser.js +1 -1
- package/lib/core/pdf_manager.js +2 -2
- package/lib/core/primitives.js +4 -0
- package/lib/core/standard_fonts.js +103 -103
- package/lib/core/type1_parser.js +6 -6
- package/lib/core/worker.js +31 -24
- package/lib/core/worker_stream.js +1 -1
- package/lib/display/annotation_layer.js +3 -0
- package/lib/display/api.js +29 -137
- package/lib/display/api_compatibility.js +11 -18
- package/lib/display/canvas.js +7 -34
- package/lib/display/content_disposition.js +4 -4
- package/lib/display/display_utils.js +6 -15
- package/lib/display/fetch_stream.js +3 -1
- package/lib/display/font_loader.js +2 -2
- package/lib/display/network.js +1 -1
- package/lib/display/node_stream.js +10 -8
- package/lib/display/pattern_helper.js +1 -1
- package/lib/display/svg.js +61 -31
- package/lib/display/text_layer.js +44 -32
- package/lib/display/transport_stream.js +3 -3
- package/lib/pdf.js +210 -48
- package/lib/pdf.worker.js +12 -4
- package/lib/shared/compatibility.js +2 -0
- package/lib/shared/is_node.js +1 -1
- package/lib/shared/message_handler.js +6 -6
- package/lib/shared/util.js +15 -9
- package/lib/test/unit/api_spec.js +165 -95
- package/lib/test/unit/cff_parser_spec.js +12 -12
- package/lib/test/unit/clitests_helper.js +1 -1
- package/lib/test/unit/display_svg_spec.js +1 -5
- package/lib/test/unit/jasmine-boot.js +2 -2
- package/lib/test/unit/node_stream_spec.js +5 -3
- package/lib/test/unit/parser_spec.js +3 -3
- package/lib/test/unit/test_utils.js +1 -1
- package/lib/test/unit/testreporter.js +4 -4
- package/lib/test/unit/ui_utils_spec.js +1 -55
- package/lib/test/unit/unicode_spec.js +1 -1
- package/lib/web/app.js +247 -159
- package/lib/web/app_options.js +16 -10
- package/lib/web/base_viewer.js +14 -6
- package/lib/web/download_manager.js +3 -1
- package/lib/web/firefox_print_service.js +1 -1
- package/lib/web/firefoxcom.js +16 -4
- package/lib/web/pdf_attachment_viewer.js +14 -7
- package/lib/web/pdf_document_properties.js +11 -16
- package/lib/web/pdf_find_bar.js +3 -3
- package/lib/web/pdf_find_controller.js +3 -3
- package/lib/web/pdf_history.js +7 -5
- package/lib/web/pdf_link_service.js +7 -8
- package/lib/web/pdf_page_view.js +1 -1
- package/lib/web/pdf_presentation_mode.js +6 -2
- package/lib/web/pdf_print_service.js +1 -1
- package/lib/web/pdf_single_page_viewer.js +2 -2
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/pdf_viewer.js +2 -2
- package/lib/web/preferences.js +4 -1
- package/lib/web/text_layer_builder.js +1 -3
- package/lib/web/ui_utils.js +3 -55
- package/lib/web/view_history.js +8 -9
- package/lib/web/viewer_compatibility.js +14 -1
- package/package.json +1 -1
- package/web/pdf_viewer.css +5 -9
- package/web/pdf_viewer.js +97 -127
- package/web/pdf_viewer.js.map +1 -1
package/lib/web/app.js
CHANGED
@@ -74,6 +74,7 @@ const DEFAULT_SCALE_DELTA = 1.1;
|
|
74
74
|
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
75
75
|
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
|
76
76
|
const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
|
77
|
+
const ENABLE_PERMISSIONS_CLASS = "enablePermissions";
|
77
78
|
const ViewOnLoad = {
|
78
79
|
UNKNOWN: -1,
|
79
80
|
PREVIOUS: 0,
|
@@ -122,6 +123,10 @@ class DefaultExternalServices {
|
|
122
123
|
});
|
123
124
|
}
|
124
125
|
|
126
|
+
static get isInAutomation() {
|
127
|
+
return (0, _pdf.shadow)(this, "isInAutomation", false);
|
128
|
+
}
|
129
|
+
|
125
130
|
}
|
126
131
|
|
127
132
|
exports.DefaultExternalServices = DefaultExternalServices;
|
@@ -187,7 +192,7 @@ const PDFViewerApplication = {
|
|
187
192
|
},
|
188
193
|
|
189
194
|
async _readPreferences() {
|
190
|
-
if (_app_options.AppOptions.get("disablePreferences")
|
195
|
+
if (_app_options.AppOptions.get("disablePreferences")) {
|
191
196
|
return;
|
192
197
|
}
|
193
198
|
|
@@ -216,40 +221,40 @@ const PDFViewerApplication = {
|
|
216
221
|
const hashParams = (0, _ui_utils.parseQueryString)(hash),
|
217
222
|
waitOn = [];
|
218
223
|
|
219
|
-
if ("disableworker" in hashParams && hashParams
|
224
|
+
if ("disableworker" in hashParams && hashParams.disableworker === "true") {
|
220
225
|
waitOn.push(loadFakeWorker());
|
221
226
|
}
|
222
227
|
|
223
228
|
if ("disablerange" in hashParams) {
|
224
|
-
_app_options.AppOptions.set("disableRange", hashParams
|
229
|
+
_app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
|
225
230
|
}
|
226
231
|
|
227
232
|
if ("disablestream" in hashParams) {
|
228
|
-
_app_options.AppOptions.set("disableStream", hashParams
|
233
|
+
_app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
|
229
234
|
}
|
230
235
|
|
231
236
|
if ("disableautofetch" in hashParams) {
|
232
|
-
_app_options.AppOptions.set("disableAutoFetch", hashParams
|
237
|
+
_app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
|
233
238
|
}
|
234
239
|
|
235
240
|
if ("disablefontface" in hashParams) {
|
236
|
-
_app_options.AppOptions.set("disableFontFace", hashParams
|
241
|
+
_app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
|
237
242
|
}
|
238
243
|
|
239
244
|
if ("disablehistory" in hashParams) {
|
240
|
-
_app_options.AppOptions.set("disableHistory", hashParams
|
245
|
+
_app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
|
241
246
|
}
|
242
247
|
|
243
248
|
if ("webgl" in hashParams) {
|
244
|
-
_app_options.AppOptions.set("enableWebGL", hashParams
|
249
|
+
_app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
|
245
250
|
}
|
246
251
|
|
247
252
|
if ("verbosity" in hashParams) {
|
248
|
-
_app_options.AppOptions.set("verbosity", hashParams
|
253
|
+
_app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
|
249
254
|
}
|
250
255
|
|
251
256
|
if ("textlayer" in hashParams) {
|
252
|
-
switch (hashParams
|
257
|
+
switch (hashParams.textlayer) {
|
253
258
|
case "off":
|
254
259
|
_app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
|
255
260
|
|
@@ -259,7 +264,7 @@ const PDFViewerApplication = {
|
|
259
264
|
case "shadow":
|
260
265
|
case "hover":
|
261
266
|
const viewer = this.appConfig.viewerContainer;
|
262
|
-
viewer.classList.add("textLayer-" + hashParams
|
267
|
+
viewer.classList.add("textLayer-" + hashParams.textlayer);
|
263
268
|
break;
|
264
269
|
}
|
265
270
|
}
|
@@ -267,12 +272,14 @@ const PDFViewerApplication = {
|
|
267
272
|
if ("pdfbug" in hashParams) {
|
268
273
|
_app_options.AppOptions.set("pdfBug", true);
|
269
274
|
|
270
|
-
|
275
|
+
_app_options.AppOptions.set("fontExtraProperties", true);
|
276
|
+
|
277
|
+
const enabled = hashParams.pdfbug.split(",");
|
271
278
|
waitOn.push(loadAndEnablePDFBug(enabled));
|
272
279
|
}
|
273
280
|
|
274
281
|
if ("locale" in hashParams) {
|
275
|
-
_app_options.AppOptions.set("locale", hashParams
|
282
|
+
_app_options.AppOptions.set("locale", hashParams.locale);
|
276
283
|
}
|
277
284
|
|
278
285
|
return Promise.all(waitOn).catch(reason => {
|
@@ -290,11 +297,11 @@ const PDFViewerApplication = {
|
|
290
297
|
|
291
298
|
async _initializeViewerComponents() {
|
292
299
|
const appConfig = this.appConfig;
|
293
|
-
this.overlayManager = new _overlay_manager.OverlayManager();
|
294
300
|
const eventBus = appConfig.eventBus || new _ui_utils.EventBus({
|
295
|
-
|
301
|
+
isInAutomation: this.externalServices.isInAutomation
|
296
302
|
});
|
297
303
|
this.eventBus = eventBus;
|
304
|
+
this.overlayManager = new _overlay_manager.OverlayManager();
|
298
305
|
const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
|
299
306
|
pdfRenderingQueue.onIdle = this.cleanup.bind(this);
|
300
307
|
this.pdfRenderingQueue = pdfRenderingQueue;
|
@@ -449,14 +456,14 @@ const PDFViewerApplication = {
|
|
449
456
|
return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
450
457
|
},
|
451
458
|
|
452
|
-
set page(val) {
|
453
|
-
this.pdfViewer.currentPageNumber = val;
|
454
|
-
},
|
455
|
-
|
456
459
|
get page() {
|
457
460
|
return this.pdfViewer.currentPageNumber;
|
458
461
|
},
|
459
462
|
|
463
|
+
set page(val) {
|
464
|
+
this.pdfViewer.currentPageNumber = val;
|
465
|
+
},
|
466
|
+
|
460
467
|
get printing() {
|
461
468
|
return !!this.printService;
|
462
469
|
},
|
@@ -541,6 +548,7 @@ const PDFViewerApplication = {
|
|
541
548
|
this.pdfDocumentProperties.setDocument(null);
|
542
549
|
}
|
543
550
|
|
551
|
+
webViewerResetPermissions();
|
544
552
|
this.store = null;
|
545
553
|
this.isInitialViewSet = false;
|
546
554
|
this.downloadComplete = false;
|
@@ -655,7 +663,7 @@ const PDFViewerApplication = {
|
|
655
663
|
this.error(msg, {
|
656
664
|
message
|
657
665
|
});
|
658
|
-
throw
|
666
|
+
throw exception;
|
659
667
|
});
|
660
668
|
});
|
661
669
|
},
|
@@ -781,7 +789,7 @@ const PDFViewerApplication = {
|
|
781
789
|
|
782
790
|
if (percent > this.loadingBar.percent || isNaN(percent)) {
|
783
791
|
this.loadingBar.percent = percent;
|
784
|
-
const disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams
|
792
|
+
const disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
|
785
793
|
|
786
794
|
if (disableAutoFetch && percent) {
|
787
795
|
if (this.disableAutoFetchLoadingBarTimeout) {
|
@@ -814,7 +822,6 @@ const PDFViewerApplication = {
|
|
814
822
|
const openActionPromise = pdfDocument.getOpenAction().catch(function () {});
|
815
823
|
this.toolbar.setPagesCount(pdfDocument.numPages, false);
|
816
824
|
this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
|
817
|
-
const store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
|
818
825
|
let baseDocumentUrl;
|
819
826
|
baseDocumentUrl = null;
|
820
827
|
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
|
@@ -828,19 +835,21 @@ const PDFViewerApplication = {
|
|
828
835
|
} = pdfViewer;
|
829
836
|
const pdfThumbnailViewer = this.pdfThumbnailViewer;
|
830
837
|
pdfThumbnailViewer.setDocument(pdfDocument);
|
838
|
+
const storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
|
839
|
+
page: null,
|
840
|
+
zoom: _ui_utils.DEFAULT_SCALE_VALUE,
|
841
|
+
scrollLeft: "0",
|
842
|
+
scrollTop: "0",
|
843
|
+
rotation: null,
|
844
|
+
sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
|
845
|
+
scrollMode: _ui_utils.ScrollMode.UNKNOWN,
|
846
|
+
spreadMode: _ui_utils.SpreadMode.UNKNOWN
|
847
|
+
}).catch(() => {
|
848
|
+
return Object.create(null);
|
849
|
+
});
|
831
850
|
firstPagePromise.then(pdfPage => {
|
832
851
|
this.loadingBar.setWidth(this.appConfig.viewerContainer);
|
833
|
-
|
834
|
-
page: null,
|
835
|
-
zoom: _ui_utils.DEFAULT_SCALE_VALUE,
|
836
|
-
scrollLeft: "0",
|
837
|
-
scrollTop: "0",
|
838
|
-
rotation: null,
|
839
|
-
sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
|
840
|
-
scrollMode: _ui_utils.ScrollMode.UNKNOWN,
|
841
|
-
spreadMode: _ui_utils.SpreadMode.UNKNOWN
|
842
|
-
}).catch(() => {});
|
843
|
-
Promise.all([_ui_utils.animationStarted, storePromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, values = {}, pageLayout, pageMode, openAction]) => {
|
852
|
+
Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, stored, pageLayout, pageMode, openAction]) => {
|
844
853
|
const viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
|
845
854
|
|
846
855
|
this._initializePdfHistory({
|
@@ -862,20 +871,20 @@ const PDFViewerApplication = {
|
|
862
871
|
|
863
872
|
let spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
|
864
873
|
|
865
|
-
if (
|
866
|
-
hash = `page=${
|
867
|
-
rotation = parseInt(
|
874
|
+
if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
|
875
|
+
hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
|
876
|
+
rotation = parseInt(stored.rotation, 10);
|
868
877
|
|
869
878
|
if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
|
870
|
-
sidebarView =
|
879
|
+
sidebarView = stored.sidebarView | 0;
|
871
880
|
}
|
872
881
|
|
873
882
|
if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
|
874
|
-
scrollMode =
|
883
|
+
scrollMode = stored.scrollMode | 0;
|
875
884
|
}
|
876
885
|
|
877
886
|
if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
|
878
|
-
spreadMode =
|
887
|
+
spreadMode = stored.spreadMode | 0;
|
879
888
|
}
|
880
889
|
}
|
881
890
|
|
@@ -901,6 +910,8 @@ const PDFViewerApplication = {
|
|
901
910
|
pdfViewer.focus();
|
902
911
|
}
|
903
912
|
|
913
|
+
this._initializePermissions(pdfDocument);
|
914
|
+
|
904
915
|
await Promise.race([pagesPromise, new Promise(resolve => {
|
905
916
|
setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
|
906
917
|
})]);
|
@@ -922,162 +933,194 @@ const PDFViewerApplication = {
|
|
922
933
|
pdfViewer.update();
|
923
934
|
});
|
924
935
|
});
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
936
|
+
pagesPromise.then(() => {
|
937
|
+
this._initializeAutoPrint(pdfDocument, openActionPromise);
|
938
|
+
});
|
939
|
+
onePageRendered.then(() => {
|
940
|
+
pdfDocument.getOutline().then(outline => {
|
941
|
+
this.pdfOutlineViewer.render({
|
942
|
+
outline
|
943
|
+
});
|
944
|
+
});
|
945
|
+
pdfDocument.getAttachments().then(attachments => {
|
946
|
+
this.pdfAttachmentViewer.render({
|
947
|
+
attachments
|
948
|
+
});
|
949
|
+
});
|
950
|
+
});
|
931
951
|
|
932
|
-
|
933
|
-
console.error("The number of Page Labels does not match " + "the number of pages in the document.");
|
934
|
-
return;
|
935
|
-
}
|
952
|
+
this._initializePageLabels(pdfDocument);
|
936
953
|
|
937
|
-
|
954
|
+
this._initializeMetadata(pdfDocument);
|
955
|
+
},
|
938
956
|
|
939
|
-
|
940
|
-
|
941
|
-
}
|
957
|
+
async _initializeAutoPrint(pdfDocument, openActionPromise) {
|
958
|
+
const [openAction, javaScript] = await Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
|
942
959
|
|
943
|
-
|
944
|
-
|
945
|
-
|
960
|
+
if (pdfDocument !== this.pdfDocument) {
|
961
|
+
return;
|
962
|
+
}
|
946
963
|
|
947
|
-
|
948
|
-
pdfThumbnailViewer.setPageLabels(labels);
|
949
|
-
this.toolbar.setPagesCount(pdfDocument.numPages, true);
|
950
|
-
this.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
|
951
|
-
});
|
952
|
-
pagesPromise.then(async () => {
|
953
|
-
const [openAction, javaScript] = await Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
|
954
|
-
let triggerAutoPrint = false;
|
964
|
+
let triggerAutoPrint = false;
|
955
965
|
|
956
|
-
|
957
|
-
|
958
|
-
|
966
|
+
if (openAction && openAction.action === "Print") {
|
967
|
+
triggerAutoPrint = true;
|
968
|
+
}
|
959
969
|
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
970
|
+
if (javaScript) {
|
971
|
+
javaScript.some(js => {
|
972
|
+
if (!js) {
|
973
|
+
return false;
|
974
|
+
}
|
965
975
|
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
976
|
+
console.warn("Warning: JavaScript is not supported");
|
977
|
+
this.fallback(_pdf.UNSUPPORTED_FEATURES.javaScript);
|
978
|
+
return true;
|
979
|
+
});
|
970
980
|
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
}
|
981
|
+
if (!triggerAutoPrint) {
|
982
|
+
for (const js of javaScript) {
|
983
|
+
if (js && _ui_utils.AutoPrintRegExp.test(js)) {
|
984
|
+
triggerAutoPrint = true;
|
985
|
+
break;
|
977
986
|
}
|
978
987
|
}
|
979
988
|
}
|
989
|
+
}
|
980
990
|
|
981
|
-
|
982
|
-
|
983
|
-
|
991
|
+
if (!this.supportsPrinting) {
|
992
|
+
return;
|
993
|
+
}
|
984
994
|
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
});
|
989
|
-
}
|
990
|
-
});
|
991
|
-
onePageRendered.then(() => {
|
992
|
-
pdfDocument.getOutline().then(outline => {
|
993
|
-
this.pdfOutlineViewer.render({
|
994
|
-
outline
|
995
|
-
});
|
996
|
-
});
|
997
|
-
pdfDocument.getAttachments().then(attachments => {
|
998
|
-
this.pdfAttachmentViewer.render({
|
999
|
-
attachments
|
1000
|
-
});
|
995
|
+
if (triggerAutoPrint) {
|
996
|
+
setTimeout(function () {
|
997
|
+
window.print();
|
1001
998
|
});
|
1002
|
-
}
|
1003
|
-
|
999
|
+
}
|
1000
|
+
},
|
1001
|
+
|
1002
|
+
async _initializeMetadata(pdfDocument) {
|
1003
|
+
const {
|
1004
1004
|
info,
|
1005
1005
|
metadata,
|
1006
1006
|
contentDispositionFilename
|
1007
|
-
}
|
1008
|
-
this.documentInfo = info;
|
1009
|
-
this.metadata = metadata;
|
1010
|
-
this.contentDispositionFilename = contentDispositionFilename;
|
1011
|
-
console.log("PDF " + pdfDocument.fingerprint + " [" + info.PDFFormatVersion + " " + (info.Producer || "-").trim() + " / " + (info.Creator || "-").trim() + "]" + " (PDF.js: " + (_pdf.version || "-") + (_app_options.AppOptions.get("enableWebGL") ? " [WebGL]" : "") + ")");
|
1012
|
-
let pdfTitle;
|
1013
|
-
const infoTitle = info && info["Title"];
|
1014
|
-
|
1015
|
-
if (infoTitle) {
|
1016
|
-
pdfTitle = infoTitle;
|
1017
|
-
}
|
1018
|
-
|
1019
|
-
const metadataTitle = metadata && metadata.get("dc:title");
|
1007
|
+
} = await pdfDocument.getMetadata();
|
1020
1008
|
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
}
|
1025
|
-
}
|
1009
|
+
if (pdfDocument !== this.pdfDocument) {
|
1010
|
+
return;
|
1011
|
+
}
|
1026
1012
|
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1013
|
+
this.documentInfo = info;
|
1014
|
+
this.metadata = metadata;
|
1015
|
+
this.contentDispositionFilename = contentDispositionFilename;
|
1016
|
+
console.log(`PDF ${pdfDocument.fingerprint} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${_pdf.version || "-"}` + `${this.pdfViewer.enableWebGL ? " [WebGL]" : ""})`);
|
1017
|
+
let pdfTitle;
|
1018
|
+
const infoTitle = info && info.Title;
|
1032
1019
|
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
}
|
1020
|
+
if (infoTitle) {
|
1021
|
+
pdfTitle = infoTitle;
|
1022
|
+
}
|
1037
1023
|
|
1038
|
-
|
1039
|
-
const KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
|
1024
|
+
const metadataTitle = metadata && metadata.get("dc:title");
|
1040
1025
|
|
1041
|
-
|
1042
|
-
|
1026
|
+
if (metadataTitle) {
|
1027
|
+
if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
|
1028
|
+
pdfTitle = metadataTitle;
|
1043
1029
|
}
|
1030
|
+
}
|
1044
1031
|
|
1045
|
-
|
1046
|
-
|
1032
|
+
if (pdfTitle) {
|
1033
|
+
this.setTitle(`${pdfTitle} - ${contentDispositionFilename || document.title}`);
|
1034
|
+
} else if (contentDispositionFilename) {
|
1035
|
+
this.setTitle(contentDispositionFilename);
|
1036
|
+
}
|
1047
1037
|
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
return false;
|
1053
|
-
}
|
1038
|
+
if (info.IsAcroFormPresent) {
|
1039
|
+
console.warn("Warning: AcroForm/XFA is not supported");
|
1040
|
+
this.fallback(_pdf.UNSUPPORTED_FEATURES.forms);
|
1041
|
+
}
|
1054
1042
|
|
1055
|
-
|
1056
|
-
|
1057
|
-
});
|
1058
|
-
}
|
1043
|
+
let versionId = "other";
|
1044
|
+
const KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
|
1059
1045
|
|
1060
|
-
|
1046
|
+
if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
|
1047
|
+
versionId = `v${info.PDFFormatVersion.replace(".", "_")}`;
|
1048
|
+
}
|
1061
1049
|
|
1062
|
-
|
1063
|
-
|
1064
|
-
}
|
1050
|
+
let generatorId = "other";
|
1051
|
+
const KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
|
1065
1052
|
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
generator
|
1070
|
-
|
1053
|
+
if (info.Producer) {
|
1054
|
+
const producer = info.Producer.toLowerCase();
|
1055
|
+
KNOWN_GENERATORS.some(function (generator) {
|
1056
|
+
if (!producer.includes(generator)) {
|
1057
|
+
return false;
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
generatorId = generator.replace(/[ .\-]/g, "_");
|
1061
|
+
return true;
|
1071
1062
|
});
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
let formType = null;
|
1066
|
+
|
1067
|
+
if (info.IsAcroFormPresent) {
|
1068
|
+
formType = info.IsXFAPresent ? "xfa" : "acroform";
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
this.externalServices.reportTelemetry({
|
1072
|
+
type: "documentInfo",
|
1073
|
+
version: versionId,
|
1074
|
+
generator: generatorId,
|
1075
|
+
formType
|
1072
1076
|
});
|
1073
1077
|
},
|
1074
1078
|
|
1079
|
+
async _initializePageLabels(pdfDocument) {
|
1080
|
+
const labels = await pdfDocument.getPageLabels();
|
1081
|
+
|
1082
|
+
if (pdfDocument !== this.pdfDocument) {
|
1083
|
+
return;
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
if (!labels || _app_options.AppOptions.get("disablePageLabels")) {
|
1087
|
+
return;
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
const numLabels = labels.length;
|
1091
|
+
|
1092
|
+
if (numLabels !== this.pagesCount) {
|
1093
|
+
console.error("The number of Page Labels does not match the number of pages in the document.");
|
1094
|
+
return;
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
let i = 0;
|
1098
|
+
|
1099
|
+
while (i < numLabels && labels[i] === (i + 1).toString()) {
|
1100
|
+
i++;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
if (i === numLabels) {
|
1104
|
+
return;
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
const {
|
1108
|
+
pdfViewer,
|
1109
|
+
pdfThumbnailViewer,
|
1110
|
+
toolbar
|
1111
|
+
} = this;
|
1112
|
+
pdfViewer.setPageLabels(labels);
|
1113
|
+
pdfThumbnailViewer.setPageLabels(labels);
|
1114
|
+
toolbar.setPagesCount(numLabels, true);
|
1115
|
+
toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
|
1116
|
+
},
|
1117
|
+
|
1075
1118
|
_initializePdfHistory({
|
1076
1119
|
fingerprint,
|
1077
1120
|
viewOnLoad,
|
1078
1121
|
initialDest = null
|
1079
1122
|
}) {
|
1080
|
-
if (_app_options.AppOptions.get("disableHistory")
|
1123
|
+
if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
|
1081
1124
|
return;
|
1082
1125
|
}
|
1083
1126
|
|
@@ -1101,6 +1144,22 @@ const PDFViewerApplication = {
|
|
1101
1144
|
}
|
1102
1145
|
},
|
1103
1146
|
|
1147
|
+
async _initializePermissions(pdfDocument) {
|
1148
|
+
const permissions = await pdfDocument.getPermissions();
|
1149
|
+
|
1150
|
+
if (pdfDocument !== this.pdfDocument) {
|
1151
|
+
return;
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
if (!permissions || !_app_options.AppOptions.get("enablePermissions")) {
|
1155
|
+
return;
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
if (!permissions.includes(_pdf.PermissionFlag.COPY)) {
|
1159
|
+
this.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
|
1160
|
+
}
|
1161
|
+
},
|
1162
|
+
|
1104
1163
|
setInitialView(storedHash, {
|
1105
1164
|
rotation,
|
1106
1165
|
sidebarView,
|
@@ -1439,7 +1498,9 @@ const PDFViewerApplication = {
|
|
1439
1498
|
_boundEvents
|
1440
1499
|
} = this;
|
1441
1500
|
window.removeEventListener("visibilitychange", webViewerVisibilityChange);
|
1442
|
-
window.removeEventListener("wheel", webViewerWheel
|
1501
|
+
window.removeEventListener("wheel", webViewerWheel, {
|
1502
|
+
passive: false
|
1503
|
+
});
|
1443
1504
|
window.removeEventListener("click", webViewerClick);
|
1444
1505
|
window.removeEventListener("keydown", webViewerKeyDown);
|
1445
1506
|
window.removeEventListener("resize", _boundEvents.windowResize);
|
@@ -1621,6 +1682,18 @@ let webViewerOpenFileViaURL;
|
|
1621
1682
|
};
|
1622
1683
|
}
|
1623
1684
|
|
1685
|
+
function webViewerResetPermissions() {
|
1686
|
+
const {
|
1687
|
+
appConfig
|
1688
|
+
} = PDFViewerApplication;
|
1689
|
+
|
1690
|
+
if (!appConfig) {
|
1691
|
+
return;
|
1692
|
+
}
|
1693
|
+
|
1694
|
+
appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
|
1695
|
+
}
|
1696
|
+
|
1624
1697
|
function webViewerPageRendered(evt) {
|
1625
1698
|
const pageNumber = evt.pageNumber;
|
1626
1699
|
const pageIndex = pageNumber - 1;
|
@@ -1813,7 +1886,7 @@ let webViewerFileInputChange, webViewerOpenFile;
|
|
1813
1886
|
|
1814
1887
|
const file = evt.fileInput.files[0];
|
1815
1888
|
|
1816
|
-
if (
|
1889
|
+
if (!_app_options.AppOptions.get("disableCreateObjectURL")) {
|
1817
1890
|
let url = URL.createObjectURL(file);
|
1818
1891
|
|
1819
1892
|
if (file.name) {
|
@@ -2172,12 +2245,27 @@ function webViewerKeyDown(evt) {
|
|
2172
2245
|
}
|
2173
2246
|
}
|
2174
2247
|
|
2248
|
+
const {
|
2249
|
+
eventBus
|
2250
|
+
} = PDFViewerApplication;
|
2251
|
+
|
2175
2252
|
if (cmd === 1 || cmd === 8) {
|
2176
2253
|
switch (evt.keyCode) {
|
2177
2254
|
case 83:
|
2178
|
-
|
2255
|
+
eventBus.dispatch("download", {
|
2256
|
+
source: window
|
2257
|
+
});
|
2179
2258
|
handled = true;
|
2180
2259
|
break;
|
2260
|
+
|
2261
|
+
case 79:
|
2262
|
+
{
|
2263
|
+
eventBus.dispatch("openfile", {
|
2264
|
+
source: window
|
2265
|
+
});
|
2266
|
+
handled = true;
|
2267
|
+
}
|
2268
|
+
break;
|
2181
2269
|
}
|
2182
2270
|
}
|
2183
2271
|
|