pdfjs-dist 2.0.943 → 2.1.266
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 +15329 -11095
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +12497 -4184
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/image_decoders/pdf.image_decoders.js +3438 -1209
- 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 +335 -109
- package/lib/core/arithmetic_decoder.js +274 -244
- package/lib/core/bidi.js +64 -5
- package/lib/core/ccitt.js +172 -17
- package/lib/core/ccitt_stream.js +14 -5
- package/lib/core/cff_parser.js +304 -28
- package/lib/core/charsets.js +4 -3
- package/lib/core/chunked_stream.js +379 -149
- package/lib/core/cmap.js +210 -40
- package/lib/core/colorspace.js +332 -187
- package/lib/core/crypto.js +289 -44
- package/lib/core/document.js +508 -249
- package/lib/core/encodings.js +18 -9
- package/lib/core/evaluator.js +657 -119
- package/lib/core/font_renderer.js +217 -34
- package/lib/core/fonts.js +632 -41
- package/lib/core/function.js +252 -26
- package/lib/core/glyphlist.js +2 -1
- package/lib/core/image.js +124 -27
- package/lib/core/jbig2.js +425 -65
- package/lib/core/jbig2_stream.js +18 -7
- package/lib/core/jpeg_stream.js +24 -8
- package/lib/core/jpg.js +208 -16
- package/lib/core/jpx.js +395 -5
- package/lib/core/jpx_stream.js +17 -5
- package/lib/core/metrics.js +3 -3
- package/lib/core/murmurhash3.js +23 -5
- package/lib/core/obj.js +625 -132
- package/lib/core/operator_list.js +104 -3
- package/lib/core/parser.js +262 -25
- package/lib/core/pattern.js +144 -12
- package/lib/core/pdf_manager.js +104 -70
- package/lib/core/primitives.js +74 -21
- package/lib/core/ps_parser.js +133 -44
- package/lib/core/standard_fonts.js +9 -9
- package/lib/core/stream.js +283 -31
- package/lib/core/type1_parser.js +138 -6
- package/lib/core/unicode.js +28 -1
- package/lib/core/worker.js +192 -57
- package/lib/display/annotation_layer.js +303 -123
- package/lib/display/api.js +1073 -574
- package/lib/display/api_compatibility.js +4 -1
- package/lib/display/canvas.js +314 -18
- package/lib/display/content_disposition.js +70 -23
- package/lib/display/dom_utils.js +112 -59
- package/lib/display/fetch_stream.js +95 -50
- package/lib/display/font_loader.js +250 -132
- package/lib/display/metadata.js +37 -15
- package/lib/display/network.js +123 -34
- package/lib/display/network_utils.js +23 -10
- package/lib/display/node_stream.js +162 -65
- package/lib/display/pattern_helper.js +57 -6
- package/lib/display/svg.js +194 -18
- package/lib/display/text_layer.js +128 -14
- package/lib/display/transport_stream.js +83 -27
- package/lib/display/webgl.js +63 -17
- package/lib/display/worker_options.js +4 -3
- package/lib/display/xml_parser.js +162 -52
- package/lib/examples/node/domstubs.js +56 -3
- package/lib/pdf.js +15 -2
- package/lib/pdf.worker.js +4 -2
- package/lib/shared/compatibility.js +129 -26
- package/lib/shared/global_scope.js +1 -1
- package/lib/shared/is_node.js +3 -3
- package/lib/shared/message_handler.js +103 -45
- package/lib/shared/streams_polyfill.js +20 -16
- package/lib/shared/url_polyfill.js +8 -2
- package/lib/shared/util.js +246 -84
- package/lib/test/unit/annotation_spec.js +99 -73
- package/lib/test/unit/api_spec.js +347 -113
- package/lib/test/unit/bidi_spec.js +6 -6
- package/lib/test/unit/cff_parser_spec.js +17 -5
- package/lib/test/unit/clitests_helper.js +7 -8
- package/lib/test/unit/cmap_spec.js +79 -25
- package/lib/test/unit/colorspace_spec.js +65 -18
- package/lib/test/unit/crypto_spec.js +16 -4
- package/lib/test/unit/custom_spec.js +40 -52
- package/lib/test/unit/display_svg_spec.js +32 -16
- package/lib/test/unit/document_spec.js +2 -2
- package/lib/test/unit/dom_utils_spec.js +8 -8
- package/lib/test/unit/encodings_spec.js +24 -44
- package/lib/test/unit/evaluator_spec.js +15 -8
- package/lib/test/unit/function_spec.js +16 -4
- package/lib/test/unit/jasmine-boot.js +29 -16
- package/lib/test/unit/message_handler_spec.js +19 -6
- package/lib/test/unit/metadata_spec.js +64 -11
- package/lib/test/unit/murmurhash3_spec.js +2 -2
- package/lib/test/unit/network_spec.js +19 -4
- package/lib/test/unit/network_utils_spec.js +6 -4
- package/lib/test/unit/node_stream_spec.js +50 -26
- package/lib/test/unit/parser_spec.js +13 -29
- package/lib/test/unit/pdf_find_controller_spec.js +144 -32
- package/lib/test/unit/pdf_find_utils_spec.js +10 -9
- package/lib/test/unit/pdf_history_spec.js +20 -8
- package/lib/test/unit/primitives_spec.js +23 -3
- package/lib/test/unit/stream_spec.js +8 -3
- package/lib/test/unit/test_utils.js +89 -26
- package/lib/test/unit/testreporter.js +19 -1
- package/lib/test/unit/type1_parser_spec.js +7 -5
- package/lib/test/unit/ui_utils_spec.js +162 -38
- package/lib/test/unit/unicode_spec.js +13 -10
- package/lib/test/unit/util_spec.js +89 -9
- package/lib/web/annotation_layer_builder.js +38 -21
- package/lib/web/app.js +610 -245
- package/lib/web/app_options.js +54 -34
- package/lib/web/base_viewer.js +359 -162
- package/lib/web/chromecom.js +159 -80
- package/lib/web/debugger.js +161 -17
- package/lib/web/download_manager.js +29 -11
- package/lib/web/firefox_print_service.js +16 -8
- package/lib/web/firefoxcom.js +127 -91
- package/lib/web/genericcom.js +50 -31
- package/lib/web/genericl10n.js +46 -34
- package/lib/web/grab_to_pan.js +25 -3
- package/lib/web/interfaces.js +108 -61
- package/lib/web/overlay_manager.js +67 -45
- package/lib/web/password_prompt.js +20 -12
- package/lib/web/pdf_attachment_viewer.js +37 -17
- package/lib/web/pdf_cursor_tools.js +38 -15
- package/lib/web/pdf_document_properties.js +65 -24
- package/lib/web/pdf_find_bar.js +48 -20
- package/lib/web/pdf_find_controller.js +290 -89
- package/lib/web/pdf_find_utils.js +19 -3
- package/lib/web/pdf_history.js +186 -49
- package/lib/web/pdf_link_service.js +127 -52
- package/lib/web/pdf_outline_viewer.js +71 -21
- package/lib/web/pdf_page_view.js +188 -63
- package/lib/web/pdf_presentation_mode.js +98 -33
- package/lib/web/pdf_print_service.js +54 -10
- package/lib/web/pdf_rendering_queue.js +26 -4
- package/lib/web/pdf_sidebar.js +116 -62
- package/lib/web/pdf_sidebar_resizer.js +41 -15
- package/lib/web/pdf_single_page_viewer.js +65 -68
- package/lib/web/pdf_thumbnail_view.js +102 -31
- package/lib/web/pdf_thumbnail_viewer.js +62 -22
- package/lib/web/pdf_viewer.component.js +111 -31
- package/lib/web/pdf_viewer.js +80 -60
- package/lib/web/preferences.js +61 -39
- package/lib/web/secondary_toolbar.js +101 -82
- package/lib/web/text_layer_builder.js +124 -69
- package/lib/web/toolbar.js +67 -27
- package/lib/web/ui_utils.js +284 -128
- package/lib/web/view_history.js +75 -51
- package/lib/web/viewer_compatibility.js +2 -1
- package/package.json +1 -1
- package/web/pdf_viewer.css +1 -1
- package/web/pdf_viewer.js +2200 -973
- package/web/pdf_viewer.js.map +1 -1
- package/lib/web/dom_events.js +0 -140
@@ -19,15 +19,15 @@
|
|
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
|
-
var _parser = require(
|
24
|
+
var _parser = require("../../core/parser");
|
25
25
|
|
26
|
-
var _util = require(
|
26
|
+
var _util = require("../../shared/util");
|
27
27
|
|
28
|
-
var _primitives = require(
|
28
|
+
var _primitives = require("../../core/primitives");
|
29
29
|
|
30
|
-
var _stream = require(
|
30
|
+
var _stream = require("../../core/stream");
|
31
31
|
|
32
32
|
describe('parser', function () {
|
33
33
|
describe('Lexer', function () {
|
@@ -39,6 +39,7 @@ describe('parser', function () {
|
|
39
39
|
});
|
40
40
|
it('should parse PostScript numbers', function () {
|
41
41
|
var numbers = ['-.002', '34.5', '-3.62', '123.6e10', '1E-5', '-1.', '0.0', '123', '-98', '43445', '0', '+17'];
|
42
|
+
|
42
43
|
for (var i = 0, ii = numbers.length; i < ii; i++) {
|
43
44
|
var num = numbers[i];
|
44
45
|
var input = new _stream.StringStream(num);
|
@@ -73,7 +74,8 @@ describe('parser', function () {
|
|
73
74
|
expect(lexer.getNumber()).toEqual(0);
|
74
75
|
var numbers = ['..', '-.', '+.', '-\r\n.', '+\r\n.'];
|
75
76
|
|
76
|
-
var _loop = function _loop(
|
77
|
+
var _loop = function _loop() {
|
78
|
+
var number = numbers[_i];
|
77
79
|
var input = new _stream.StringStream(number);
|
78
80
|
var lexer = new _parser.Lexer(input);
|
79
81
|
expect(function () {
|
@@ -81,29 +83,8 @@ describe('parser', function () {
|
|
81
83
|
}).toThrowError(_util.FormatError, /^Invalid number:\s/);
|
82
84
|
};
|
83
85
|
|
84
|
-
var
|
85
|
-
|
86
|
-
var _iteratorError = undefined;
|
87
|
-
|
88
|
-
try {
|
89
|
-
for (var _iterator = numbers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
90
|
-
var number = _step.value;
|
91
|
-
|
92
|
-
_loop(number);
|
93
|
-
}
|
94
|
-
} catch (err) {
|
95
|
-
_didIteratorError = true;
|
96
|
-
_iteratorError = err;
|
97
|
-
} finally {
|
98
|
-
try {
|
99
|
-
if (!_iteratorNormalCompletion && _iterator.return) {
|
100
|
-
_iterator.return();
|
101
|
-
}
|
102
|
-
} finally {
|
103
|
-
if (_didIteratorError) {
|
104
|
-
throw _iteratorError;
|
105
|
-
}
|
106
|
-
}
|
86
|
+
for (var _i = 0; _i < numbers.length; _i++) {
|
87
|
+
_loop();
|
107
88
|
}
|
108
89
|
});
|
109
90
|
it('should handle glued numbers and operators', function () {
|
@@ -115,10 +96,12 @@ describe('parser', function () {
|
|
115
96
|
});
|
116
97
|
it('should stop parsing strings at the end of stream', function () {
|
117
98
|
var input = new _stream.StringStream('(1$4)');
|
99
|
+
|
118
100
|
input.getByte = function (super_getByte) {
|
119
101
|
var ch = super_getByte.call(input);
|
120
102
|
return ch === 0x24 ? -1 : ch;
|
121
103
|
}.bind(input, input.getByte);
|
104
|
+
|
122
105
|
var lexer = new _parser.Lexer(input);
|
123
106
|
var result = lexer.getString();
|
124
107
|
expect(result).toEqual('1');
|
@@ -138,6 +121,7 @@ describe('parser', function () {
|
|
138
121
|
it('should handle Names with invalid usage of NUMBER SIGN (#)', function () {
|
139
122
|
var inputNames = ['/# 680 0 R', '/#AQwerty', '/#A<</B'];
|
140
123
|
var expectedNames = ['#', '#AQwerty', '#A'];
|
124
|
+
|
141
125
|
for (var i = 0, ii = inputNames.length; i < ii; i++) {
|
142
126
|
var input = new _stream.StringStream(inputNames[i]);
|
143
127
|
var lexer = new _parser.Lexer(input);
|
@@ -19,51 +19,64 @@
|
|
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
|
-
var
|
24
|
+
var _test_utils = require("./test_utils");
|
25
25
|
|
26
|
-
var
|
26
|
+
var _ui_utils = require("../../web/ui_utils");
|
27
27
|
|
28
|
-
var
|
28
|
+
var _api = require("../../display/api");
|
29
29
|
|
30
|
-
var
|
30
|
+
var _pdf_find_controller = require("../../web/pdf_find_controller");
|
31
31
|
|
32
|
-
var
|
32
|
+
var _pdf_link_service = require("../../web/pdf_link_service");
|
33
33
|
|
34
|
-
|
34
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
35
35
|
|
36
36
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
37
37
|
|
38
|
-
function
|
38
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
39
39
|
|
40
|
-
function
|
40
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
41
41
|
|
42
|
-
|
42
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
43
|
+
|
44
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
45
|
+
|
46
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
47
|
+
|
48
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
49
|
+
|
50
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
51
|
+
|
52
|
+
var MockLinkService =
|
53
|
+
/*#__PURE__*/
|
54
|
+
function (_SimpleLinkService) {
|
43
55
|
_inherits(MockLinkService, _SimpleLinkService);
|
44
56
|
|
45
57
|
function MockLinkService() {
|
46
|
-
|
58
|
+
var _this;
|
47
59
|
|
48
|
-
|
60
|
+
_classCallCheck(this, MockLinkService);
|
49
61
|
|
62
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(MockLinkService).call(this));
|
50
63
|
_this._page = 1;
|
51
64
|
_this._pdfDocument = null;
|
52
65
|
return _this;
|
53
66
|
}
|
54
67
|
|
55
68
|
_createClass(MockLinkService, [{
|
56
|
-
key:
|
69
|
+
key: "setDocument",
|
57
70
|
value: function setDocument(pdfDocument) {
|
58
71
|
this._pdfDocument = pdfDocument;
|
59
72
|
}
|
60
73
|
}, {
|
61
|
-
key:
|
74
|
+
key: "pagesCount",
|
62
75
|
get: function get() {
|
63
76
|
return this._pdfDocument.numPages;
|
64
77
|
}
|
65
78
|
}, {
|
66
|
-
key:
|
79
|
+
key: "page",
|
67
80
|
get: function get() {
|
68
81
|
return this._page;
|
69
82
|
},
|
@@ -76,8 +89,8 @@ var MockLinkService = function (_SimpleLinkService) {
|
|
76
89
|
}(_pdf_link_service.SimpleLinkService);
|
77
90
|
|
78
91
|
describe('pdf_find_controller', function () {
|
79
|
-
var eventBus
|
80
|
-
var pdfFindController
|
92
|
+
var eventBus;
|
93
|
+
var pdfFindController;
|
81
94
|
beforeEach(function (done) {
|
82
95
|
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)('tracemonkey.pdf'));
|
83
96
|
loadingTask.promise.then(function (pdfDocument) {
|
@@ -96,23 +109,122 @@ describe('pdf_find_controller', function () {
|
|
96
109
|
eventBus = null;
|
97
110
|
pdfFindController = null;
|
98
111
|
});
|
99
|
-
|
100
|
-
|
101
|
-
var
|
102
|
-
|
103
|
-
|
104
|
-
|
112
|
+
|
113
|
+
function testSearch(_ref) {
|
114
|
+
var parameters = _ref.parameters,
|
115
|
+
matchesPerPage = _ref.matchesPerPage,
|
116
|
+
selectedMatch = _ref.selectedMatch;
|
117
|
+
return new Promise(function (resolve) {
|
118
|
+
pdfFindController.executeCommand('find', parameters);
|
119
|
+
var totalPages = matchesPerPage.length;
|
120
|
+
|
121
|
+
for (var i = totalPages - 1; i >= 0; i--) {
|
122
|
+
if (matchesPerPage[i] > 0) {
|
123
|
+
totalPages = i + 1;
|
124
|
+
break;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
var totalMatches = matchesPerPage.reduce(function (a, b) {
|
129
|
+
return a + b;
|
130
|
+
});
|
131
|
+
eventBus.on('updatefindmatchescount', function onUpdateFindMatchesCount(evt) {
|
132
|
+
if (pdfFindController.pageMatches.length !== totalPages) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
|
136
|
+
eventBus.off('updatefindmatchescount', onUpdateFindMatchesCount);
|
137
|
+
expect(evt.matchesCount.total).toBe(totalMatches);
|
138
|
+
|
139
|
+
for (var _i = 0; _i < totalPages; _i++) {
|
140
|
+
expect(pdfFindController.pageMatches[_i].length).toEqual(matchesPerPage[_i]);
|
141
|
+
}
|
142
|
+
|
143
|
+
expect(pdfFindController.selected.pageIdx).toEqual(selectedMatch.pageIndex);
|
144
|
+
expect(pdfFindController.selected.matchIdx).toEqual(selectedMatch.matchIndex);
|
145
|
+
resolve();
|
146
|
+
});
|
105
147
|
});
|
106
|
-
|
107
|
-
|
108
|
-
|
148
|
+
}
|
149
|
+
|
150
|
+
it('performs a normal search', function (done) {
|
151
|
+
testSearch({
|
152
|
+
parameters: {
|
153
|
+
query: 'Dynamic',
|
154
|
+
caseSensitive: false,
|
155
|
+
entireWord: false,
|
156
|
+
phraseSearch: true,
|
157
|
+
findPrevious: false
|
158
|
+
},
|
159
|
+
matchesPerPage: [11, 5, 0, 3, 0, 0, 0, 1, 1, 1, 0, 3, 4, 4],
|
160
|
+
selectedMatch: {
|
161
|
+
pageIndex: 0,
|
162
|
+
matchIndex: 0
|
109
163
|
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
164
|
+
}).then(done);
|
165
|
+
});
|
166
|
+
it('performs a normal search and finds the previous result', function (done) {
|
167
|
+
testSearch({
|
168
|
+
parameters: {
|
169
|
+
query: 'conference',
|
170
|
+
caseSensitive: false,
|
171
|
+
entireWord: false,
|
172
|
+
phraseSearch: true,
|
173
|
+
findPrevious: true
|
174
|
+
},
|
175
|
+
matchesPerPage: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5],
|
176
|
+
selectedMatch: {
|
177
|
+
pageIndex: 13,
|
178
|
+
matchIndex: 4
|
114
179
|
}
|
115
|
-
|
116
|
-
|
180
|
+
}).then(done);
|
181
|
+
});
|
182
|
+
it('performs a case sensitive search', function (done) {
|
183
|
+
testSearch({
|
184
|
+
parameters: {
|
185
|
+
query: 'Dynamic',
|
186
|
+
caseSensitive: true,
|
187
|
+
entireWord: false,
|
188
|
+
phraseSearch: true,
|
189
|
+
findPrevious: false
|
190
|
+
},
|
191
|
+
matchesPerPage: [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3],
|
192
|
+
selectedMatch: {
|
193
|
+
pageIndex: 0,
|
194
|
+
matchIndex: 0
|
195
|
+
}
|
196
|
+
}).then(done);
|
197
|
+
});
|
198
|
+
it('performs an entire word search', function (done) {
|
199
|
+
testSearch({
|
200
|
+
parameters: {
|
201
|
+
query: 'Government',
|
202
|
+
caseSensitive: false,
|
203
|
+
entireWord: true,
|
204
|
+
phraseSearch: true,
|
205
|
+
findPrevious: false
|
206
|
+
},
|
207
|
+
matchesPerPage: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
|
208
|
+
selectedMatch: {
|
209
|
+
pageIndex: 12,
|
210
|
+
matchIndex: 0
|
211
|
+
}
|
212
|
+
}).then(done);
|
213
|
+
});
|
214
|
+
it('performs a multiple term (no phrase) search', function (done) {
|
215
|
+
testSearch({
|
216
|
+
parameters: {
|
217
|
+
query: 'alternate solution',
|
218
|
+
caseSensitive: false,
|
219
|
+
entireWord: false,
|
220
|
+
phraseSearch: false,
|
221
|
+
findPrevious: false
|
222
|
+
},
|
223
|
+
matchesPerPage: [0, 0, 0, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0],
|
224
|
+
selectedMatch: {
|
225
|
+
pageIndex: 5,
|
226
|
+
matchIndex: 0
|
227
|
+
}
|
228
|
+
}).then(done);
|
117
229
|
});
|
118
230
|
});
|
@@ -19,9 +19,9 @@
|
|
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
|
-
var _pdf_find_utils = require(
|
24
|
+
var _pdf_find_utils = require("../../web/pdf_find_utils");
|
25
25
|
|
26
26
|
describe('pdf_find_utils', function () {
|
27
27
|
describe('getCharacterType', function () {
|
@@ -44,14 +44,15 @@ describe('pdf_find_utils', function () {
|
|
44
44
|
'.': _pdf_find_utils.CharacterType.PUNCT,
|
45
45
|
';': _pdf_find_utils.CharacterType.PUNCT,
|
46
46
|
':': _pdf_find_utils.CharacterType.PUNCT,
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
"\u2122": _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
48
|
+
"\u0E25": _pdf_find_utils.CharacterType.THAI_LETTER,
|
49
|
+
"\u4000": _pdf_find_utils.CharacterType.HAN_LETTER,
|
50
|
+
"\uF950": _pdf_find_utils.CharacterType.HAN_LETTER,
|
51
|
+
"\u30C0": _pdf_find_utils.CharacterType.KATAKANA_LETTER,
|
52
|
+
"\u3050": _pdf_find_utils.CharacterType.HIRAGANA_LETTER,
|
53
|
+
"\uFF80": _pdf_find_utils.CharacterType.HALFWIDTH_KATAKANA_LETTER
|
54
54
|
};
|
55
|
+
|
55
56
|
for (var character in characters) {
|
56
57
|
var charCode = character.charCodeAt(0);
|
57
58
|
var type = characters[character];
|
@@ -19,9 +19,9 @@
|
|
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
|
-
var _pdf_history = require(
|
24
|
+
var _pdf_history = require("../../web/pdf_history");
|
25
25
|
|
26
26
|
describe('pdf_history', function () {
|
27
27
|
describe('isDestHashesEqual', function () {
|
@@ -34,7 +34,9 @@ describe('pdf_history', function () {
|
|
34
34
|
var destArrayString = JSON.stringify([{
|
35
35
|
num: 3757,
|
36
36
|
gen: 0
|
37
|
-
}, {
|
37
|
+
}, {
|
38
|
+
name: 'XYZ'
|
39
|
+
}, 92.918, 748.972, null]);
|
38
40
|
expect((0, _pdf_history.isDestHashesEqual)(destArrayString, 'page.157')).toEqual(false);
|
39
41
|
expect((0, _pdf_history.isDestHashesEqual)('page.157', destArrayString)).toEqual(false);
|
40
42
|
});
|
@@ -48,23 +50,33 @@ describe('pdf_history', function () {
|
|
48
50
|
var firstDest = [{
|
49
51
|
num: 1,
|
50
52
|
gen: 0
|
51
|
-
}, {
|
53
|
+
}, {
|
54
|
+
name: 'XYZ'
|
55
|
+
}, 0, 375, null];
|
52
56
|
var secondDest = [{
|
53
57
|
num: 5,
|
54
58
|
gen: 0
|
55
|
-
}, {
|
59
|
+
}, {
|
60
|
+
name: 'XYZ'
|
61
|
+
}, 0, 375, null];
|
56
62
|
var thirdDest = [{
|
57
63
|
num: 1,
|
58
64
|
gen: 0
|
59
|
-
}, {
|
65
|
+
}, {
|
66
|
+
name: 'XYZ'
|
67
|
+
}, 750, 0, null];
|
60
68
|
var fourthDest = [{
|
61
69
|
num: 1,
|
62
70
|
gen: 0
|
63
|
-
}, {
|
71
|
+
}, {
|
72
|
+
name: 'XYZ'
|
73
|
+
}, 0, 375, 1.0];
|
64
74
|
var fifthDest = [{
|
65
75
|
gen: 0,
|
66
76
|
num: 1
|
67
|
-
}, {
|
77
|
+
}, {
|
78
|
+
name: 'XYZ'
|
79
|
+
}, 0, 375, null];
|
68
80
|
it('should reject non-equal destination arrays', function () {
|
69
81
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, undefined)).toEqual(false);
|
70
82
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, [1, 2, 3, 4, 5])).toEqual(false);
|
@@ -19,24 +19,30 @@
|
|
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
|
-
var _primitives = require(
|
24
|
+
var _primitives = require("../../core/primitives");
|
25
25
|
|
26
|
-
var _test_utils = require(
|
26
|
+
var _test_utils = require("./test_utils");
|
27
27
|
|
28
28
|
describe('primitives', function () {
|
29
29
|
describe('Name', function () {
|
30
30
|
it('should retain the given name', function () {
|
31
31
|
var givenName = 'Font';
|
32
|
+
|
32
33
|
var name = _primitives.Name.get(givenName);
|
34
|
+
|
33
35
|
expect(name.name).toEqual(givenName);
|
34
36
|
});
|
35
37
|
it('should create only one object for a name and cache it', function () {
|
36
38
|
var firstFont = _primitives.Name.get('Font');
|
39
|
+
|
37
40
|
var secondFont = _primitives.Name.get('Font');
|
41
|
+
|
38
42
|
var firstSubtype = _primitives.Name.get('Subtype');
|
43
|
+
|
39
44
|
var secondSubtype = _primitives.Name.get('Subtype');
|
45
|
+
|
40
46
|
expect(firstFont).toBe(secondFont);
|
41
47
|
expect(firstSubtype).toBe(secondSubtype);
|
42
48
|
expect(firstFont).not.toBe(firstSubtype);
|
@@ -45,14 +51,20 @@ describe('primitives', function () {
|
|
45
51
|
describe('Cmd', function () {
|
46
52
|
it('should retain the given cmd name', function () {
|
47
53
|
var givenCmd = 'BT';
|
54
|
+
|
48
55
|
var cmd = _primitives.Cmd.get(givenCmd);
|
56
|
+
|
49
57
|
expect(cmd.cmd).toEqual(givenCmd);
|
50
58
|
});
|
51
59
|
it('should create only one object for a command and cache it', function () {
|
52
60
|
var firstBT = _primitives.Cmd.get('BT');
|
61
|
+
|
53
62
|
var secondBT = _primitives.Cmd.get('BT');
|
63
|
+
|
54
64
|
var firstET = _primitives.Cmd.get('ET');
|
65
|
+
|
55
66
|
var secondET = _primitives.Cmd.get('ET');
|
67
|
+
|
56
68
|
expect(firstBT).toBe(secondBT);
|
57
69
|
expect(firstET).toBe(secondET);
|
58
70
|
expect(firstBT).not.toBe(firstET);
|
@@ -63,12 +75,14 @@ describe('primitives', function () {
|
|
63
75
|
expect(dict.has()).toBeFalsy();
|
64
76
|
expect(dict.has('Prev')).toBeFalsy();
|
65
77
|
};
|
78
|
+
|
66
79
|
var checkInvalidKeyValues = function checkInvalidKeyValues(dict) {
|
67
80
|
expect(dict.get()).toBeUndefined();
|
68
81
|
expect(dict.get('Prev')).toBeUndefined();
|
69
82
|
expect(dict.get('Decode', 'D')).toBeUndefined();
|
70
83
|
expect(dict.get('FontFile', 'FontFile2', 'FontFile3')).toBeNull();
|
71
84
|
};
|
85
|
+
|
72
86
|
var emptyDict, dictWithSizeKey, dictWithManyKeys;
|
73
87
|
var storedSize = 42;
|
74
88
|
var testFontFile = 'file1';
|
@@ -195,7 +209,9 @@ describe('primitives', function () {
|
|
195
209
|
var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3', 'Size'];
|
196
210
|
var fontFileDict = new _primitives.Dict();
|
197
211
|
fontFileDict.set('FontFile', 'Type1 font file');
|
212
|
+
|
198
213
|
var mergedDict = _primitives.Dict.merge(null, [dictWithManyKeys, dictWithSizeKey, fontFileDict]);
|
214
|
+
|
199
215
|
var mergedKeys = mergedDict.getKeys();
|
200
216
|
expect(mergedKeys.sort()).toEqual(expectedKeys);
|
201
217
|
expect(mergedDict.get('FontFile')).toEqual(testFontFile);
|
@@ -233,10 +249,12 @@ describe('primitives', function () {
|
|
233
249
|
});
|
234
250
|
it('handles names', function () {
|
235
251
|
var name = _primitives.Name.get('Font');
|
252
|
+
|
236
253
|
expect((0, _primitives.isName)(name)).toEqual(true);
|
237
254
|
});
|
238
255
|
it('handles names with name check', function () {
|
239
256
|
var name = _primitives.Name.get('Font');
|
257
|
+
|
240
258
|
expect((0, _primitives.isName)(name, 'Font')).toEqual(true);
|
241
259
|
expect((0, _primitives.isName)(name, 'Subtype')).toEqual(false);
|
242
260
|
});
|
@@ -248,10 +266,12 @@ describe('primitives', function () {
|
|
248
266
|
});
|
249
267
|
it('handles commands', function () {
|
250
268
|
var cmd = _primitives.Cmd.get('BT');
|
269
|
+
|
251
270
|
expect((0, _primitives.isCmd)(cmd)).toEqual(true);
|
252
271
|
});
|
253
272
|
it('handles commands with cmd check', function () {
|
254
273
|
var cmd = _primitives.Cmd.get('BT');
|
274
|
+
|
255
275
|
expect((0, _primitives.isCmd)(cmd, 'BT')).toEqual(true);
|
256
276
|
expect((0, _primitives.isCmd)(cmd, 'ET')).toEqual(false);
|
257
277
|
});
|
@@ -19,11 +19,11 @@
|
|
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
|
-
var _stream = require(
|
24
|
+
var _stream = require("../../core/stream");
|
25
25
|
|
26
|
-
var _primitives = require(
|
26
|
+
var _primitives = require("../../core/primitives");
|
27
27
|
|
28
28
|
describe('stream', function () {
|
29
29
|
beforeEach(function () {
|
@@ -32,20 +32,25 @@ describe('stream', function () {
|
|
32
32
|
return {
|
33
33
|
compare: function compare(actual, expected) {
|
34
34
|
var result = {};
|
35
|
+
|
35
36
|
if (actual.length !== expected.length) {
|
36
37
|
result.pass = false;
|
37
38
|
result.message = 'Array length: ' + actual.length + ', expected: ' + expected.length;
|
38
39
|
return result;
|
39
40
|
}
|
41
|
+
|
40
42
|
result.pass = true;
|
43
|
+
|
41
44
|
for (var i = 0, ii = expected.length; i < ii; i++) {
|
42
45
|
var a = actual[i],
|
43
46
|
b = expected[i];
|
47
|
+
|
44
48
|
if (a !== b) {
|
45
49
|
result.pass = false;
|
46
50
|
break;
|
47
51
|
}
|
48
52
|
}
|
53
|
+
|
49
54
|
return result;
|
50
55
|
}
|
51
56
|
};
|