pdfjs-dist 2.0.943 → 2.4.456
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/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,336 +19,297 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFDocumentProperties =
|
27
|
+
exports.PDFDocumentProperties = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _pdf = require("../pdf");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _ui_utils = require("./ui_utils.js");
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
var DEFAULT_FIELD_CONTENT = '-';
|
40
|
-
var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
|
41
|
-
var US_PAGE_NAMES = {
|
42
|
-
'8.5x11': 'Letter',
|
43
|
-
'8.5x14': 'Legal'
|
33
|
+
const DEFAULT_FIELD_CONTENT = "-";
|
34
|
+
const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
|
35
|
+
const US_PAGE_NAMES = {
|
36
|
+
"8.5x11": "Letter",
|
37
|
+
"8.5x14": "Legal"
|
44
38
|
};
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
const METRIC_PAGE_NAMES = {
|
40
|
+
"297x420": "A3",
|
41
|
+
"210x297": "A4"
|
48
42
|
};
|
43
|
+
|
49
44
|
function getPageName(size, isPortrait, pageNames) {
|
50
|
-
|
51
|
-
|
52
|
-
return pageNames[width
|
45
|
+
const width = isPortrait ? size.width : size.height;
|
46
|
+
const height = isPortrait ? size.height : size.width;
|
47
|
+
return pageNames[`${width}x${height}`];
|
53
48
|
}
|
54
49
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
var _this = this;
|
63
|
-
|
64
|
-
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
|
65
|
-
|
66
|
-
_classCallCheck(this, PDFDocumentProperties);
|
67
|
-
|
50
|
+
class PDFDocumentProperties {
|
51
|
+
constructor({
|
52
|
+
overlayName,
|
53
|
+
fields,
|
54
|
+
container,
|
55
|
+
closeButton
|
56
|
+
}, overlayManager, eventBus, l10n = _ui_utils.NullL10n) {
|
68
57
|
this.overlayName = overlayName;
|
69
58
|
this.fields = fields;
|
70
59
|
this.container = container;
|
71
60
|
this.overlayManager = overlayManager;
|
72
61
|
this.l10n = l10n;
|
62
|
+
|
73
63
|
this._reset();
|
64
|
+
|
74
65
|
if (closeButton) {
|
75
|
-
closeButton.addEventListener(
|
66
|
+
closeButton.addEventListener("click", this.close.bind(this));
|
76
67
|
}
|
68
|
+
|
77
69
|
this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
|
70
|
+
|
78
71
|
if (eventBus) {
|
79
|
-
eventBus.
|
80
|
-
|
72
|
+
eventBus._on("pagechanging", evt => {
|
73
|
+
this._currentPageNumber = evt.pageNumber;
|
81
74
|
});
|
82
|
-
|
83
|
-
|
75
|
+
|
76
|
+
eventBus._on("rotationchanging", evt => {
|
77
|
+
this._pagesRotation = evt.pagesRotation;
|
84
78
|
});
|
85
79
|
}
|
80
|
+
|
86
81
|
this._isNonMetricLocale = true;
|
87
|
-
l10n.getLanguage().then(
|
88
|
-
|
82
|
+
l10n.getLanguage().then(locale => {
|
83
|
+
this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
|
89
84
|
});
|
90
85
|
}
|
91
86
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
87
|
+
open() {
|
88
|
+
const freezeFieldData = data => {
|
89
|
+
Object.defineProperty(this, "fieldData", {
|
90
|
+
value: Object.freeze(data),
|
91
|
+
writable: false,
|
92
|
+
enumerable: true,
|
93
|
+
configurable: true
|
94
|
+
});
|
95
|
+
};
|
96
|
+
|
97
|
+
Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(() => {
|
98
|
+
const currentPageNumber = this._currentPageNumber;
|
99
|
+
const pagesRotation = this._pagesRotation;
|
100
|
+
|
101
|
+
if (this.fieldData && currentPageNumber === this.fieldData["_currentPageNumber"] && pagesRotation === this.fieldData["_pagesRotation"]) {
|
102
|
+
this._updateUI();
|
103
|
+
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
|
107
|
+
this.pdfDocument.getMetadata().then(({
|
108
|
+
info,
|
109
|
+
metadata,
|
110
|
+
contentDispositionFilename
|
111
|
+
}) => {
|
112
|
+
return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url || ""), this._parseFileSize(this.maybeFileSize), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
|
113
|
+
return this._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
|
114
|
+
}), this._parseLinearization(info.IsLinearized)]);
|
115
|
+
}).then(([info, metadata, fileName, fileSize, creationDate, modDate, pageSize, isLinearized]) => {
|
116
|
+
freezeFieldData({
|
117
|
+
fileName,
|
118
|
+
fileSize,
|
119
|
+
title: info.Title,
|
120
|
+
author: info.Author,
|
121
|
+
subject: info.Subject,
|
122
|
+
keywords: info.Keywords,
|
123
|
+
creationDate,
|
124
|
+
modificationDate: modDate,
|
125
|
+
creator: info.Creator,
|
126
|
+
producer: info.Producer,
|
127
|
+
version: info.PDFFormatVersion,
|
128
|
+
pageCount: this.pdfDocument.numPages,
|
129
|
+
pageSize,
|
130
|
+
linearized: isLinearized,
|
131
|
+
_currentPageNumber: currentPageNumber,
|
132
|
+
_pagesRotation: pagesRotation
|
103
133
|
});
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
134
|
+
|
135
|
+
this._updateUI();
|
136
|
+
|
137
|
+
return this.pdfDocument.getDownloadInfo();
|
138
|
+
}).then(({
|
139
|
+
length
|
140
|
+
}) => {
|
141
|
+
this.maybeFileSize = length;
|
142
|
+
return this._parseFileSize(length);
|
143
|
+
}).then(fileSize => {
|
144
|
+
if (fileSize === this.fieldData["fileSize"]) {
|
110
145
|
return;
|
111
146
|
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
|
119
|
-
}), _this2._parseLinearization(info.IsLinearized)]);
|
120
|
-
}).then(function (_ref3) {
|
121
|
-
var _ref4 = _slicedToArray(_ref3, 8),
|
122
|
-
info = _ref4[0],
|
123
|
-
metadata = _ref4[1],
|
124
|
-
fileName = _ref4[2],
|
125
|
-
fileSize = _ref4[3],
|
126
|
-
creationDate = _ref4[4],
|
127
|
-
modDate = _ref4[5],
|
128
|
-
pageSize = _ref4[6],
|
129
|
-
isLinearized = _ref4[7];
|
130
|
-
|
131
|
-
freezeFieldData({
|
132
|
-
'fileName': fileName,
|
133
|
-
'fileSize': fileSize,
|
134
|
-
'title': info.Title,
|
135
|
-
'author': info.Author,
|
136
|
-
'subject': info.Subject,
|
137
|
-
'keywords': info.Keywords,
|
138
|
-
'creationDate': creationDate,
|
139
|
-
'modificationDate': modDate,
|
140
|
-
'creator': info.Creator,
|
141
|
-
'producer': info.Producer,
|
142
|
-
'version': info.PDFFormatVersion,
|
143
|
-
'pageCount': _this2.pdfDocument.numPages,
|
144
|
-
'pageSize': pageSize,
|
145
|
-
'linearized': isLinearized,
|
146
|
-
'_currentPageNumber': currentPageNumber,
|
147
|
-
'_pagesRotation': pagesRotation
|
148
|
-
});
|
149
|
-
_this2._updateUI();
|
150
|
-
return _this2.pdfDocument.getDownloadInfo();
|
151
|
-
}).then(function (_ref5) {
|
152
|
-
var length = _ref5.length;
|
153
|
-
|
154
|
-
_this2.maybeFileSize = length;
|
155
|
-
return _this2._parseFileSize(length);
|
156
|
-
}).then(function (fileSize) {
|
157
|
-
if (fileSize === _this2.fieldData['fileSize']) {
|
158
|
-
return;
|
159
|
-
}
|
160
|
-
var data = Object.assign(Object.create(null), _this2.fieldData);
|
161
|
-
data['fileSize'] = fileSize;
|
162
|
-
freezeFieldData(data);
|
163
|
-
_this2._updateUI();
|
164
|
-
});
|
147
|
+
|
148
|
+
const data = Object.assign(Object.create(null), this.fieldData);
|
149
|
+
data["fileSize"] = fileSize;
|
150
|
+
freezeFieldData(data);
|
151
|
+
|
152
|
+
this._updateUI();
|
165
153
|
});
|
154
|
+
});
|
155
|
+
}
|
156
|
+
|
157
|
+
close() {
|
158
|
+
this.overlayManager.close(this.overlayName);
|
159
|
+
}
|
160
|
+
|
161
|
+
setDocument(pdfDocument, url = null) {
|
162
|
+
if (this.pdfDocument) {
|
163
|
+
this._reset();
|
164
|
+
|
165
|
+
this._updateUI(true);
|
166
166
|
}
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
this.overlayManager.close(this.overlayName);
|
167
|
+
|
168
|
+
if (!pdfDocument) {
|
169
|
+
return;
|
171
170
|
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
return;
|
183
|
-
}
|
184
|
-
this.pdfDocument = pdfDocument;
|
185
|
-
this.url = url;
|
186
|
-
this._dataAvailableCapability.resolve();
|
171
|
+
|
172
|
+
this.pdfDocument = pdfDocument;
|
173
|
+
this.url = url;
|
174
|
+
|
175
|
+
this._dataAvailableCapability.resolve();
|
176
|
+
}
|
177
|
+
|
178
|
+
setFileSize(fileSize) {
|
179
|
+
if (Number.isInteger(fileSize) && fileSize > 0) {
|
180
|
+
this.maybeFileSize = fileSize;
|
187
181
|
}
|
188
|
-
}
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
182
|
+
}
|
183
|
+
|
184
|
+
_reset() {
|
185
|
+
this.pdfDocument = null;
|
186
|
+
this.url = null;
|
187
|
+
this.maybeFileSize = 0;
|
188
|
+
delete this.fieldData;
|
189
|
+
this._dataAvailableCapability = (0, _pdf.createPromiseCapability)();
|
190
|
+
this._currentPageNumber = 1;
|
191
|
+
this._pagesRotation = 0;
|
192
|
+
}
|
193
|
+
|
194
|
+
_updateUI(reset = false) {
|
195
|
+
if (reset || !this.fieldData) {
|
196
|
+
for (const id in this.fields) {
|
197
|
+
this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
|
193
198
|
}
|
199
|
+
|
200
|
+
return;
|
194
201
|
}
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
this.pdfDocument = null;
|
199
|
-
this.url = null;
|
200
|
-
this.maybeFileSize = 0;
|
201
|
-
delete this.fieldData;
|
202
|
-
this._dataAvailableCapability = (0, _pdf.createPromiseCapability)();
|
203
|
-
this._currentPageNumber = 1;
|
204
|
-
this._pagesRotation = 0;
|
202
|
+
|
203
|
+
if (this.overlayManager.active !== this.overlayName) {
|
204
|
+
return;
|
205
205
|
}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
if (reset || !this.fieldData) {
|
212
|
-
for (var id in this.fields) {
|
213
|
-
this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
|
214
|
-
}
|
215
|
-
return;
|
216
|
-
}
|
217
|
-
if (this.overlayManager.active !== this.overlayName) {
|
218
|
-
return;
|
219
|
-
}
|
220
|
-
for (var _id in this.fields) {
|
221
|
-
var content = this.fieldData[_id];
|
222
|
-
this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
|
223
|
-
}
|
206
|
+
|
207
|
+
for (const id in this.fields) {
|
208
|
+
const content = this.fieldData[id];
|
209
|
+
this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
|
224
210
|
}
|
225
|
-
}
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
size_kb: (+kb.toPrecision(3)).toLocaleString(),
|
236
|
-
size_b: fileSize.toLocaleString()
|
237
|
-
}, '{{size_kb}} KB ({{size_b}} bytes)');
|
238
|
-
}
|
239
|
-
return this.l10n.get('document_properties_mb', {
|
240
|
-
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
|
211
|
+
}
|
212
|
+
|
213
|
+
async _parseFileSize(fileSize = 0) {
|
214
|
+
const kb = fileSize / 1024;
|
215
|
+
|
216
|
+
if (!kb) {
|
217
|
+
return undefined;
|
218
|
+
} else if (kb < 1024) {
|
219
|
+
return this.l10n.get("document_properties_kb", {
|
220
|
+
size_kb: (+kb.toPrecision(3)).toLocaleString(),
|
241
221
|
size_b: fileSize.toLocaleString()
|
242
|
-
},
|
222
|
+
}, "{{size_kb}} KB ({{size_b}} bytes)");
|
243
223
|
}
|
244
|
-
}, {
|
245
|
-
key: '_parsePageSize',
|
246
|
-
value: function _parsePageSize(pageSizeInches, pagesRotation) {
|
247
|
-
var _this3 = this;
|
248
224
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
225
|
+
return this.l10n.get("document_properties_mb", {
|
226
|
+
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
|
227
|
+
size_b: fileSize.toLocaleString()
|
228
|
+
}, "{{size_mb}} MB ({{size_b}} bytes)");
|
229
|
+
}
|
230
|
+
|
231
|
+
async _parsePageSize(pageSizeInches, pagesRotation) {
|
232
|
+
if (!pageSizeInches) {
|
233
|
+
return undefined;
|
234
|
+
}
|
235
|
+
|
236
|
+
if (pagesRotation % 180 !== 0) {
|
237
|
+
pageSizeInches = {
|
238
|
+
width: pageSizeInches.height,
|
239
|
+
height: pageSizeInches.width
|
262
240
|
};
|
263
|
-
|
264
|
-
|
265
|
-
|
241
|
+
}
|
242
|
+
|
243
|
+
const isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
|
244
|
+
let sizeInches = {
|
245
|
+
width: Math.round(pageSizeInches.width * 100) / 100,
|
246
|
+
height: Math.round(pageSizeInches.height * 100) / 100
|
247
|
+
};
|
248
|
+
let sizeMillimeters = {
|
249
|
+
width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
|
250
|
+
height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
|
251
|
+
};
|
252
|
+
let pageName = null;
|
253
|
+
let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
|
254
|
+
|
255
|
+
if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
|
256
|
+
const exactMillimeters = {
|
257
|
+
width: pageSizeInches.width * 25.4,
|
258
|
+
height: pageSizeInches.height * 25.4
|
259
|
+
};
|
260
|
+
const intMillimeters = {
|
261
|
+
width: Math.round(sizeMillimeters.width),
|
262
|
+
height: Math.round(sizeMillimeters.height)
|
266
263
|
};
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
};
|
278
|
-
if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
|
279
|
-
name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
|
280
|
-
if (name) {
|
281
|
-
sizeInches = {
|
282
|
-
width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
|
283
|
-
height: Math.round(intMillimeters.height / 25.4 * 100) / 100
|
284
|
-
};
|
285
|
-
sizeMillimeters = intMillimeters;
|
286
|
-
}
|
264
|
+
|
265
|
+
if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
|
266
|
+
rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
|
267
|
+
|
268
|
+
if (rawName) {
|
269
|
+
sizeInches = {
|
270
|
+
width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
|
271
|
+
height: Math.round(intMillimeters.height / 25.4 * 100) / 100
|
272
|
+
};
|
273
|
+
sizeMillimeters = intMillimeters;
|
287
274
|
}
|
288
275
|
}
|
289
|
-
if (name) {
|
290
|
-
pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
|
291
|
-
}
|
292
|
-
return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get('document_properties_page_size_unit_' + (this._isNonMetricLocale ? 'inches' : 'millimeters'), null, this._isNonMetricLocale ? 'in' : 'mm'), pageName, this.l10n.get('document_properties_page_size_orientation_' + (isPortrait ? 'portrait' : 'landscape'), null, isPortrait ? 'portrait' : 'landscape')]).then(function (_ref6) {
|
293
|
-
var _ref7 = _slicedToArray(_ref6, 4),
|
294
|
-
_ref7$ = _ref7[0],
|
295
|
-
width = _ref7$.width,
|
296
|
-
height = _ref7$.height,
|
297
|
-
unit = _ref7[1],
|
298
|
-
name = _ref7[2],
|
299
|
-
orientation = _ref7[3];
|
300
|
-
|
301
|
-
return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
|
302
|
-
width: width.toLocaleString(),
|
303
|
-
height: height.toLocaleString(),
|
304
|
-
unit: unit,
|
305
|
-
name: name,
|
306
|
-
orientation: orientation
|
307
|
-
}, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
|
308
|
-
});
|
309
276
|
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
if (!inputDate) {
|
314
|
-
return;
|
315
|
-
}
|
316
|
-
var dateToParse = inputDate;
|
317
|
-
if (dateToParse.substring(0, 2) === 'D:') {
|
318
|
-
dateToParse = dateToParse.substring(2);
|
319
|
-
}
|
320
|
-
var year = parseInt(dateToParse.substring(0, 4), 10);
|
321
|
-
var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
|
322
|
-
var day = parseInt(dateToParse.substring(6, 8), 10);
|
323
|
-
var hours = parseInt(dateToParse.substring(8, 10), 10);
|
324
|
-
var minutes = parseInt(dateToParse.substring(10, 12), 10);
|
325
|
-
var seconds = parseInt(dateToParse.substring(12, 14), 10);
|
326
|
-
var utRel = dateToParse.substring(14, 15);
|
327
|
-
var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
|
328
|
-
var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
|
329
|
-
if (utRel === '-') {
|
330
|
-
hours += offsetHours;
|
331
|
-
minutes += offsetMinutes;
|
332
|
-
} else if (utRel === '+') {
|
333
|
-
hours -= offsetHours;
|
334
|
-
minutes -= offsetMinutes;
|
335
|
-
}
|
336
|
-
var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
|
337
|
-
var dateString = date.toLocaleDateString();
|
338
|
-
var timeString = date.toLocaleTimeString();
|
339
|
-
return this.l10n.get('document_properties_date_string', {
|
340
|
-
date: dateString,
|
341
|
-
time: timeString
|
342
|
-
}, '{{date}}, {{time}}');
|
277
|
+
|
278
|
+
if (rawName) {
|
279
|
+
pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
|
343
280
|
}
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
281
|
+
|
282
|
+
return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(([{
|
283
|
+
width,
|
284
|
+
height
|
285
|
+
}, unit, name, orientation]) => {
|
286
|
+
return this.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
|
287
|
+
width: width.toLocaleString(),
|
288
|
+
height: height.toLocaleString(),
|
289
|
+
unit,
|
290
|
+
name,
|
291
|
+
orientation
|
292
|
+
}, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
|
293
|
+
});
|
294
|
+
}
|
295
|
+
|
296
|
+
async _parseDate(inputDate) {
|
297
|
+
const dateObject = _pdf.PDFDateString.toDateObject(inputDate);
|
298
|
+
|
299
|
+
if (!dateObject) {
|
300
|
+
return undefined;
|
348
301
|
}
|
349
|
-
}]);
|
350
302
|
|
351
|
-
|
352
|
-
|
303
|
+
return this.l10n.get("document_properties_date_string", {
|
304
|
+
date: dateObject.toLocaleDateString(),
|
305
|
+
time: dateObject.toLocaleTimeString()
|
306
|
+
}, "{{date}}, {{time}}");
|
307
|
+
}
|
308
|
+
|
309
|
+
_parseLinearization(isLinearized) {
|
310
|
+
return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
|
311
|
+
}
|
312
|
+
|
313
|
+
}
|
353
314
|
|
354
315
|
exports.PDFDocumentProperties = PDFDocumentProperties;
|