pdfjs-dist 2.2.228 → 2.3.200

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.

Files changed (84) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +8851 -8582
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +8717 -8394
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/image_decoders/pdf.image_decoders.js +3014 -2864
  9. package/image_decoders/pdf.image_decoders.js.map +1 -1
  10. package/image_decoders/pdf.image_decoders.min.js +1 -1
  11. package/lib/core/annotation.js +203 -39
  12. package/lib/core/chunked_stream.js +32 -9
  13. package/lib/core/core_utils.js +48 -22
  14. package/lib/core/document.js +44 -33
  15. package/lib/core/evaluator.js +68 -32
  16. package/lib/core/fonts.js +2 -2
  17. package/lib/core/glyphlist.js +1 -0
  18. package/lib/core/image.js +1 -1
  19. package/lib/core/jbig2.js +23 -6
  20. package/lib/core/jpg.js +54 -23
  21. package/lib/core/jpx.js +23 -6
  22. package/lib/core/obj.js +18 -16
  23. package/lib/core/operator_list.js +17 -14
  24. package/lib/core/parser.js +9 -12
  25. package/lib/core/pattern.js +22 -7
  26. package/lib/core/pdf_manager.js +4 -4
  27. package/lib/core/primitives.js +63 -42
  28. package/lib/core/stream.js +14 -0
  29. package/lib/core/type1_parser.js +9 -1
  30. package/lib/core/worker.js +17 -56
  31. package/lib/display/annotation_layer.js +194 -85
  32. package/lib/display/api.js +331 -213
  33. package/lib/display/canvas.js +6 -1
  34. package/lib/display/content_disposition.js +1 -1
  35. package/lib/display/display_utils.js +48 -18
  36. package/lib/display/network_utils.js +6 -0
  37. package/lib/display/pattern_helper.js +22 -5
  38. package/lib/display/svg.js +1 -1
  39. package/lib/display/text_layer.js +62 -53
  40. package/lib/display/xml_parser.js +1 -1
  41. package/lib/pdf.js +2 -3
  42. package/lib/pdf.worker.js +2 -2
  43. package/lib/shared/compatibility.js +23 -19
  44. package/lib/shared/message_handler.js +163 -196
  45. package/lib/shared/streams_polyfill.js +1 -1
  46. package/lib/shared/util.js +288 -196
  47. package/lib/test/unit/annotation_spec.js +687 -93
  48. package/lib/test/unit/api_spec.js +72 -27
  49. package/lib/test/unit/display_utils_spec.js +1 -1
  50. package/lib/test/unit/evaluator_spec.js +21 -5
  51. package/lib/test/unit/fetch_stream_spec.js +3 -1
  52. package/lib/test/unit/message_handler_spec.js +10 -6
  53. package/lib/test/unit/network_spec.js +3 -1
  54. package/lib/test/unit/network_utils_spec.js +14 -0
  55. package/lib/test/unit/node_stream_spec.js +3 -3
  56. package/lib/test/unit/primitives_spec.js +2 -2
  57. package/lib/test/unit/type1_parser_spec.js +1 -1
  58. package/lib/test/unit/ui_utils_spec.js +1 -1
  59. package/lib/test/unit/util_spec.js +10 -10
  60. package/lib/web/app.js +47 -35
  61. package/lib/web/app_options.js +4 -4
  62. package/lib/web/base_viewer.js +36 -12
  63. package/lib/web/chromecom.js +1 -3
  64. package/lib/web/download_manager.js +1 -1
  65. package/lib/web/firefox_print_service.js +7 -4
  66. package/lib/web/firefoxcom.js +10 -5
  67. package/lib/web/interfaces.js +4 -0
  68. package/lib/web/pdf_document_properties.js +1 -1
  69. package/lib/web/pdf_history.js +1 -1
  70. package/lib/web/pdf_link_service.js +7 -3
  71. package/lib/web/pdf_outline_viewer.js +2 -1
  72. package/lib/web/pdf_page_view.js +12 -16
  73. package/lib/web/pdf_print_service.js +3 -5
  74. package/lib/web/pdf_sidebar.js +3 -0
  75. package/lib/web/pdf_viewer.component.js +2 -2
  76. package/lib/web/toolbar.js +2 -0
  77. package/lib/web/ui_utils.js +1 -1
  78. package/package.json +1 -1
  79. package/web/pdf_viewer.css +5 -9
  80. package/web/pdf_viewer.js +60 -45
  81. package/web/pdf_viewer.js.map +1 -1
  82. package/external/streams/streams-lib.js +0 -3962
  83. package/external/url/url-lib.js +0 -627
  84. package/lib/shared/url_polyfill.js +0 -56
@@ -138,6 +138,68 @@ describe('annotation', function () {
138
138
  }, done.fail);
139
139
  });
140
140
  });
