1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965 | 1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ShapeAnnotation = (function () {
function ShapeAnnotation(pdfviewer, pdfViewerBase) {
this.shapeCount = 0;
this.isAddAnnotationProgramatically = false;
this.pdfViewer = pdfviewer;
this.pdfViewerBase = pdfViewerBase;
}
ShapeAnnotation.prototype.renderShapeAnnotations = function (shapeAnnotations, pageNumber, isImportAcion, isAnnotOrderAction) {
if (shapeAnnotations) {
if (shapeAnnotations.length >= 1) {
var shapeAnnots = this.pdfViewer.annotation.getStoredAnnotations(pageNumber, shapeAnnotations, '_annotations_shape');
if (!shapeAnnots || isAnnotOrderAction || isImportAcion) {
for (var i = 0; i < shapeAnnotations.length; i++) {
var annotation = shapeAnnotations[parseInt(i.toString(), 10)];
annotation.annotationAddMode = this.pdfViewer.annotationModule.findAnnotationMode(annotation, pageNumber, annotation.AnnotType);
var annotationObject = null;
this.shapeCount = this.shapeCount + 1;
var isAnnotationRotated = void 0;
if (annotation.ShapeAnnotationType) {
if (isImportAcion) {
if (this.pdfViewerBase.isJsonImported) {
annotation.Bounds = this.pdfViewerBase.
importJsonForRotatedDocuments(annotation.Rotate, pageNumber, annotation.Bounds, annotation.AnnotationRotation);
isAnnotationRotated = this.pdfViewerBase.isPageRotated;
}
}
var vertexPoints = null;
if (annotation.VertexPoints) {
vertexPoints = [];
if (isImportAcion && this.pdfViewerBase.isJsonImported) {
vertexPoints =
this.pdfViewerBase.calculateVertexPoints(annotation.Rotate, pageNumber, annotation.VertexPoints, annotation.AnnotationRotation);
}
else {
for (var j = 0; j < annotation.VertexPoints.length; j++) {
var x = annotation.VertexPoints[parseInt(j.toString(), 10)].X ?
annotation.VertexPoints[parseInt(j.toString(), 10)].X :
annotation.VertexPoints[parseInt(j.toString(), 10)].x;
var y = annotation.VertexPoints[parseInt(j.toString(), 10)].Y ?
annotation.VertexPoints[parseInt(j.toString(), 10)].Y :
annotation.VertexPoints[parseInt(j.toString(), 10)].y;
var point = { x: x, y: y };
vertexPoints.push(point);
}
}
}
if (annotation.Bounds && annotation.EnableShapeLabel === true) {
annotation.LabelBounds = this.pdfViewer.annotationModule.inputElementModule.
calculateLabelBoundsFromLoadedDocument(annotation.Bounds);
annotation.LabelBorderColor = annotation.LabelBorderColor ? annotation.LabelBorderColor :
annotation.StrokeColor;
annotation.FontColor = annotation.FontColor ? annotation.FontColor : annotation.StrokeColor;
annotation.LabelFillColor = annotation.LabelFillColor ? annotation.LabelFillColor : annotation.FillColor;
annotation.FontSize = annotation.FontSize ? annotation.FontSize : 16;
annotation.LabelSettings = annotation.LabelSettings ? annotation.LabelSettings :
this.pdfViewer.shapeLabelSettings;
}
var annotationSelectorSettings = typeof (annotation.AnnotationSelectorSettings) === 'string' ? JSON.parse(annotation.AnnotationSelectorSettings) : annotation.AnnotationSelectorSettings;
if (ej2_base_1.isNullOrUndefined(annotationSelectorSettings)) {
this.pdfViewerBase.annotationSelectorSettingLoad(annotation);
}
else {
annotation.AnnotationSelectorSettings = annotationSelectorSettings;
}
annotation.AnnotationSettings = annotation.AnnotationSettings ?
annotation.AnnotationSettings : this.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
if (annotation.IsLocked) {
annotation.AnnotationSettings.isLock = annotation.IsLocked;
}
annotation.allowedInteractions = annotation.AllowedInteractions ? annotation.AllowedInteractions :
this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
var left = annotation.Bounds.X ? annotation.Bounds.X : annotation.Bounds.x;
var top_1 = annotation.Bounds.Y ? annotation.Bounds.Y : annotation.Bounds.y;
var width = annotation.Bounds.Width ? annotation.Bounds.Width : annotation.Bounds.width;
var height = annotation.Bounds.Height ? annotation.Bounds.Height : annotation.Bounds.height;
annotationObject = {
id: 'shape' + this.shapeCount, shapeAnnotationType: annotation.ShapeAnnotationType, author: annotation.Author, allowedInteractions: annotation.allowedInteractions, modifiedDate: annotation.ModifiedDate, subject: annotation.Subject, pageNumber: pageNumber,
note: annotation.Note, strokeColor: annotation.StrokeColor, fillColor: annotation.FillColor,
opacity: annotation.Opacity, thickness: annotation.Thickness, rectangleDifference: annotation.RectangleDifference, borderStyle: annotation.BorderStyle, borderDashArray: annotation.BorderDashArray, rotateAngle: annotation.RotateAngle, isCloudShape: annotation.IsCloudShape,
cloudIntensity: annotation.CloudIntensity, vertexPoints: vertexPoints, lineHeadStart: annotation.LineHeadStart, lineHeadEnd: annotation.LineHeadEnd, isLocked: annotation.IsLocked,
comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
review: { state: annotation.State, stateModel: annotation.StateModel,
modifiedDate: annotation.ModifiedDate, author: annotation.Author },
annotName: annotation.AnnotName, bounds: { left: left, top: top_1, width: width,
height: height, right: annotation.Bounds.Right, bottom: annotation.Bounds.Bottom },
labelContent: annotation.LabelContent, enableShapeLabel: annotation.EnableShapeLabel,
labelFillColor: annotation.LabelFillColor, fontColor: annotation.FontColor,
labelBorderColor: annotation.LabelBorderColor, fontSize: annotation.FontSize,
labelBounds: annotation.LabelBounds, annotationSelectorSettings: this.getSettings(annotation),
labelSettings: annotation.LabelSettings, annotationSettings: annotation.AnnotationSettings,
customData: this.pdfViewer.annotation.getCustomData(annotation), isPrint: annotation.IsPrint,
isCommentLock: annotation.IsCommentLock, isAnnotationRotated: isAnnotationRotated
};
var vPoints = annotationObject.vertexPoints;
if (vertexPoints == null) {
vPoints = [];
}
annotation.AnnotationSelectorSettings = annotation.AnnotationSelectorSettings ? typeof (annotation.AnnotationSelectorSettings) === 'string' ? JSON.parse(annotation.AnnotationSelectorSettings) : annotation.AnnotationSelectorSettings : this.pdfViewer.annotationSelectorSettings;
var annot = {
id: 'shape' + this.shapeCount, shapeAnnotationType: this.getShapeType(annotationObject), author: annotationObject.author, allowedInteractions: annotationObject.allowedInteractions, modifiedDate: annotationObject.modifiedDate, annotName: annotationObject.annotName,
subject: annotationObject.subject, notes: annotationObject.note, fillColor: annotationObject.fillColor,
strokeColor: annotationObject.strokeColor, opacity: annotationObject.opacity,
thickness: annotationObject.thickness, borderStyle: annotationObject.borderStyle, borderDashArray: annotationObject.borderDashArray ? annotationObject.borderDashArray.toString() : '0', rotateAngle: parseFloat(annotationObject.rotateAngle.split('Angle')[1]), comments: annotationObject.comments, review: annotationObject.review, isCloudShape: annotationObject.isCloudShape, cloudIntensity: annotationObject.cloudIntensity, taregetDecoraterShapes: this.pdfViewer.annotation.getArrowType(annotationObject.lineHeadEnd),
sourceDecoraterShapes: this.pdfViewer.annotation.getArrowType(annotationObject.lineHeadStart),
vertexPoints: vPoints, bounds: { x: annotationObject.bounds.left, y: annotationObject.bounds.top,
width: annotationObject.bounds.width, height: annotationObject.bounds.height },
pageIndex: annotationObject.pageNumber,
labelContent: annotation.LabelContent, enableShapeLabel: annotation.EnableShapeLabel,
labelFillColor: annotation.LabelFillColor,
fontColor: annotation.FontColor, labelBorderColor: annotation.LabelBorderColor,
fontSize: annotation.FontSize,
labelBounds: annotation.LabelBounds, annotationSelectorSettings: annotation.AnnotationSelectorSettings,
annotationSettings: annotationObject.annotationSettings, annotationAddMode: annotation.annotationAddMode,
isPrint: annotation.IsPrint, isCommentLock: annotationObject.isCommentLock,
customData: annotationObject.customData
};
var addedAnnot = this.pdfViewer.add(annot);
this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotationObject, '_annotations_shape');
if (this.isAddAnnotationProgramatically) {
var settings = {
opacity: annot.opacity, strokeColor: annot.strokeColor, thickness: annot.thickness,
modifiedDate: annot.modifiedDate,
width: annot.bounds.width, height: annot.bounds.height
};
this.pdfViewer.fireAnnotationAdd(annot.pageIndex, annot.annotName, annotation.ShapeAnnotationType, annot.bounds, settings);
}
}
}
}
}
else if (shapeAnnotations.shapeAnnotationType) {
var annotationObject = this.createAnnotationObject(shapeAnnotations);
if (!ej2_base_1.isNullOrUndefined(shapeAnnotations.formFieldAnnotationType) && shapeAnnotations.formFieldAnnotationType !== '') {
this.pdfViewer.annotationModule.isFormFieldShape = true;
}
else {
this.pdfViewer.annotationModule.isFormFieldShape = false;
}
this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotationObject, '_annotations_shape');
if (shapeAnnotations) {
shapeAnnotations.customData = annotationObject.customData;
}
this.pdfViewer.annotationModule.triggerAnnotationAdd(shapeAnnotations);
}
}
};
ShapeAnnotation.prototype.getSettings = function (annotation) {
var selector = this.pdfViewer.annotationSelectorSettings;
if (annotation.AnnotationSelectorSettings) {
selector = typeof (annotation.AnnotationSelectorSettings) === 'string' ? JSON.parse(annotation.AnnotationSelectorSettings) : annotation.AnnotationSelectorSettings;
}
else {
selector = this.getSelector(annotation.ShapeAnnotationType, annotation.Subject);
}
return selector;
};
ShapeAnnotation.prototype.setAnnotationType = function (type) {
this.updateShapeProperties();
this.pdfViewerBase.disableTextSelectionMode();
var author = 'Guest';
var subject = '';
var customData;
switch (type) {
case 'Line': {
this.currentAnnotationMode = 'Line';
var modifiedDateLine = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.lineSettings.author ? this.pdfViewer.lineSettings.author : 'Guest';
subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.lineSettings.subject ? this.pdfViewer.lineSettings.subject : 'Line';
customData = !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.customData) ?
this.pdfViewer.annotationSettings.customData : this.pdfViewer.lineSettings.customData ?
this.pdfViewer.lineSettings.customData : null;
this.pdfViewer.drawingObject = {
shapeAnnotationType: this.setShapeType('Line'), fillColor: this.lineFillColor, notes: '', strokeColor: this.lineStrokeColor, opacity: this.lineOpacity,
thickness: this.lineThickness, modifiedDate: modifiedDateLine, borderDashArray: this.lineDashArray.toString(),
sourceDecoraterShapes: this.pdfViewer.annotation.getArrowType(this.lineStartHead.toString()),
taregetDecoraterShapes: this.pdfViewer.annotation.getArrowType(this.lineEndHead.toString()),
author: author, subject: subject, lineHeadStart: this.lineStartHead, lineHeadEnd: this.lineEndHead,
isCommentLock: false, customData: customData
};
this.pdfViewer.tool = 'Line';
break;
}
case 'Arrow': {
this.currentAnnotationMode = 'Arrow';
var modifiedDateArrow = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.arrowSettings.author ? this.pdfViewer.arrowSettings.author : 'Guest';
subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.arrowSettings.subject ? this.pdfViewer.arrowSettings.subject : 'Arrow';
customData = !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.customData) ?
this.pdfViewer.annotationSettings.customData : this.pdfViewer.arrowSettings.customData ?
this.pdfViewer.arrowSettings.customData : null;
this.pdfViewer.drawingObject = {
shapeAnnotationType: this.setShapeType('Arrow'), opacity: this.arrowOpacity,
sourceDecoraterShapes: this.pdfViewer.annotation.getArrowType(this.arrowStartHead.toString()),
taregetDecoraterShapes: this.pdfViewer.annotation.getArrowType(this.arrowEndHead.toString()),
fillColor: this.arrowFillColor, strokeColor: this.arrowStrokeColor, notes: '', thickness: this.arrowThickness,
borderDashArray: this.arrowDashArray.toString(), author: author, subject: subject,
modifiedDate: modifiedDateArrow, lineHeadStart: this.arrowStartHead, lineHeadEnd: this.arrowEndHead,
isCommentLock: false, customData: customData
};
this.pdfViewer.tool = 'Line';
break;
}
case 'Rectangle': {
this.currentAnnotationMode = 'Rectangle';
var modifiedDateRect = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.rectangleSettings.author ? this.pdfViewer.rectangleSettings.author : 'Guest';
subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.rectangleSettings.subject ? this.pdfViewer.rectangleSettings.subject : 'Rectangle';
customData = !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.customData) ?
this.pdfViewer.annotationSettings.customData : this.pdfViewer.rectangleSettings.customData ?
this.pdfViewer.rectangleSettings.customData : null;
this.pdfViewer.drawingObject = {
shapeAnnotationType: this.setShapeType('Rectangle'), strokeColor: this.rectangleStrokeColor,
fillColor: this.rectangleFillColor, opacity: this.rectangleOpacity, notes: '',
thickness: this.rectangleThickness, borderDashArray: '0', modifiedDate: modifiedDateRect,
author: author, subject: subject, isCommentLock: false, customData: customData
};
this.pdfViewer.tool = 'DrawTool';
break;
}
case 'Circle': {
this.currentAnnotationMode = 'Circle';
var modifiedDateCir = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.circleSettings.author ? this.pdfViewer.circleSettings.author : 'Guest';
subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.circleSettings.subject ? this.pdfViewer.circleSettings.subject : 'Circle';
customData = !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.customData) ?
this.pdfViewer.annotationSettings.customData : this.pdfViewer.circleSettings.customData ?
this.pdfViewer.circleSettings.customData : null;
this.pdfViewer.drawingObject = {
shapeAnnotationType: this.setShapeType('Circle'), strokeColor: this.circleStrokeColor,
fillColor: this.circleFillColor, opacity: this.circleOpacity, notes: '',
thickness: this.circleThickness, borderDashArray: '0', modifiedDate: modifiedDateCir,
author: author, subject: subject, isCommentLock: false, customData: customData
};
this.pdfViewer.tool = 'DrawTool';
break;
}
case 'Polygon': {
this.currentAnnotationMode = 'Polygon';
var modifiedDatePolygon = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.polygonSettings.author ? this.pdfViewer.polygonSettings.author : 'Guest';
subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.polygonSettings.subject ? this.pdfViewer.polygonSettings.subject : 'Polygon';
customData = !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.customData) ?
this.pdfViewer.annotationSettings.customData : this.pdfViewer.polygonSettings.customData ?
this.pdfViewer.polygonSettings.customData : null;
this.pdfViewer.drawingObject = {
strokeColor: this.polygonStrokeColor, fillColor: this.polygonFillColor,
opacity: this.polygonOpacity, thickness: this.polygonThickness, borderDashArray: '0',
notes: '', author: author, subject: subject,
modifiedDate: modifiedDatePolygon, borderStyle: '', isCommentLock: false, customData: customData
};
this.pdfViewer.tool = 'Polygon';
break;
}
}
};
ShapeAnnotation.prototype.updateShapeProperties = function () {
this.lineFillColor = this.pdfViewer.lineSettings.fillColor ? this.pdfViewer.lineSettings.fillColor : '#ffffff00';
this.lineStrokeColor = this.pdfViewer.lineSettings.strokeColor ? this.pdfViewer.lineSettings.strokeColor : '#ff0000';
this.lineThickness = this.pdfViewer.lineSettings.thickness ? this.pdfViewer.lineSettings.thickness : 1;
this.lineOpacity = this.pdfViewer.lineSettings.opacity ? this.pdfViewer.lineSettings.opacity : 1;
this.lineDashArray = this.pdfViewer.lineSettings.borderDashArray ? this.pdfViewer.lineSettings.borderDashArray : 0;
this.lineStartHead = this.pdfViewer.lineSettings.lineHeadStartStyle ? this.pdfViewer.lineSettings.lineHeadStartStyle : 'None';
this.lineEndHead = this.pdfViewer.lineSettings.lineHeadEndStyle ? this.pdfViewer.lineSettings.lineHeadEndStyle : 'None';
this.arrowFillColor = this.pdfViewer.arrowSettings.fillColor ? this.pdfViewer.arrowSettings.fillColor : '#ffffff00';
this.arrowStrokeColor = this.pdfViewer.arrowSettings.strokeColor ? this.pdfViewer.arrowSettings.strokeColor : '#ff0000';
this.arrowThickness = this.pdfViewer.arrowSettings.thickness ? this.pdfViewer.arrowSettings.thickness : 1;
this.arrowOpacity = this.pdfViewer.arrowSettings.opacity ? this.pdfViewer.arrowSettings.opacity : 1;
this.arrowDashArray = this.pdfViewer.arrowSettings.borderDashArray ? this.pdfViewer.arrowSettings.borderDashArray : 0;
this.arrowStartHead = this.pdfViewer.arrowSettings.lineHeadStartStyle ? this.pdfViewer.arrowSettings.lineHeadStartStyle : 'Closed';
this.arrowEndHead = this.pdfViewer.arrowSettings.lineHeadEndStyle ? this.pdfViewer.arrowSettings.lineHeadEndStyle : 'Closed';
this.rectangleFillColor = this.pdfViewer.rectangleSettings.fillColor ? this.pdfViewer.rectangleSettings.fillColor : '#ffffff00';
this.rectangleStrokeColor = this.pdfViewer.rectangleSettings.strokeColor ? this.pdfViewer.rectangleSettings.strokeColor : '#ff0000';
this.rectangleThickness = this.pdfViewer.rectangleSettings.thickness ? this.pdfViewer.rectangleSettings.thickness : 1;
this.rectangleOpacity = this.pdfViewer.rectangleSettings.opacity ? this.pdfViewer.rectangleSettings.opacity : 1;
this.circleFillColor = this.pdfViewer.circleSettings.fillColor ? this.pdfViewer.circleSettings.fillColor : '#ffffff00';
this.circleStrokeColor = this.pdfViewer.circleSettings.strokeColor ? this.pdfViewer.circleSettings.strokeColor : '#ff0000';
this.circleThickness = this.pdfViewer.circleSettings.thickness ? this.pdfViewer.circleSettings.thickness : 1;
this.circleOpacity = this.pdfViewer.circleSettings.opacity ? this.pdfViewer.circleSettings.opacity : 1;
this.polygonFillColor = this.pdfViewer.polygonSettings.fillColor ? this.pdfViewer.polygonSettings.fillColor : '#ffffff00';
this.polygonStrokeColor = this.pdfViewer.polygonSettings.strokeColor ? this.pdfViewer.polygonSettings.strokeColor : '#ff0000';
this.polygonThickness = this.pdfViewer.polygonSettings.thickness ? this.pdfViewer.polygonSettings.thickness : 1;
this.polygonOpacity = this.pdfViewer.polygonSettings.opacity ? this.pdfViewer.polygonSettings.opacity : 1;
};
ShapeAnnotation.prototype.setShapeType = function (shape) {
var shapeType;
switch (shape) {
case 'Line':
shapeType = 'Line';
break;
case 'Circle':
shapeType = 'Ellipse';
break;
case 'Square':
shapeType = 'Rectangle';
break;
case 'Polyline':
shapeType = 'Line';
break;
case 'Arrow':
shapeType = 'LineWidthArrowHead';
break;
}
return shapeType;
};
ShapeAnnotation.prototype.getShapeType = function (shape) {
var shapeType;
switch (shape.shapeAnnotationType) {
case 'Line':
shapeType = 'Line';
break;
case 'Circle':
shapeType = 'Ellipse';
break;
case 'Square':
shapeType = 'Rectangle';
break;
case 'Polyline':
shapeType = 'Line';
break;
case 'Polygon':
shapeType = 'Polygon';
break;
}
if ((shape.shapeAnnotationType === 'Line' || shape.shapeAnnotationType === 'Polyline') && (shape.lineHeadStart !== 'None' || shape.lineHeadEnd !== 'None')) {
shapeType = 'LineWidthArrowHead';
}
return shapeType;
};
ShapeAnnotation.prototype.getShapeAnnotType = function (shape) {
var shapeType;
switch (shape) {
case 'Line':
case 'LineWidthArrowHead':
shapeType = 'Line';
break;
case 'Rectangle':
shapeType = 'Square';
break;
case 'Ellipse':
shapeType = 'Circle';
break;
case 'Polygon':
shapeType = 'Polygon';
break;
}
return shapeType;
};
ShapeAnnotation.prototype.modifyInCollection = function (property, pageNumber, annotationBase, toolMoved) {
if (!ej2_base_1.isNullOrUndefined(annotationBase.formFieldAnnotationType) && annotationBase.formFieldAnnotationType !== '') {
this.pdfViewer.annotationModule.isFormFieldShape = true;
}
else {
this.pdfViewer.annotationModule.isFormFieldShape = false;
}
if (toolMoved) {
this.pdfViewerBase.updateDocumentEditedProperty(true);
}
var currentAnnotObject = null;
if (annotationBase) {
if (property === 'bounds') {
this.pdfViewer.annotationModule.stickyNotesAnnotationModule.updateAnnotationModifiedDate(annotationBase, true);
}
}
var pageAnnotations = this.getAnnotations(pageNumber, null);
if (pageAnnotations != null && annotationBase) {
for (var i = 0; i < pageAnnotations.length; i++) {
if (annotationBase.id === pageAnnotations[parseInt(i.toString(), 10)].id) {
if (property === 'bounds') {
this.pdfViewerBase.isBounds =
this.pdfViewerBase.boundsCalculation(pageAnnotations[parseInt(i.toString(), 10)].bounds, annotationBase.wrapper.bounds);
if (this.pdfViewerBase.isBounds) {
if (pageAnnotations[parseInt(i.toString(), 10)].shapeAnnotationType === 'Line') {
pageAnnotations[parseInt(i.toString(), 10)].vertexPoints = annotationBase.vertexPoints;
pageAnnotations[parseInt(i.toString(), 10)].bounds =
{
left: annotationBase.bounds.x, top: annotationBase.bounds.y, width: annotationBase.bounds.width,
height: annotationBase.bounds.height, right: annotationBase.bounds.right,
bottom: annotationBase.bounds.bottom
};
}
else if (pageAnnotations[parseInt(i.toString(), 10)].shapeAnnotationType === 'Polygon') {
pageAnnotations[parseInt(i.toString(), 10)].vertexPoints = annotationBase.vertexPoints;
pageAnnotations[parseInt(i.toString(), 10)].bounds = {
left: annotationBase.bounds.x,
top: annotationBase.bounds.y, width: annotationBase.bounds.width,
height: annotationBase.bounds.height, right: annotationBase.bounds.right,
bottom: annotationBase.bounds.bottom
};
}
else {
pageAnnotations[parseInt(i.toString(), 10)].bounds = {
left: annotationBase.bounds.x,
top: annotationBase.bounds.y, width: annotationBase.bounds.width,
height: annotationBase.bounds.height, right: annotationBase.bounds.right,
bottom: annotationBase.bounds.bottom
};
}
}
if (pageAnnotations[parseInt(i.toString(), 10)].enableShapeLabel === true && annotationBase.wrapper) {
var labelTop = 0;
var labelLeft = 0;
var labelWidth = 0;
var labelHeight = 24.6;
var labelMaxWidth = 151;
if (annotationBase.wrapper.bounds.width) {
labelWidth = (annotationBase.wrapper.bounds.width / 2);
labelWidth = (labelWidth > 0 && labelWidth < labelMaxWidth) ? labelWidth : labelMaxWidth;
}
if (annotationBase.wrapper.bounds.left) {
labelLeft = (annotationBase.wrapper.bounds.left + (annotationBase.wrapper.bounds.width / 2)
- (labelWidth / 2));
}
if (annotationBase.wrapper.bounds.top) {
labelTop = (annotationBase.wrapper.bounds.top + (annotationBase.wrapper.bounds.height / 2) - 12.3);
}
pageAnnotations[parseInt(i.toString(), 10)].labelBounds =
{ left: labelLeft, top: labelTop, width: labelWidth, height: labelHeight, right: 0, bottom: 0 };
}
}
else if (property === 'fill') {
pageAnnotations[parseInt(i.toString(), 10)].fillColor = annotationBase.wrapper.children[0].style.fill;
}
else if (property === 'stroke') {
pageAnnotations[parseInt(i.toString(), 10)].strokeColor = annotationBase.wrapper.children[0].style.strokeColor;
}
else if (property === 'opacity') {
pageAnnotations[parseInt(i.toString(), 10)].opacity = annotationBase.wrapper.children[0].style.opacity;
}
else if (property === 'thickness') {
pageAnnotations[parseInt(i.toString(), 10)].thickness = annotationBase.wrapper.children[0].style.strokeWidth;
}
else if (property === 'dashArray') {
pageAnnotations[parseInt(i.toString(), 10)].borderDashArray =
annotationBase.wrapper.children[0].style.strokeDashArray;
pageAnnotations[parseInt(i.toString(), 10)].borderStyle = annotationBase.borderStyle;
}
else if (property === 'startArrow') {
pageAnnotations[parseInt(i.toString(), 10)].lineHeadStart =
this.pdfViewer.annotation.getArrowTypeForCollection(annotationBase.sourceDecoraterShapes);
}
else if (property === 'endArrow') {
pageAnnotations[parseInt(i.toString(), 10)].lineHeadEnd =
this.pdfViewer.annotation.getArrowTypeForCollection(annotationBase.taregetDecoraterShapes);
}
else if (property === 'notes') {
pageAnnotations[parseInt(i.toString(), 10)].note = annotationBase.notes;
}
else if (property === 'delete') {
currentAnnotObject = pageAnnotations.splice(i, 1)[0];
break;
}
else if (property === 'labelContent') {
pageAnnotations[parseInt(i.toString(), 10)].note = annotationBase.labelContent;
pageAnnotations[parseInt(i.toString(), 10)].labelContent = annotationBase.labelContent;
break;
}
else if (property === 'fontColor') {
pageAnnotations[parseInt(i.toString(), 10)].fontColor = annotationBase.fontColor;
}
else if (property === 'fontSize') {
pageAnnotations[parseInt(i.toString(), 10)].fontSize = annotationBase.fontSize;
}
if (this.pdfViewerBase.isBounds) {
pageAnnotations[parseInt(i.toString(), 10)].modifiedDate =
this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
}
this.pdfViewer.annotationModule.storeAnnotationCollections(pageAnnotations[parseInt(i.toString(), 10)], pageNumber);
}
}
this.manageAnnotations(pageAnnotations, pageNumber);
}
return currentAnnotObject;
};
ShapeAnnotation.prototype.addInCollection = function (pageNumber, annotationBase) {
var pageAnnotations = this.getAnnotations(pageNumber, null);
if (pageAnnotations) {
pageAnnotations.push(annotationBase);
}
this.manageAnnotations(pageAnnotations, pageNumber);
};
ShapeAnnotation.prototype.saveShapeAnnotations = function () {
var storeObject = window.sessionStorage.getItem(this.pdfViewerBase.documentId + '_annotations_shape');
if (this.pdfViewerBase.isStorageExceed) {
storeObject = this.pdfViewerBase.annotationStorage[this.pdfViewerBase.documentId + '_annotations_shape'];
}
var annotations = [];
for (var j = 0; j < this.pdfViewerBase.pageCount; j++) {
annotations[parseInt(j.toString(), 10)] = [];
}
if (storeObject && !this.pdfViewer.annotationSettings.skipDownload) {
var annotationCollection = JSON.parse(storeObject);
for (var i = 0; i < annotationCollection.length; i++) {
var newArray = [];
var pageAnnotationObject = annotationCollection[parseInt(i.toString(), 10)];
if (pageAnnotationObject) {
for (var z = 0; pageAnnotationObject.annotations.length > z; z++) {
if (!this.pdfViewerBase.checkFormFieldCollection(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].id)) {
this.pdfViewer.annotationModule.updateModifiedDate(pageAnnotationObject.annotations[parseInt(z.toString(), 10)]);
if (this.pdfViewerBase.isJsonExported) {
if (pageAnnotationObject.annotations[parseInt(z.toString(), 10)].isAnnotationRotated) {
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].bounds =
this.pdfViewer.annotation.getBounds(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].bounds, pageAnnotationObject.pageIndex);
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].vertexPoints =
this.pdfViewer.annotation.getVertexPoints(pageAnnotationObject.
annotations[parseInt(z.toString(), 10)].vertexPoints, pageAnnotationObject.pageIndex);
}
else {
var pageDetails = this.pdfViewerBase.pageSize[pageAnnotationObject.pageIndex];
if (pageDetails) {
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].annotationRotation =
pageDetails.rotation;
}
}
}
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].bounds =
JSON.stringify(this.pdfViewer.annotation.getBounds(pageAnnotationObject.
annotations[parseInt(z.toString(), 10)].bounds, pageAnnotationObject.pageIndex));
var strokeColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].strokeColor;
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].strokeColor =
JSON.stringify(this.getRgbCode(strokeColorString));
var fillColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].fillColor;
if (!ej2_base_1.isNullOrUndefined(fillColorString)) {
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].fillColor =
JSON.stringify(this.getRgbCode(fillColorString));
}
else {
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].fillColor = 'transparent';
}
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].vertexPoints =
JSON.stringify(this.pdfViewer.annotation.getVertexPoints(pageAnnotationObject.
annotations[parseInt(z.toString(), 10)].vertexPoints, pageAnnotationObject.pageIndex));
if (pageAnnotationObject.annotations[parseInt(z.toString(), 10)].rectangleDifference !== null) {
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].rectangleDifference =
JSON.stringify(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].rectangleDifference);
}
if (pageAnnotationObject.annotations[parseInt(z.toString(), 10)].enableShapeLabel === true) {
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelBounds =
JSON.stringify(this.pdfViewer.annotationModule.inputElementModule.
calculateLabelBounds(JSON.parse(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].bounds)));
var labelFillColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelFillColor;
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelFillColor =
JSON.stringify(this.getRgbCode(labelFillColorString));
var labelBorderColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelBorderColor;
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelBorderColor =
JSON.stringify(this.getRgbCode(labelBorderColorString));
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelSettings.fillColor = labelFillColorString;
var fontColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelSettings.fontColor;
pageAnnotationObject.annotations[parseInt(z.toString(), 10)].fontColor =
JSON.stringify(this.getRgbCode(fontColorString));
}
}
else {
pageAnnotationObject.annotations[parseInt(z.toString(), 10)] = '';
}
}
pageAnnotationObject.annotations = pageAnnotationObject.annotations.filter(function (item) { return item; });
newArray = pageAnnotationObject.annotations;
}
annotations[pageAnnotationObject.pageIndex] = newArray;
}
}
return JSON.stringify(annotations);
};
ShapeAnnotation.prototype.manageAnnotations = function (pageAnnotations, pageNumber) {
var storeObject = window.sessionStorage.getItem(this.pdfViewerBase.documentId + '_annotations_shape');
if (this.pdfViewerBase.isStorageExceed) {
storeObject = this.pdfViewerBase.annotationStorage[this.pdfViewerBase.documentId + '_annotations_shape'];
}
if (storeObject) {
var annotObject = JSON.parse(storeObject);
if (!this.pdfViewerBase.isStorageExceed) {
window.sessionStorage.removeItem(this.pdfViewerBase.documentId + '_annotations_shape');
}
var index = this.pdfViewer.annotationModule.getPageCollection(annotObject, pageNumber);
if (index != null && annotObject[parseInt(index.toString(), 10)]) {
annotObject[parseInt(index.toString(), 10)].annotations = pageAnnotations;
}
var annotationStringified = JSON.stringify(annotObject);
if (this.pdfViewerBase.isStorageExceed) {
this.pdfViewerBase.annotationStorage[this.pdfViewerBase.documentId + '_annotations_shape'] = annotationStringified;
}
else {
window.sessionStorage.setItem(this.pdfViewerBase.documentId + '_annotations_shape', annotationStringified);
}
}
};
ShapeAnnotation.prototype.createAnnotationObject = function (annotationModel) {
var bound;
var labelBound;
var annotationName = this.pdfViewer.annotation.createGUID();
if (!annotationModel.formFieldAnnotationType) {
var commentsDivid = this.pdfViewer.annotation.stickyNotesAnnotationModule.addComments('shape', (annotationModel.pageIndex + 1), annotationModel.shapeAnnotationType);
if (commentsDivid) {
document.getElementById(commentsDivid).id = annotationName;
}
}
annotationModel.annotName = annotationName;
if (annotationModel.wrapper.bounds) {
bound = {
left: annotationModel.wrapper.bounds.x, top: annotationModel.wrapper.bounds.y,
height: annotationModel.wrapper.bounds.height, width: annotationModel.wrapper.bounds.width,
right: annotationModel.wrapper.bounds.right, bottom: annotationModel.wrapper.bounds.bottom
};
labelBound = this.pdfViewer.annotationModule.inputElementModule.calculateLabelBounds(annotationModel.wrapper.bounds);
}
else {
bound = { left: 0, top: 0, height: 0, width: 0, right: 0, bottom: 0 };
labelBound = { left: 0, top: 0, height: 0, width: 0, right: 0, bottom: 0 };
}
if (annotationModel.subject === 'Line' && annotationModel.shapeAnnotationType === 'Polygon') {
annotationModel.author = this.pdfViewer.annotationModule.updateAnnotationAuthor('shape', 'Polygon');
}
else {
annotationModel.author = annotationModel && annotationModel.author != 'Guest' ? annotationModel.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('shape', annotationModel.subject);
}
this.pdfViewer.annotation.stickyNotesAnnotationModule.addTextToComments(annotationName, annotationModel.notes);
var borderDashArray = parseInt(annotationModel.borderDashArray, 10);
borderDashArray = isNaN(borderDashArray) ? 0 : borderDashArray;
var annotationSettings = this.pdfViewer.annotationModule.findAnnotationSettings(annotationModel, true);
annotationModel.isPrint = annotationSettings.isPrint;
var setting = this.pdfViewer.shapeLabelSettings;
var labelSettings = { borderColor: annotationModel.strokeColor, fillColor: annotationModel.fillColor,
fontColor: annotationModel.fontColor, fontSize: annotationModel.fontSize,
labelContent: annotationModel.labelContent, labelHeight: setting.labelHeight,
labelWidth: setting.labelMaxWidth, opacity: annotationModel.opacity
};
return {
id: annotationModel.id, shapeAnnotationType: this.getShapeAnnotType(annotationModel.shapeAnnotationType),
author: annotationModel.author, allowedInteractions: this.pdfViewer.annotationModule.
updateAnnotationAllowedInteractions(annotationModel), subject: annotationModel.subject,
note: annotationModel.notes,
strokeColor: annotationModel.strokeColor, annotName: annotationName, comments: [], review: { state: '', stateModel: '', modifiedDate: this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime(), author: annotationModel.author },
fillColor: annotationModel.fillColor, opacity: annotationModel.opacity,
thickness: annotationModel.thickness, pageNumber: annotationModel.pageIndex,
borderStyle: annotationModel.borderStyle, borderDashArray: borderDashArray,
bounds: bound, modifiedDate: this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime(),
rotateAngle: 'RotateAngle' + annotationModel.rotateAngle, isCloudShape: annotationModel.isCloudShape, cloudIntensity: annotationModel.cloudIntensity,
vertexPoints: annotationModel.vertexPoints, lineHeadStart: this.pdfViewer.annotation.getArrowTypeForCollection(annotationModel.sourceDecoraterShapes),
lineHeadEnd: this.pdfViewer.annotation.getArrowTypeForCollection(annotationModel.taregetDecoraterShapes),
rectangleDifference: [], isLocked: annotationSettings.isLock,
labelContent: annotationModel.labelContent, enableShapeLabel: annotationModel.enableShapeLabel,
labelFillColor: annotationModel.labelFillColor,
fontColor: annotationModel.fontColor, labelBorderColor: annotationModel.labelBorderColor, fontSize: annotationModel.fontSize,
labelBounds: labelBound, annotationSelectorSettings: this.getSelector(annotationModel.shapeAnnotationType, annotationModel.subject), labelSettings: labelSettings,
annotationSettings: annotationSettings,
customData: this.pdfViewer.annotation.getShapeData(annotationModel.shapeAnnotationType, annotationModel.subject),
isPrint: annotationModel.isPrint, isCommentLock: annotationModel.isCommentLock, isAnnotationRotated: false
};
};
ShapeAnnotation.prototype.getSelector = function (type, subject) {
var selector = this.pdfViewer.annotationSelectorSettings;
if (type === 'Line' && subject !== 'Arrow' && this.pdfViewer.lineSettings.annotationSelectorSettings) {
selector = this.pdfViewer.lineSettings.annotationSelectorSettings;
}
else if ((type === 'LineWidthArrowHead' || subject === 'Arrow') && this.pdfViewer.lineSettings.annotationSelectorSettings) {
selector = this.pdfViewer.arrowSettings.annotationSelectorSettings;
}
else if ((type === 'Rectangle' || type === 'Square') && this.pdfViewer.rectangleSettings.annotationSelectorSettings) {
selector = this.pdfViewer.rectangleSettings.annotationSelectorSettings;
}
else if ((type === 'Ellipse' || type === 'Circle') && this.pdfViewer.circleSettings.annotationSelectorSettings) {
selector = this.pdfViewer.circleSettings.annotationSelectorSettings;
}
else if (type === 'Polygon' && this.pdfViewer.polygonSettings.annotationSelectorSettings) {
selector = this.pdfViewer.polygonSettings.annotationSelectorSettings;
}
return selector;
};
ShapeAnnotation.prototype.getAnnotations = function (pageIndex, shapeAnnotations) {
var annotationCollection;
var storeObject = window.sessionStorage.getItem(this.pdfViewerBase.documentId + '_annotations_shape');
if (this.pdfViewerBase.isStorageExceed) {
storeObject = this.pdfViewerBase.annotationStorage[this.pdfViewerBase.documentId + '_annotations_shape'];
}
if (storeObject) {
var annotObject = JSON.parse(storeObject);
var index = this.pdfViewer.annotationModule.getPageCollection(annotObject, pageIndex);
if (index != null && annotObject[parseInt(index.toString(), 10)]) {
annotationCollection = annotObject[parseInt(index.toString(), 10)].annotations;
}
else {
annotationCollection = shapeAnnotations;
}
}
else {
annotationCollection = shapeAnnotations;
}
return annotationCollection;
};
ShapeAnnotation.prototype.getRgbCode = function (colorString) {
if (!colorString.match(/#([a-z0-9]+)/gi) && !colorString.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/)) {
colorString = this.pdfViewer.annotationModule.nameToHash(colorString);
}
var stringArray = colorString.split(',');
if (ej2_base_1.isNullOrUndefined(stringArray[1])) {
colorString = this.pdfViewer.annotationModule.getValue(colorString, 'rgba');
stringArray = colorString.split(',');
}
var r = parseInt(stringArray[0].split('(')[1], 10);
var g = parseInt(stringArray[1], 10);
var b = parseInt(stringArray[2], 10);
var a = parseFloat(stringArray[3]);
return { r: r, g: g, b: b, a: a };
};
ShapeAnnotation.prototype.saveImportedShapeAnnotations = function (annotation, pageNumber) {
var annotationObject = null;
var vertexPoints = null;
annotation.Author = this.pdfViewer.annotationModule.updateAnnotationAuthor('shape', annotation.Subject);
if (annotation.VertexPoints) {
vertexPoints = [];
for (var j = 0; j < annotation.VertexPoints.length; j++) {
var point = { x: annotation.VertexPoints[parseInt(j.toString(), 10)].X,
y: annotation.VertexPoints[parseInt(j.toString(), 10)].Y };
vertexPoints.push(point);
}
}
if (annotation.Bounds && annotation.EnableShapeLabel === true) {
annotation.LabelBounds = this.pdfViewer.annotationModule.
inputElementModule.calculateLabelBoundsFromLoadedDocument(annotation.Bounds);
annotation.LabelBorderColor = annotation.LabelBorderColor ? annotation.LabelBorderColor : annotation.StrokeColor;
annotation.FontColor = annotation.FontColor ? annotation.FontColor : annotation.StrokeColor;
annotation.LabelFillColor = annotation.LabelFillColor ? annotation.LabelFillColor : annotation.FillColor;
annotation.FontSize = annotation.FontSize ? annotation.FontSize : 16;
annotation.LabelSettings = annotation.LabelSettings ? annotation.LabelSettings : this.pdfViewer.shapeLabelSettings;
}
annotation.AnnotationSettings = annotation.AnnotationSettings ?
annotation.AnnotationSettings : this.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
annotation.allowedInteractions = annotation.AllowedInteractions ?
annotation.AllowedInteractions : this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
annotationObject = {
id: 'shape', shapeAnnotationType: annotation.ShapeAnnotationType, author: annotation.Author, allowedInteractions: annotation.allowedInteractions, modifiedDate: annotation.ModifiedDate, subject: annotation.Subject, pageNumber: pageNumber,
note: annotation.Note, strokeColor: annotation.StrokeColor, fillColor: annotation.FillColor,
opacity: annotation.Opacity, thickness: annotation.Thickness, rectangleDifference: annotation.RectangleDifference,
borderStyle: annotation.BorderStyle, borderDashArray: annotation.BorderDashArray,
rotateAngle: annotation.RotateAngle, isCloudShape: annotation.IsCloudShape,
cloudIntensity: annotation.CloudIntensity, vertexPoints: vertexPoints, lineHeadStart: annotation.LineHeadStart,
lineHeadEnd: annotation.LineHeadEnd, isLocked: annotation.IsLocked,
comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
review: { state: annotation.State, stateModel: annotation.StateModel, modifiedDate: annotation.ModifiedDate,
author: annotation.Author }, annotName: annotation.AnnotName,
bounds: { left: annotation.Bounds.X, top: annotation.Bounds.Y, width: annotation.Bounds.Width,
height: annotation.Bounds.Height, right: annotation.Bounds.Right, bottom: annotation.Bounds.Bottom },
labelContent: annotation.LabelContent, enableShapeLabel: annotation.EnableShapeLabel, labelFillColor: annotation.LabelFillColor,
labelBorderColor: annotation.LabelBorderColor, fontColor: annotation.FontColor, fontSize: annotation.FontSize,
labelBounds: annotation.LabelBounds, annotationSelectorSettings: this.getSettings(annotation),
labelSettings: annotation.LabelSettings, annotationSettings: annotation.AnnotationSettings,
customData: this.pdfViewer.annotation.getCustomData(annotation), isPrint: annotation.IsPrint,
isCommentLock: annotation.IsCommentLock, isAnnotationRotated: false
};
this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotationObject, '_annotations_shape');
};
ShapeAnnotation.prototype.updateShapeAnnotationCollections = function (annotation, pageNumber) {
var annotationObject = null;
var vertexPoints = null;
if (annotation.VertexPoints) {
vertexPoints = [];
for (var j = 0; j < annotation.VertexPoints.length; j++) {
var point = { x: annotation.VertexPoints[parseInt(j.toString(), 10)].X,
y: annotation.VertexPoints[parseInt(j.toString(), 10)].Y };
vertexPoints.push(point);
}
}
if (annotation.Bounds && annotation.EnableShapeLabel === true) {
annotation.LabelBounds =
this.pdfViewer.annotationModule.inputElementModule.calculateLabelBoundsFromLoadedDocument(annotation.Bounds);
annotation.LabelBorderColor = annotation.LabelBorderColor ? annotation.LabelBorderColor : annotation.StrokeColor;
annotation.FontColor = annotation.FontColor ? annotation.FontColor : annotation.StrokeColor;
annotation.LabelFillColor = annotation.LabelFillColor ? annotation.LabelFillColor : annotation.FillColor;
annotation.FontSize = annotation.FontSize ? annotation.FontSize : 16;
var settings = this.pdfViewer.shapeLabelSettings;
var labelSettings = { borderColor: annotation.StrokeColor, fillColor: annotation.FillColor,
fontColor: annotation.FontColor, fontSize: annotation.FontSize, labelContent: annotation.LabelContent,
labelHeight: settings.labelHeight, labelWidth: settings.labelWidth, opacity: annotation.Opacity
};
annotation.LabelSettings = annotation.LabelSettings ? annotation.LabelSettings : labelSettings;
}
annotation.AnnotationSettings = annotation.AnnotationSettings ? annotation.AnnotationSettings :
this.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
if (annotation.IsLocked) {
annotation.AnnotationSettings.isLock = annotation.IsLocked;
}
annotation.allowedInteractions = annotation.AllowedInteractions ? annotation.AllowedInteractions :
this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
annotationObject = {
id: 'shape', shapeAnnotationType: annotation.ShapeAnnotationType, author: annotation.Author, allowedInteractions: annotation.allowedInteractions, modifiedDate: annotation.ModifiedDate, subject: annotation.Subject,
note: annotation.Note, strokeColor: annotation.StrokeColor, fillColor: annotation.FillColor, opacity: annotation.Opacity,
thickness: annotation.Thickness, rectangleDifference: annotation.RectangleDifference,
borderStyle: annotation.BorderStyle, borderDashArray: annotation.BorderDashArray, rotateAngle: annotation.RotateAngle,
isCloudShape: annotation.IsCloudShape, cloudIntensity: annotation.CloudIntensity, vertexPoints: vertexPoints,
lineHeadStart: annotation.LineHeadStart, lineHeadEnd: annotation.LineHeadEnd, isLocked: annotation.IsLocked,
comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
review: { state: annotation.State, stateModel: annotation.StateModel, modifiedDate: annotation.ModifiedDate,
author: annotation.Author }, annotationId: annotation.AnnotName,
bounds: { left: annotation.Bounds.X, top: annotation.Bounds.Y, width: annotation.Bounds.Width,
height: annotation.Bounds.Height, right: annotation.Bounds.Right, bottom: annotation.Bounds.Bottom },
labelContent: annotation.LabelContent, enableShapeLabel: annotation.EnableShapeLabel, labelFillColor: annotation.LabelFillColor,
labelBorderColor: annotation.LabelBorderColor, fontColor: annotation.FontColor, fontSize: annotation.FontSize,
labelBounds: annotation.LabelBounds, pageNumber: pageNumber, labelSettings: annotation.LabelSettings,
annotationSettings: annotation.AnnotationSettings, customData: this.pdfViewer.annotation.getCustomData(annotation),
isPrint: annotation.IsPrint, isCommentLock: annotation.IsCommentLock
};
return annotationObject;
};
ShapeAnnotation.prototype.updateAddAnnotationDetails = function (annotationType, annotationObject, offset) {
if (!annotationObject) {
annotationObject = { offset: { x: 10, y: 10 }, pageNumber: 0, width: undefined, height: undefined };
offset = annotationObject.offset;
}
else if (!annotationObject.offset) {
offset = { x: 10, y: 10 };
}
else {
offset = annotationObject.offset;
}
var annotationSelectorSettings = null;
var allowedInteractions = null;
var annotationSettings = null;
var shapeAnnotationType = '';
var isArrow = false;
var vertexPoints = null;
var currentDateString = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
var annotationName = this.pdfViewer.annotation.createGUID();
if (annotationType === 'Line') {
annotationSelectorSettings = this.pdfViewer.lineSettings.annotationSelectorSettings;
this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.lineSettings);
annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('shape', annotationType);
allowedInteractions = this.pdfViewer.lineSettings.allowedInteractions ?
this.pdfViewer.lineSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
shapeAnnotationType = 'Line';
if (annotationObject.vertexPoints) {
vertexPoints = annotationObject.vertexPoints;
}
else {
vertexPoints = [{ x: offset.x, y: offset.y }, { x: offset.x + 100, y: offset.y }];
}
annotationObject.width = annotationObject.width ? annotationObject.width : 1;
annotationObject.height = annotationObject.height ? annotationObject.height : 1;
}
else if (annotationType === 'Arrow') {
annotationSelectorSettings = this.pdfViewer.arrowSettings.annotationSelectorSettings;
this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.arrowSettings);
annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('shape', annotationType);
allowedInteractions = this.pdfViewer.arrowSettings.allowedInteractions ?
this.pdfViewer.arrowSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
shapeAnnotationType = 'Line';
isArrow = true;
if (annotationObject.vertexPoints) {
vertexPoints = annotationObject.vertexPoints;
}
else {
vertexPoints = [{ x: offset.x, y: offset.y }, { x: offset.x + 100, y: offset.y }];
}
annotationObject.width = annotationObject.width ? annotationObject.width : 1;
annotationObject.height = annotationObject.height ? annotationObject.height : 1;
}
else if (annotationType === 'Rectangle') {
annotationSelectorSettings = this.pdfViewer.rectangleSettings.annotationSelectorSettings;
this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.rectangleSettings);
annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('shape', annotationType);
allowedInteractions = this.pdfViewer.rectangleSettings.allowedInteractions ?
this.pdfViewer.rectangleSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
shapeAnnotationType = 'Square';
annotationObject.width = annotationObject.width ? annotationObject.width : 150;
annotationObject.height = annotationObject.height ? annotationObject.height : 75;
}
else if (annotationType === 'Circle') {
annotationSelectorSettings = this.pdfViewer.circleSettings.annotationSelectorSettings;
this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.circleSettings);
annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('shape', annotationType);
allowedInteractions = this.pdfViewer.circleSettings.allowedInteractions ?
this.pdfViewer.circleSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
shapeAnnotationType = 'Circle';
annotationObject.width = annotationObject.width ? annotationObject.width : 100;
annotationObject.height = annotationObject.height ? annotationObject.height : 90;
}
else if (annotationType === 'Polygon') {
annotationSelectorSettings = this.pdfViewer.polygonSettings.annotationSelectorSettings;
this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.polygonSettings);
annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('shape', annotationType);
allowedInteractions = this.pdfViewer.polygonSettings.allowedInteractions ?
this.pdfViewer.polygonSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
shapeAnnotationType = 'Polygon';
if (annotationObject.vertexPoints) {
vertexPoints = annotationObject.vertexPoints;
}
else {
vertexPoints = [{ x: offset.x, y: offset.y }, { x: offset.x + 42, y: offset.y - 29 },
{ x: offset.x + 89, y: offset.y - 1 }, { x: offset.x + 78, y: offset.y + 42 },
{ x: offset.x + 11, y: offset.y + 42 }, { x: offset.x, y: offset.y }];
}
annotationObject.width = annotationObject.width ? annotationObject.width : 1;
annotationObject.height = annotationObject.height ? annotationObject.height : 1;
}
annotationSettings.isLock = annotationObject.isLock ? annotationObject.isLock : annotationSettings.isLock;
annotationSettings.minHeight = annotationObject.minHeight ? annotationObject.minHeight : annotationSettings.minHeight;
annotationSettings.minWidth = annotationObject.minWidth ? annotationObject.minWidth : annotationSettings.minWidth;
annotationSettings.maxWidth = annotationObject.maxWidth ? annotationObject.maxWidth : annotationSettings.maxWidth;
annotationSettings.maxHeight = annotationObject.maxHeight ? annotationObject.maxHeight : annotationSettings.maxHeight;
if (vertexPoints) {
vertexPoints = this.pdfViewer.annotation.getVertexPointsXY(vertexPoints);
}
var shapeAnnotation = [];
var shape = {
AllowedInteractions: annotationObject.allowedInteractions ? annotationObject.allowedInteractions : allowedInteractions,
AnnotName: annotationName,
AnnotType: 'shape',
AnnotationSelectorSettings: annotationObject.annotationSelectorSettings ?
annotationObject.annotationSelectorSettings : annotationSelectorSettings,
AnnotationSettings: annotationSettings,
Author: annotationObject.author ? annotationObject.author : 'Guest',
BorderDashArray: annotationObject.borderDashArray ? annotationObject.borderDashArray : 0,
BorderStyle: 'Solid',
Bounds: { X: offset.x, Y: offset.y, Width: annotationObject.width,
Height: annotationObject.height, Left: offset.x, Top: offset.y,
Location: { X: offset.x, Y: offset.y }, Size: { Height: annotationObject.height,
IsEmpty: false, Width: annotationObject.width } },
CloudIntensity: 0,
Comments: null,
CustomData: annotationObject.customData ? annotationObject.customData : null,
CreatedDate: currentDateString,
EnableShapeLabel: false,
ExistingCustomData: null,
FillColor: annotationObject.fillColor ? annotationObject.fillColor : '#ffffff00',
FontColor: null,
FontSize: 0,
IsCloudShape: false,
IsCommentLock: false,
IsLocked: annotationObject.isLock ? annotationObject.isLock : false,
IsPrint: annotationObject.isPrint ? annotationObject.isPrint : true,
LabelBorderColor: null,
LabelBounds: { X: 0, Y: 0, Width: 0, Height: 0 },
LabelContent: null,
LabelFillColor: null,
LabelSettings: null,
LineHeadEnd: annotationObject.lineHeadStartStyle ? annotationObject.lineHeadStartStyle : isArrow ? 'ClosedArrow' : 'None',
LineHeadStart: annotationObject.lineHeadEndStyle ? annotationObject.lineHeadEndStyle : isArrow ? 'ClosedArrow' : 'None',
ModifiedDate: '',
Note: '',
Opacity: annotationObject.opacity ? annotationObject.opacity : 1,
RectangleDifference: null,
RotateAngle: 'RotateAngle0',
ShapeAnnotationType: shapeAnnotationType,
State: '',
StateModel: '',
StrokeColor: annotationObject.strokeColor ? annotationObject.strokeColor : '#ff0000',
Subject: annotationObject.subject ? annotationObject.subject : annotationType.toString(),
Thickness: annotationObject.thickness ? annotationObject.thickness : 1,
VertexPoints: vertexPoints
};
shapeAnnotation[0] = shape;
return { shapeAnnotation: shapeAnnotation };
};
return ShapeAnnotation;
}());
exports.ShapeAnnotation = ShapeAnnotation;
});
|