141
+ describe('getQuadPoints', function () {
142
+ var dict, rect;
143
+ beforeEach(function (done) {
144
+ dict = new _primitives.Dict();
145
+ rect = [];
146
+ done();
147
+ });
148
+ afterEach(function () {
149
+ dict = null;
150
+ rect = null;
151
+ });
152
+ it('should ignore missing quadpoints', function () {
153
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
154
+ });
155
+ it('should ignore non-array values', function () {
156
+ dict.set('QuadPoints', 'foo');
157
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
158
+ });
159
+ it('should ignore arrays where the length is not a multiple of eight', function () {
160
+ dict.set('QuadPoints', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
161
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
162
+ });
163
+ it('should ignore quadpoints if one coordinate lies outside the rectangle', function () {
164
+ rect = [10, 10, 20, 20];
165
+ var inputs = [[11, 11, 12, 12, 9, 13, 14, 14], [11, 11, 12, 12, 13, 9, 14, 14], [11, 11, 12, 12, 21, 13, 14, 14], [11, 11, 12, 12, 13, 21, 14, 14]];
166
+
167
+ for (var _i = 0, _inputs = inputs; _i < _inputs.length; _i++) {
168
+ var input = _inputs[_i];
169
+ dict.set('QuadPoints', input);
170
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
171
+ }
172
+ });
173
+ it('should process valid quadpoints arrays', function () {
174
+ rect = [10, 10, 20, 20];
175
+ dict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18]);
176
+ expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual([[{
177
+ x: 11,
178
+ y: 11
179
+ }, {
180
+ x: 12,
181
+ y: 12
182
+ }, {
183
+ x: 13,
184
+ y: 13
185
+ }, {
186
+ x: 14,
187
+ y: 14
188
+ }], [{
189
+ x: 15,
190
+ y: 15
191
+ }, {
192
+ x: 16,
193
+ y: 16
194
+ }, {
195
+ x: 17,
196
+ y: 17
197
+ }, {
198
+ x: 18,
199
+ y: 18
200
+ }]]);
201
+ });
202
+ });
141
203
  describe('Annotation', function () {
142
204
  var dict, ref;
143
205
  beforeAll(function (done) {
@@ -350,6 +412,218 @@ describe('annotation', function () {
350
412
  markupAnnotation.setCreationDate(undefined);
351
413
  expect(markupAnnotation.creationDate).toEqual(null);
352
414
  });
415
+ it('should not parse IRT/RT when not defined', function (done) {
416
+ dict.set('Type', _primitives.Name.get('Annot'));
417
+ dict.set('Subtype', _primitives.Name.get('Text'));
418
+ var xref = new _test_utils.XRefMock([{
419
+ ref: ref,
420
+ data: dict
421
+ }]);
422
+
423
+ _annotation.AnnotationFactory.create(xref, ref, pdfManagerMock, idFactoryMock).then(function (_ref5) {
424
+ var data = _ref5.data;
425
+ expect(data.inReplyTo).toBeUndefined();
426
+ expect(data.replyType).toBeUndefined();
427
+ done();
428
+ }, done.fail);
429
+ });
430
+ it('should parse IRT and set default RT when not defined.', function (done) {
431
+ var annotationRef = new _primitives.Ref(819, 0);
432
+ var annotationDict = new _primitives.Dict();
433
+ annotationDict.set('Type', _primitives.Name.get('Annot'));
434
+ annotationDict.set('Subtype', _primitives.Name.get('Text'));
435
+ var replyRef = new _primitives.Ref(820, 0);
436
+ var replyDict = new _primitives.Dict();
437
+ replyDict.set('Type', _primitives.Name.get('Annot'));
438
+ replyDict.set('Subtype', _primitives.Name.get('Text'));
439
+ replyDict.set('IRT', annotationRef);
440
+ var xref = new _test_utils.XRefMock([{
441
+ ref: annotationRef,
442
+ data: annotationDict
443
+ }, {
444
+ ref: replyRef,
445
+ data: replyDict
446
+ }]);
447
+ annotationDict.assignXref(xref);
448
+ replyDict.assignXref(xref);
449
+
450
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref6) {
451
+ var data = _ref6.data;
452
+ expect(data.inReplyTo).toEqual(annotationRef.toString());
453
+ expect(data.replyType).toEqual('R');
454
+ done();
455
+ }, done.fail);
456
+ });
457
+ it('should parse IRT/RT for a group type', function (done) {
458
+ var annotationRef = new _primitives.Ref(819, 0);
459
+ var annotationDict = new _primitives.Dict();
460
+ annotationDict.set('Type', _primitives.Name.get('Annot'));
461
+ annotationDict.set('Subtype', _primitives.Name.get('Text'));
462
+ annotationDict.set('T', 'ParentTitle');
463
+ annotationDict.set('Contents', 'ParentText');
464
+ annotationDict.set('CreationDate', 'D:20180423');
465
+ annotationDict.set('M', 'D:20190423');
466
+ annotationDict.set('C', [0, 0, 1]);
467
+ var popupRef = new _primitives.Ref(820, 0);
468
+ var popupDict = new _primitives.Dict();
469
+ popupDict.set('Type', _primitives.Name.get('Annot'));
470
+ popupDict.set('Subtype', _primitives.Name.get('Popup'));
471
+ popupDict.set('Parent', annotationRef);
472
+ annotationDict.set('Popup', popupRef);
473
+ var replyRef = new _primitives.Ref(821, 0);
474
+ var replyDict = new _primitives.Dict();
475
+ replyDict.set('Type', _primitives.Name.get('Annot'));
476
+ replyDict.set('Subtype', _primitives.Name.get('Text'));
477
+ replyDict.set('IRT', annotationRef);
478
+ replyDict.set('RT', _primitives.Name.get('Group'));
479
+ replyDict.set('T', 'ReplyTitle');
480
+ replyDict.set('Contents', 'ReplyText');
481
+ replyDict.set('CreationDate', 'D:20180523');
482
+ replyDict.set('M', 'D:20190523');
483
+ replyDict.set('C', [0.4]);
484
+ var xref = new _test_utils.XRefMock([{
485
+ ref: annotationRef,
486
+ data: annotationDict
487
+ }, {
488
+ ref: popupRef,
489
+ data: popupDict
490
+ }, {
491
+ ref: replyRef,
492
+ data: replyDict
493
+ }]);
494
+ annotationDict.assignXref(xref);
495
+ popupDict.assignXref(xref);
496
+ replyDict.assignXref(xref);
497
+
498
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref7) {
499
+ var data = _ref7.data;
500
+ expect(data.inReplyTo).toEqual(annotationRef.toString());
501
+ expect(data.replyType).toEqual('Group');
502
+ expect(data.title).toEqual('ParentTitle');
503
+ expect(data.contents).toEqual('ParentText');
504
+ expect(data.creationDate).toEqual('D:20180423');
505
+ expect(data.modificationDate).toEqual('D:20190423');
506
+ expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
507
+ expect(data.hasPopup).toEqual(true);
508
+ done();
509
+ }, done.fail);
510
+ });
511
+ it('should parse IRT/RT for a reply type', function (done) {
512
+ var annotationRef = new _primitives.Ref(819, 0);
513
+ var annotationDict = new _primitives.Dict();
514
+ annotationDict.set('Type', _primitives.Name.get('Annot'));
515
+ annotationDict.set('Subtype', _primitives.Name.get('Text'));
516
+ annotationDict.set('T', 'ParentTitle');
517
+ annotationDict.set('Contents', 'ParentText');
518
+ annotationDict.set('CreationDate', 'D:20180423');
519
+ annotationDict.set('M', 'D:20190423');
520
+ annotationDict.set('C', [0, 0, 1]);
521
+ var popupRef = new _primitives.Ref(820, 0);
522
+ var popupDict = new _primitives.Dict();
523
+ popupDict.set('Type', _primitives.Name.get('Annot'));
524
+ popupDict.set('Subtype', _primitives.Name.get('Popup'));
525
+ popupDict.set('Parent', annotationRef);
526
+ annotationDict.set('Popup', popupRef);
527
+ var replyRef = new _primitives.Ref(821, 0);
528
+ var replyDict = new _primitives.Dict();
529
+ replyDict.set('Type', _primitives.Name.get('Annot'));
530
+ replyDict.set('Subtype', _primitives.Name.get('Text'));
531
+ replyDict.set('IRT', annotationRef);
532
+ replyDict.set('RT', _primitives.Name.get('R'));
533
+ replyDict.set('T', 'ReplyTitle');
534
+ replyDict.set('Contents', 'ReplyText');
535
+ replyDict.set('CreationDate', 'D:20180523');
536
+ replyDict.set('M', 'D:20190523');
537
+ replyDict.set('C', [0.4]);
538
+ var xref = new _test_utils.XRefMock([{
539
+ ref: annotationRef,
540
+ data: annotationDict
541
+ }, {
542
+ ref: popupRef,
543
+ data: popupDict
544
+ }, {
545
+ ref: replyRef,
546
+ data: replyDict
547
+ }]);
548
+ annotationDict.assignXref(xref);
549
+ popupDict.assignXref(xref);
550
+ replyDict.assignXref(xref);
551
+
552
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref8) {
553
+ var data = _ref8.data;
554
+ expect(data.inReplyTo).toEqual(annotationRef.toString());
555
+ expect(data.replyType).toEqual('R');
556
+ expect(data.title).toEqual('ReplyTitle');
557
+ expect(data.contents).toEqual('ReplyText');
558
+ expect(data.creationDate).toEqual('D:20180523');
559
+ expect(data.modificationDate).toEqual('D:20190523');
560
+ expect(data.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
561
+ expect(data.hasPopup).toEqual(false);
562
+ done();
563
+ }, done.fail);
564
+ });
565
+ });
566
+ describe('TextAnnotation', function () {
567
+ it('should not parse state model and state when not defined', function (done) {
568
+ var annotationRef = new _primitives.Ref(819, 0);
569
+ var annotationDict = new _primitives.Dict();
570
+ annotationDict.set('Type', _primitives.Name.get('Annot'));
571
+ annotationDict.set('Subtype', _primitives.Name.get('Text'));
572
+ annotationDict.set('Contents', 'TestText');
573
+ var replyRef = new _primitives.Ref(820, 0);
574
+ var replyDict = new _primitives.Dict();
575
+ replyDict.set('Type', _primitives.Name.get('Annot'));
576
+ replyDict.set('Subtype', _primitives.Name.get('Text'));
577
+ replyDict.set('IRT', annotationRef);
578
+ replyDict.set('RT', _primitives.Name.get('R'));
579
+ replyDict.set('Contents', 'ReplyText');
580
+ var xref = new _test_utils.XRefMock([{
581
+ ref: annotationRef,
582
+ data: annotationDict
583
+ }, {
584
+ ref: replyRef,
585
+ data: replyDict
586
+ }]);
587
+ annotationDict.assignXref(xref);
588
+ replyDict.assignXref(xref);
589
+
590
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref9) {
591
+ var data = _ref9.data;
592
+ expect(data.stateModel).toBeNull();
593
+ expect(data.state).toBeNull();
594
+ done();
595
+ }, done.fail);
596
+ });
597
+ it('should correctly parse state model and state when defined', function (done) {
598
+ var annotationRef = new _primitives.Ref(819, 0);
599
+ var annotationDict = new _primitives.Dict();
600
+ annotationDict.set('Type', _primitives.Name.get('Annot'));
601
+ annotationDict.set('Subtype', _primitives.Name.get('Text'));
602
+ var replyRef = new _primitives.Ref(820, 0);
603
+ var replyDict = new _primitives.Dict();
604
+ replyDict.set('Type', _primitives.Name.get('Annot'));
605
+ replyDict.set('Subtype', _primitives.Name.get('Text'));
606
+ replyDict.set('IRT', annotationRef);
607
+ replyDict.set('RT', _primitives.Name.get('R'));
608
+ replyDict.set('StateModel', 'Review');
609
+ replyDict.set('State', 'Rejected');
610
+ var xref = new _test_utils.XRefMock([{
611
+ ref: annotationRef,
612
+ data: annotationDict
613
+ }, {
614
+ ref: replyRef,
615
+ data: replyDict
616
+ }]);
617
+ annotationDict.assignXref(xref);
618
+ replyDict.assignXref(xref);
619
+
620
+ _annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref10) {
621
+ var data = _ref10.data;
622
+ expect(data.stateModel).toEqual('Review');
623
+ expect(data.state).toEqual('Rejected');
624
+ done();
625
+ }, done.fail);
626
+ });
353
627
  });
354
628
  describe('LinkAnnotation', function () {
355
629
  it('should correctly parse a URI action', function (done) {
@@ -369,8 +643,8 @@ describe('annotation', function () {
369
643
  data: annotationDict
370
644
  }]);
371
645
 
372
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref5) {
373
- var data = _ref5.data;
646
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref11) {
647
+ var data = _ref11.data;
374
648
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
375
649
  expect(data.url).toEqual('http://www.ctan.org/tex-archive/info/lshort');
376
650
  expect(data.unsafeUrl).toEqual('http://www.ctan.org/tex-archive/info/lshort');
@@ -395,8 +669,8 @@ describe('annotation', function () {
395
669
  data: annotationDict
396
670
  }]);
397
671
 
398
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref6) {
399
- var data = _ref6.data;
672
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref12) {
673
+ var data = _ref12.data;
400
674
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
401
675
  expect(data.url).toEqual('http://www.hmrc.gov.uk/');
402
676
  expect(data.unsafeUrl).toEqual('http://www.hmrc.gov.uk');
@@ -423,8 +697,8 @@ describe('annotation', function () {
423
697
  data: annotationDict
424
698
  }]);
425
699
 
426
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref7) {
427
- var data = _ref7.data;
700
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref13) {
701
+ var data = _ref13.data;
428
702
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
429
703
  expect(data.url).toEqual(new URL((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4')).href);
430
704
  expect(data.unsafeUrl).toEqual((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4'));
@@ -449,8 +723,8 @@ describe('annotation', function () {
449
723
  data: annotationDict
450
724
  }]);
451
725
 
452
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref8) {
453
- var data = _ref8.data;
726
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref14) {
727
+ var data = _ref14.data;
454
728
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
455
729
  expect(data.url).toBeUndefined();
456
730
  expect(data.unsafeUrl).toBeUndefined();
@@ -477,8 +751,8 @@ describe('annotation', function () {
477
751
  data: annotationDict
478
752
  }]);
479
753
 
480
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref9) {
481
- var data = _ref9.data;
754
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref15) {
755
+ var data = _ref15.data;
482
756
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
483
757
  expect(data.url).toBeUndefined();
484
758
  expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
@@ -508,8 +782,8 @@ describe('annotation', function () {
508
782
  docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
509
783
  });
510
784
 
511
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref10) {
512
- var data = _ref10.data;
785
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref16) {
786
+ var data = _ref16.data;
513
787
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
514
788
  expect(data.url).toEqual('http://www.example.com/0013/001346/134685E.pdf#4.3');
515
789
  expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
@@ -535,8 +809,8 @@ describe('annotation', function () {
535
809
  data: annotationDict
536
810
  }]);
537
811
 
538
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref11) {
539
- var data = _ref11.data;
812
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref17) {
813
+ var data = _ref17.data;
540
814
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
541
815
  expect(data.url).toEqual('http://www.example.com/test.pdf#15');
542
816
  expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#15');
@@ -563,8 +837,8 @@ describe('annotation', function () {
563
837
  data: annotationDict
564
838
  }]);
565
839
 
566
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref12) {
567
- var data = _ref12.data;
840
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref18) {
841
+ var data = _ref18.data;
568
842
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
569
843
  expect(data.url).toEqual(new URL('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]').href);
570
844
  expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]');
@@ -598,8 +872,8 @@ describe('annotation', function () {
598
872
  docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
599
873
  });
600
874
 
601
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref13) {
602
- var data = _ref13.data;
875
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref19) {
876
+ var data = _ref19.data;
603
877
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
604
878
  expect(data.url).toEqual(new URL('http://www.example.com/test/pdfs/Part II/Part II.pdf').href);
605
879
  expect(data.unsafeUrl).toEqual('Part II/Part II.pdf');
@@ -629,8 +903,8 @@ describe('annotation', function () {
629
903
  ref: annotationRef,
630
904
  data: annotationDict
631
905
  }]);
632
- return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref14) {
633
- var data = _ref14.data;
906
+ return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref20) {
907
+ var data = _ref20.data;
634
908
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
635
909
  expect(data.url).toEqual(expectedUrl);
636
910
  expect(data.unsafeUrl).toEqual(expectedUnsafeUrl);
@@ -676,8 +950,8 @@ describe('annotation', function () {
676
950
  data: annotationDict
677
951
  }]);
678
952
 
679
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref15) {
680
- var data = _ref15.data;
953
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref21) {
954
+ var data = _ref21.data;
681
955
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
682
956
  expect(data.url).toBeUndefined();
683
957
  expect(data.unsafeUrl).toBeUndefined();
@@ -698,8 +972,8 @@ describe('annotation', function () {
698
972
  data: annotationDict
699
973
  }]);
700
974
 
701
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref16) {
702
- var data = _ref16.data;
975
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref22) {
976
+ var data = _ref22.data;
703
977
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
704
978
  expect(data.url).toBeUndefined();
705
979
  expect(data.unsafeUrl).toBeUndefined();
@@ -720,8 +994,8 @@ describe('annotation', function () {
720
994
  data: annotationDict
721
995
  }]);
722
996
 
723
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref17) {
724
- var data = _ref17.data;
997
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref23) {
998
+ var data = _ref23.data;
725
999
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
726
1000
  expect(data.url).toBeUndefined();
727
1001
  expect(data.unsafeUrl).toBeUndefined();
@@ -751,8 +1025,8 @@ describe('annotation', function () {
751
1025
  data: annotationDict
752
1026
  }]);
753
1027
 
754
- _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref18) {
755
- var data = _ref18.data;
1028
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref24) {
1029
+ var data = _ref24.data;
756
1030
  expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
757
1031
  expect(data.url).toBeUndefined();
758
1032
  expect(data.unsafeUrl).toBeUndefined();
@@ -760,6 +1034,58 @@ describe('annotation', function () {
760
1034
  done();
761
1035
  }, done.fail);
762
1036
  });
1037
+ it('should not set quadpoints if not defined', function (done) {
1038
+ var annotationDict = new _primitives.Dict();
1039
+ annotationDict.set('Type', _primitives.Name.get('Annot'));
1040
+ annotationDict.set('Subtype', _primitives.Name.get('Link'));
1041
+
1042
+ var annotationRef = _primitives.Ref.get(121, 0);
1043
+
1044
+ var xref = new _test_utils.XRefMock([{
1045
+ ref: annotationRef,
1046
+ data: annotationDict
1047
+ }]);
1048
+
1049
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref25) {
1050
+ var data = _ref25.data;
1051
+ expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
1052
+ expect(data.quadPoints).toBeUndefined();
1053
+ done();
1054
+ }, done.fail);
1055
+ });
1056
+ it('should set quadpoints if defined', function (done) {
1057
+ var annotationDict = new _primitives.Dict();
1058
+ annotationDict.set('Type', _primitives.Name.get('Annot'));
1059
+ annotationDict.set('Subtype', _primitives.Name.get('Link'));
1060
+ annotationDict.set('Rect', [10, 10, 20, 20]);
1061
+ annotationDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
1062
+
1063
+ var annotationRef = _primitives.Ref.get(121, 0);
1064
+
1065
+ var xref = new _test_utils.XRefMock([{
1066
+ ref: annotationRef,
1067
+ data: annotationDict
1068
+ }]);
1069
+
1070
+ _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref26) {
1071
+ var data = _ref26.data;
1072
+ expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
1073
+ expect(data.quadPoints).toEqual([[{
1074
+ x: 11,
1075
+ y: 11
1076
+ }, {
1077
+ x: 12,
1078
+ y: 12
1079
+ }, {
1080
+ x: 13,
1081
+ y: 13
1082
+ }, {
1083
+ x: 14,
1084
+ y: 14
1085
+ }]]);
1086
+ done();
1087
+ }, done.fail);
1088
+ });
763
1089
  });
764
1090
  describe('WidgetAnnotation', function () {
765
1091
  var widgetDict;
@@ -780,8 +1106,8 @@ describe('annotation', function () {
780
1106
  data: widgetDict
781
1107
  }]);
782
1108
 
783
- _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref19) {
784
- var data = _ref19.data;
1109
+ _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref27) {
1110
+ var data = _ref27.data;
785
1111
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
786
1112
  expect(data.fieldName).toEqual('');
787
1113
  done();
@@ -797,8 +1123,8 @@ describe('annotation', function () {
797
1123
  data: widgetDict
798
1124
  }]);
799
1125
 
800
- _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref20) {
801
- var data = _ref20.data;
1126
+ _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref28) {
1127
+ var data = _ref28.data;
802
1128
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
803
1129
  expect(data.fieldName).toEqual('foo');
804
1130
  done();
@@ -820,8 +1146,8 @@ describe('annotation', function () {
820
1146
  data: widgetDict
821
1147
  }]);
822
1148
 
823
- _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref21) {
824
- var data = _ref21.data;
1149
+ _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref29) {
1150
+ var data = _ref29.data;
825
1151
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
826
1152
  expect(data.fieldName).toEqual('foo.bar.baz');
827
1153
  done();
@@ -841,8 +1167,8 @@ describe('annotation', function () {
841
1167
  data: widgetDict
842
1168
  }]);
843
1169
 
844
- _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref22) {
845
- var data = _ref22.data;
1170
+ _annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref30) {
1171
+ var data = _ref30.data;
846
1172
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
847
1173
  expect(data.fieldName).toEqual('foo.bar');
848
1174
  done();
@@ -869,8 +1195,8 @@ describe('annotation', function () {
869
1195
  data: textWidgetDict
870
1196
  }]);
871
1197
 
872
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref23) {
873
- var data = _ref23.data;
1198
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref31) {
1199
+ var data = _ref31.data;
874
1200
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
875
1201
  expect(data.textAlignment).toEqual(null);
876
1202
  expect(data.maxLen).toEqual(null);
@@ -892,8 +1218,8 @@ describe('annotation', function () {
892
1218
  data: textWidgetDict
893
1219
  }]);
894
1220
 
895
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref24) {
896
- var data = _ref24.data;
1221
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref32) {
1222
+ var data = _ref32.data;
897
1223
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
898
1224
  expect(data.textAlignment).toEqual(null);
899
1225
  expect(data.maxLen).toEqual(null);
@@ -915,8 +1241,8 @@ describe('annotation', function () {
915
1241
  data: textWidgetDict
916
1242
  }]);
917
1243
 
918
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref25) {
919
- var data = _ref25.data;
1244
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref33) {
1245
+ var data = _ref33.data;
920
1246
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
921
1247
  expect(data.textAlignment).toEqual(1);
922
1248
  expect(data.maxLen).toEqual(20);
@@ -935,8 +1261,8 @@ describe('annotation', function () {
935
1261
  data: textWidgetDict
936
1262
  }]);
937
1263
 
938
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref26) {
939
- var data = _ref26.data;
1264
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref34) {
1265
+ var data = _ref34.data;
940
1266
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
941
1267
  expect(data.comb).toEqual(false);
942
1268
  done();
@@ -953,8 +1279,8 @@ describe('annotation', function () {
953
1279
  data: textWidgetDict
954
1280
  }]);
955
1281
 
956
- _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref27) {
957
- var data = _ref27.data;
1282
+ _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref35) {
1283
+ var data = _ref35.data;
958
1284
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
959
1285
  expect(data.comb).toEqual(true);
960
1286
  done();
@@ -976,8 +1302,8 @@ describe('annotation', function () {
976
1302
  ref: textWidgetRef,
977
1303
  data: textWidgetDict
978
1304
  }]);
979
- return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref28) {
980
- var data = _ref28.data;
1305
+ return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref36) {
1306
+ var data = _ref36.data;
981
1307
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
982
1308
  var valid = invalidFieldFlags.length === 0;
983
1309
  expect(data.comb).toEqual(valid);
@@ -1020,8 +1346,8 @@ describe('annotation', function () {
1020
1346
  data: buttonWidgetDict
1021
1347
  }]);
1022
1348
 
1023
- _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref29) {
1024
- var data = _ref29.data;
1349
+ _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref37) {
1350
+ var data = _ref37.data;
1025
1351
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1026
1352
  expect(data.checkBox).toEqual(true);
1027
1353
  expect(data.fieldValue).toEqual('1');
@@ -1040,8 +1366,8 @@ describe('annotation', function () {
1040
1366
  data: buttonWidgetDict
1041
1367
  }]);
1042
1368
 
1043
- _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref30) {
1044
- var data = _ref30.data;
1369
+ _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref38) {
1370
+ var data = _ref38.data;
1045
1371
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1046
1372
  expect(data.checkBox).toEqual(true);
1047
1373
  expect(data.fieldValue).toEqual('1');
@@ -1067,8 +1393,8 @@ describe('annotation', function () {
1067
1393
  data: buttonWidgetDict
1068
1394
  }]);
1069
1395
 
1070
- _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref31) {
1071
- var data = _ref31.data;
1396
+ _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref39) {
1397
+ var data = _ref39.data;
1072
1398
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1073
1399
  expect(data.checkBox).toEqual(false);
1074
1400
  expect(data.radioButton).toEqual(true);
@@ -1092,8 +1418,8 @@ describe('annotation', function () {
1092
1418
  data: buttonWidgetDict
1093
1419
  }]);
1094
1420
 
1095
- _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref32) {
1096
- var data = _ref32.data;
1421
+ _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref40) {
1422
+ var data = _ref40.data;
1097
1423
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1098
1424
  expect(data.checkBox).toEqual(false);
1099
1425
  expect(data.radioButton).toEqual(true);
@@ -1123,8 +1449,8 @@ describe('annotation', function () {
1123
1449
  data: choiceWidgetDict
1124
1450
  }]);
1125
1451
 
1126
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref33) {
1127
- var data = _ref33.data;
1452
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref41) {
1453
+ var data = _ref41.data;
1128
1454
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1129
1455
  expect(data.options).toEqual([]);
1130
1456
  done();
@@ -1161,8 +1487,8 @@ describe('annotation', function () {
1161
1487
  data: optionOneArr
1162
1488
  }]);
1163
1489
 
1164
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref34) {
1165
- var data = _ref34.data;
1490
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref42) {
1491
+ var data = _ref42.data;
1166
1492
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1167
1493
  expect(data.options).toEqual(expected);
1168
1494
  done();
@@ -1192,8 +1518,8 @@ describe('annotation', function () {
1192
1518
  data: optionBarStr
1193
1519
  }]);
1194
1520
 
1195
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref35) {
1196
- var data = _ref35.data;
1521
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref43) {
1522
+ var data = _ref43.data;
1197
1523
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1198
1524
  expect(data.options).toEqual(expected);
1199
1525
  done();
@@ -1219,8 +1545,8 @@ describe('annotation', function () {
1219
1545
  data: choiceWidgetDict
1220
1546
  }]);
1221
1547
 
1222
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref36) {
1223
- var data = _ref36.data;
1548
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref44) {
1549
+ var data = _ref44.data;
1224
1550
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1225
1551
  expect(data.options).toEqual(expected);
1226
1552
  done();
@@ -1241,8 +1567,8 @@ describe('annotation', function () {
1241
1567
  data: choiceWidgetDict
1242
1568
  }]);
1243
1569
 
1244
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref37) {
1245
- var data = _ref37.data;
1570
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref45) {
1571
+ var data = _ref45.data;
1246
1572
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1247
1573
  expect(data.options).toEqual(expected);
1248
1574
  done();
@@ -1259,8 +1585,8 @@ describe('annotation', function () {
1259
1585
  data: choiceWidgetDict
1260
1586
  }]);
1261
1587
 
1262
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref38) {
1263
- var data = _ref38.data;
1588
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref46) {
1589
+ var data = _ref46.data;
1264
1590
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1265
1591
  expect(data.fieldValue).toEqual(fieldValue);
1266
1592
  done();
@@ -1277,8 +1603,8 @@ describe('annotation', function () {
1277
1603
  data: choiceWidgetDict
1278
1604
  }]);
1279
1605
 
1280
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref39) {
1281
- var data = _ref39.data;
1606
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref47) {
1607
+ var data = _ref47.data;
1282
1608
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1283
1609
  expect(data.fieldValue).toEqual([fieldValue]);
1284
1610
  done();
@@ -1292,8 +1618,8 @@ describe('annotation', function () {
1292
1618
  data: choiceWidgetDict
1293
1619
  }]);
1294
1620
 
1295
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref40) {
1296
- var data = _ref40.data;
1621
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref48) {
1622
+ var data = _ref48.data;
1297
1623
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1298
1624
  expect(data.readOnly).toEqual(false);
1299
1625
  expect(data.combo).toEqual(false);
@@ -1311,8 +1637,8 @@ describe('annotation', function () {
1311
1637
  data: choiceWidgetDict
1312
1638
  }]);
1313
1639
 
1314
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref41) {
1315
- var data = _ref41.data;
1640
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref49) {
1641
+ var data = _ref49.data;
1316
1642
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1317
1643
  expect(data.readOnly).toEqual(false);
1318
1644
  expect(data.combo).toEqual(false);
@@ -1330,8 +1656,8 @@ describe('annotation', function () {
1330
1656
  data: choiceWidgetDict
1331
1657
  }]);
1332
1658
 
1333
- _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref42) {
1334
- var data = _ref42.data;
1659
+ _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref50) {
1660
+ var data = _ref50.data;
1335
1661
  expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
1336
1662
  expect(data.readOnly).toEqual(true);
1337
1663
  expect(data.combo).toEqual(true);
@@ -1354,8 +1680,8 @@ describe('annotation', function () {
1354
1680
  data: lineDict
1355
1681
  }]);
1356
1682
 
1357
- _annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(function (_ref43) {
1358
- var data = _ref43.data;
1683
+ _annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(function (_ref51) {
1684
+ var data = _ref51.data;
1359
1685
  expect(data.annotationType).toEqual(_util.AnnotationType.LINE);
1360
1686
  expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
1361
1687
  done();
@@ -1407,8 +1733,8 @@ describe('annotation', function () {
1407
1733
  fileSpecDict.assignXref(xref);
1408
1734
  fileAttachmentDict.assignXref(xref);
1409
1735
 
1410
- _annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(function (_ref44) {
1411
- var data = _ref44.data;
1736
+ _annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(function (_ref52) {
1737
+ var data = _ref52.data;
1412
1738
  expect(data.annotationType).toEqual(_util.AnnotationType.FILEATTACHMENT);
1413
1739
  expect(data.file.filename).toEqual('Test.txt');
1414
1740
  expect(data.file.content).toEqual((0, _util.stringToBytes)('Test attachment'));
@@ -1435,9 +1761,9 @@ describe('annotation', function () {
1435
1761
  data: popupDict
1436
1762
  }]);
1437
1763
 
1438
- _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref45) {
1439
- var data = _ref45.data,
1440
- viewable = _ref45.viewable;
1764
+ _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref53) {
1765
+ var data = _ref53.data,
1766
+ viewable = _ref53.viewable;
1441
1767
  expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
1442
1768
  expect(data.modificationDate).toEqual('D:20190423');
1443
1769
  expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
@@ -1460,9 +1786,9 @@ describe('annotation', function () {
1460
1786
  data: popupDict
1461
1787
  }]);
1462
1788
 
1463
- _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref46) {
1464
- var data = _ref46.data,
1465
- viewable = _ref46.viewable;
1789
+ _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref54) {
1790
+ var data = _ref54.data,
1791
+ viewable = _ref54.viewable;
1466
1792
  expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
1467
1793
  expect(data.modificationDate).toEqual(null);
1468
1794
  expect(data.color).toEqual(null);
@@ -1487,15 +1813,67 @@ describe('annotation', function () {
1487
1813
  data: popupDict
1488
1814
  }]);
1489
1815
 
1490
- _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref47) {
1491
- var data = _ref47.data,
1492
- viewable = _ref47.viewable;
1816
+ _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref55) {
1817
+ var data = _ref55.data,
1818
+ viewable = _ref55.viewable;
1493
1819
  expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
1494
1820
  expect(data.annotationFlags).toEqual(25);
1495
1821
  expect(viewable).toEqual(true);
1496
1822
  done();
1497
1823
  }, done.fail);
1498
1824
  });
1825
+ it('should correctly inherit Contents from group-master annotation ' + 'if parent has ReplyType == Group', function (done) {
1826
+ var annotationRef = new _primitives.Ref(819, 0);
1827
+ var annotationDict = new _primitives.Dict();
1828
+ annotationDict.set('Type', _primitives.Name.get('Annot'));
1829
+ annotationDict.set('Subtype', _primitives.Name.get('Text'));
1830
+ annotationDict.set('T', 'Correct Title');
1831
+ annotationDict.set('Contents', 'Correct Text');
1832
+ annotationDict.set('M', 'D:20190423');
1833
+ annotationDict.set('C', [0, 0, 1]);
1834
+ var replyRef = new _primitives.Ref(820, 0);
1835
+ var replyDict = new _primitives.Dict();
1836
+ replyDict.set('Type', _primitives.Name.get('Annot'));
1837
+ replyDict.set('Subtype', _primitives.Name.get('Text'));
1838
+ replyDict.set('IRT', annotationRef);
1839
+ replyDict.set('RT', _primitives.Name.get('Group'));
1840
+ replyDict.set('T', 'Reply Title');
1841
+ replyDict.set('Contents', 'Reply Text');
1842
+ replyDict.set('M', 'D:20190523');
1843
+ replyDict.set('C', [0.4]);
1844
+ var popupRef = new _primitives.Ref(821, 0);
1845
+ var popupDict = new _primitives.Dict();
1846
+ popupDict.set('Type', _primitives.Name.get('Annot'));
1847
+ popupDict.set('Subtype', _primitives.Name.get('Popup'));
1848
+ popupDict.set('T', 'Wrong Title');
1849
+ popupDict.set('Contents', 'Wrong Text');
1850
+ popupDict.set('Parent', replyRef);
1851
+ popupDict.set('M', 'D:20190623');
1852
+ popupDict.set('C', [0.8]);
1853
+ replyDict.set('Popup', popupRef);
1854
+ var xref = new _test_utils.XRefMock([{
1855
+ ref: annotationRef,
1856
+ data: annotationDict
1857
+ }, {
1858
+ ref: replyRef,
1859
+ data: replyDict
1860
+ }, {
1861
+ ref: popupRef,
1862
+ data: popupDict
1863
+ }]);
1864
+ annotationDict.assignXref(xref);
1865
+ popupDict.assignXref(xref);
1866
+ replyDict.assignXref(xref);
1867
+
1868
+ _annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref56) {
1869
+ var data = _ref56.data;
1870
+ expect(data.title).toEqual('Correct Title');
1871
+ expect(data.contents).toEqual('Correct Text');
1872
+ expect(data.modificationDate).toEqual('D:20190423');
1873
+ expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
1874
+ done();
1875
+ }, done.fail);
1876
+ });
1499
1877
  });
1500
1878
  describe('InkAnnotation', function () {
1501
1879
  it('should handle a single ink list', function (done) {
@@ -1511,8 +1889,8 @@ describe('annotation', function () {
1511
1889
  data: inkDict
1512
1890
  }]);
1513
1891
 
1514
- _annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref48) {
1515
- var data = _ref48.data;
1892
+ _annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref57) {
1893
+ var data = _ref57.data;
1516
1894
  expect(data.annotationType).toEqual(_util.AnnotationType.INK);
1517
1895
  expect(data.inkLists.length).toEqual(1);
1518
1896
  expect(data.inkLists[0]).toEqual([{
@@ -1544,8 +1922,8 @@ describe('annotation', function () {
1544
1922
  data: inkDict
1545
1923
  }]);
1546
1924
 
1547
- _annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref49) {
1548
- var data = _ref49.data;
1925
+ _annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref58) {
1926
+ var data = _ref58.data;
1549
1927
  expect(data.annotationType).toEqual(_util.AnnotationType.INK);
1550
1928
  expect(data.inkLists.length).toEqual(2);
1551
1929
  expect(data.inkLists[0]).toEqual([{
@@ -1566,4 +1944,220 @@ describe('annotation', function () {
1566
1944
  }, done.fail);
1567
1945
  });
1568
1946
  });
1947
+ describe('HightlightAnnotation', function () {
1948
+ it('should not set quadpoints if not defined', function (done) {
1949
+ var highlightDict = new _primitives.Dict();
1950
+ highlightDict.set('Type', _primitives.Name.get('Annot'));
1951
+ highlightDict.set('Subtype', _primitives.Name.get('Highlight'));
1952
+
1953
+ var highlightRef = _primitives.Ref.get(121, 0);
1954
+
1955
+ var xref = new _test_utils.XRefMock([{
1956
+ ref: highlightRef,
1957
+ data: highlightDict
1958
+ }]);
1959
+
1960
+ _annotation.AnnotationFactory.create(xref, highlightRef, pdfManagerMock, idFactoryMock).then(function (_ref59) {
1961
+ var data = _ref59.data;
1962
+ expect(data.annotationType).toEqual(_util.AnnotationType.HIGHLIGHT);
1963
+ expect(data.quadPoints).toBeUndefined();
1964
+ done();
1965
+ }, done.fail);
1966
+ });
1967
+ it('should set quadpoints if defined', function (done) {
1968
+ var highlightDict = new _primitives.Dict();
1969
+ highlightDict.set('Type', _primitives.Name.get('Annot'));
1970
+ highlightDict.set('Subtype', _primitives.Name.get('Highlight'));
1971
+ highlightDict.set('Rect', [10, 10, 20, 20]);
1972
+ highlightDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
1973
+
1974
+ var highlightRef = _primitives.Ref.get(121, 0);
1975
+
1976
+ var xref = new _test_utils.XRefMock([{
1977
+ ref: highlightRef,
1978
+ data: highlightDict
1979
+ }]);
1980
+
1981
+ _annotation.AnnotationFactory.create(xref, highlightRef, pdfManagerMock, idFactoryMock).then(function (_ref60) {
1982
+ var data = _ref60.data;
1983
+ expect(data.annotationType).toEqual(_util.AnnotationType.HIGHLIGHT);
1984
+ expect(data.quadPoints).toEqual([[{
1985
+ x: 11,
1986
+ y: 11
1987
+ }, {
1988
+ x: 12,
1989
+ y: 12
1990
+ }, {
1991
+ x: 13,
1992
+ y: 13
1993
+ }, {
1994
+ x: 14,
1995
+ y: 14
1996
+ }]]);
1997
+ done();
1998
+ }, done.fail);
1999
+ });
2000
+ });
2001
+ describe('UnderlineAnnotation', function () {
2002
+ it('should not set quadpoints if not defined', function (done) {
2003
+ var underlineDict = new _primitives.Dict();
2004
+ underlineDict.set('Type', _primitives.Name.get('Annot'));
2005
+ underlineDict.set('Subtype', _primitives.Name.get('Underline'));
2006
+
2007
+ var underlineRef = _primitives.Ref.get(121, 0);
2008
+
2009
+ var xref = new _test_utils.XRefMock([{
2010
+ ref: underlineRef,
2011
+ data: underlineDict
2012
+ }]);
2013
+
2014
+ _annotation.AnnotationFactory.create(xref, underlineRef, pdfManagerMock, idFactoryMock).then(function (_ref61) {
2015
+ var data = _ref61.data;
2016
+ expect(data.annotationType).toEqual(_util.AnnotationType.UNDERLINE);
2017
+ expect(data.quadPoints).toBeUndefined();
2018
+ done();
2019
+ }, done.fail);
2020
+ });
2021
+ it('should set quadpoints if defined', function (done) {
2022
+ var underlineDict = new _primitives.Dict();
2023
+ underlineDict.set('Type', _primitives.Name.get('Annot'));
2024
+ underlineDict.set('Subtype', _primitives.Name.get('Underline'));
2025
+ underlineDict.set('Rect', [10, 10, 20, 20]);
2026
+ underlineDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
2027
+
2028
+ var underlineRef = _primitives.Ref.get(121, 0);
2029
+
2030
+ var xref = new _test_utils.XRefMock([{
2031
+ ref: underlineRef,
2032
+ data: underlineDict
2033
+ }]);
2034
+
2035
+ _annotation.AnnotationFactory.create(xref, underlineRef, pdfManagerMock, idFactoryMock).then(function (_ref62) {
2036
+ var data = _ref62.data;
2037
+ expect(data.annotationType).toEqual(_util.AnnotationType.UNDERLINE);
2038
+ expect(data.quadPoints).toEqual([[{
2039
+ x: 11,
2040
+ y: 11
2041
+ }, {
2042
+ x: 12,
2043
+ y: 12
2044
+ }, {
2045
+ x: 13,
2046
+ y: 13
2047
+ }, {
2048
+ x: 14,
2049
+ y: 14
2050
+ }]]);
2051
+ done();
2052
+ }, done.fail);
2053
+ });
2054
+ });
2055
+ describe('SquigglyAnnotation', function () {
2056
+ it('should not set quadpoints if not defined', function (done) {
2057
+ var squigglyDict = new _primitives.Dict();
2058
+ squigglyDict.set('Type', _primitives.Name.get('Annot'));
2059
+ squigglyDict.set('Subtype', _primitives.Name.get('Squiggly'));
2060
+
2061
+ var squigglyRef = _primitives.Ref.get(121, 0);
2062
+
2063
+ var xref = new _test_utils.XRefMock([{
2064
+ ref: squigglyRef,
2065
+ data: squigglyDict
2066
+ }]);
2067
+
2068
+ _annotation.AnnotationFactory.create(xref, squigglyRef, pdfManagerMock, idFactoryMock).then(function (_ref63) {
2069
+ var data = _ref63.data;
2070
+ expect(data.annotationType).toEqual(_util.AnnotationType.SQUIGGLY);
2071
+ expect(data.quadPoints).toBeUndefined();
2072
+ done();
2073
+ }, done.fail);
2074
+ });
2075
+ it('should set quadpoints if defined', function (done) {
2076
+ var squigglyDict = new _primitives.Dict();
2077
+ squigglyDict.set('Type', _primitives.Name.get('Annot'));
2078
+ squigglyDict.set('Subtype', _primitives.Name.get('Squiggly'));
2079
+ squigglyDict.set('Rect', [10, 10, 20, 20]);
2080
+ squigglyDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
2081
+
2082
+ var squigglyRef = _primitives.Ref.get(121, 0);
2083
+
2084
+ var xref = new _test_utils.XRefMock([{
2085
+ ref: squigglyRef,
2086
+ data: squigglyDict
2087
+ }]);
2088
+
2089
+ _annotation.AnnotationFactory.create(xref, squigglyRef, pdfManagerMock, idFactoryMock).then(function (_ref64) {
2090
+ var data = _ref64.data;
2091
+ expect(data.annotationType).toEqual(_util.AnnotationType.SQUIGGLY);
2092
+ expect(data.quadPoints).toEqual([[{
2093
+ x: 11,
2094
+ y: 11
2095
+ }, {
2096
+ x: 12,
2097
+ y: 12
2098
+ }, {
2099
+ x: 13,
2100
+ y: 13
2101
+ }, {
2102
+ x: 14,
2103
+ y: 14
2104
+ }]]);
2105
+ done();
2106
+ }, done.fail);
2107
+ });
2108
+ });
2109
+ describe('StrikeOutAnnotation', function () {
2110
+ it('should not set quadpoints if not defined', function (done) {
2111
+ var strikeOutDict = new _primitives.Dict();
2112
+ strikeOutDict.set('Type', _primitives.Name.get('Annot'));
2113
+ strikeOutDict.set('Subtype', _primitives.Name.get('StrikeOut'));
2114
+
2115
+ var strikeOutRef = _primitives.Ref.get(121, 0);
2116
+
2117
+ var xref = new _test_utils.XRefMock([{
2118
+ ref: strikeOutRef,
2119
+ data: strikeOutDict
2120
+ }]);
2121
+
2122
+ _annotation.AnnotationFactory.create(xref, strikeOutRef, pdfManagerMock, idFactoryMock).then(function (_ref65) {
2123
+ var data = _ref65.data;
2124
+ expect(data.annotationType).toEqual(_util.AnnotationType.STRIKEOUT);
2125
+ expect(data.quadPoints).toBeUndefined();
2126
+ done();
2127
+ }, done.fail);
2128
+ });
2129
+ it('should set quadpoints if defined', function (done) {
2130
+ var strikeOutDict = new _primitives.Dict();
2131
+ strikeOutDict.set('Type', _primitives.Name.get('Annot'));
2132
+ strikeOutDict.set('Subtype', _primitives.Name.get('StrikeOut'));
2133
+ strikeOutDict.set('Rect', [10, 10, 20, 20]);
2134
+ strikeOutDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
2135
+
2136
+ var strikeOutRef = _primitives.Ref.get(121, 0);
2137
+
2138
+ var xref = new _test_utils.XRefMock([{
2139
+ ref: strikeOutRef,
2140
+ data: strikeOutDict
2141
+ }]);
2142
+
2143
+ _annotation.AnnotationFactory.create(xref, strikeOutRef, pdfManagerMock, idFactoryMock).then(function (_ref66) {
2144
+ var data = _ref66.data;
2145
+ expect(data.annotationType).toEqual(_util.AnnotationType.STRIKEOUT);
2146
+ expect(data.quadPoints).toEqual([[{
2147
+ x: 11,
2148
+ y: 11
2149
+ }, {
2150
+ x: 12,
2151
+ y: 12
2152
+ }, {
2153
+ x: 13,
2154
+ y: 13
2155
+ }, {
2156
+ x: 14,
2157
+ y: 14
2158
+ }]]);
2159
+ done();
2160
+ }, done.fail);
2161
+ });
2162
+ });
1569
2163
  });