nuxeo-development-framework 0.8.0 → 0.8.1

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.
@@ -19243,7 +19243,8 @@
19243
19243
  this.events = new i0.EventEmitter();
19244
19244
  this.SignatureEvent = new i0.EventEmitter(); // used to export signature to outside
19245
19245
  this.firstTimeLoad = true; //flage to control importing signatures in the first time load only
19246
- this.firstSignatureLoad = true;
19246
+ this.firstSignatureLoad = true; // flage to pass first load of imported signatures without emitting the event
19247
+ this.newSignCreation = false; // flage to indicate signature creation is created or choosed from stored ones
19247
19248
  }
19248
19249
  PdftronComponent.prototype.ngOnInit = function () {
19249
19250
  return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -19280,7 +19281,7 @@
19280
19281
  this.addPrintButton();
19281
19282
  this.addDownloadButton();
19282
19283
  this.importSignature();
19283
- // this.exportingSignature();
19284
+ this.exportingSignature();
19284
19285
  this.deleteAnnotation();
19285
19286
  this.exportingSavedSignature();
19286
19287
  this.loadDocument();
@@ -19302,17 +19303,6 @@
19302
19303
  }
19303
19304
  });
19304
19305
  };
19305
- PdftronComponent.prototype.exportingSignature = function () {
19306
- var _this = this;
19307
- var documentViewer = this.webViewerInstance.docViewer;
19308
- var SignatureCreateTool = documentViewer.getTool('AnnotationCreateSignature');
19309
- SignatureCreateTool.on('annotationAdded', function (annotation) {
19310
- if (annotation && _this.userSignatures.length < 4) {
19311
- _this.extractAnnotationSignature(annotation, documentViewer);
19312
- }
19313
- });
19314
- ;
19315
- };
19316
19306
  PdftronComponent.prototype.exportingSavedSignature = function () {
19317
19307
  var _this = this;
19318
19308
  var documentViewer = this.webViewerInstance.docViewer;
@@ -19320,22 +19310,40 @@
19320
19310
  SignatureCreateTool.on('signatureSaved', function (annotation) {
19321
19311
  if (!_this.firstSignatureLoad) {
19322
19312
  console.log('signature saved trigered');
19323
- // this.extractAnnotationSignature(annotation, documentViewer);
19324
- _this.SignatureEvent.emit({ data: annotation[0]['image']['currentSrc'], eventName: 'export' });
19313
+ _this.newSignCreation = true;
19325
19314
  }
19326
19315
  _this.firstSignatureLoad = false;
19327
19316
  });
19328
19317
  ;
19329
19318
  };
19330
- PdftronComponent.prototype.deleteAnnotation = function () {
19319
+ PdftronComponent.prototype.exportingSignature = function () {
19331
19320
  var _this = this;
19332
19321
  var documentViewer = this.webViewerInstance.docViewer;
19333
19322
  var SignatureCreateTool = documentViewer.getTool('AnnotationCreateSignature');
19334
- SignatureCreateTool.on('signatureDeleted', function (annotation, index) {
19335
- console.log('there were annotations deleted');
19336
- _this.userSignatures.splice(index, 1);
19337
- _this.SignatureEvent.emit({ data: { signature: annotation, index: index }, eventName: 'delete' });
19323
+ SignatureCreateTool.on('annotationAdded', function (annotation) {
19324
+ if (annotation && _this.newSignCreation) {
19325
+ _this.newSignCreation = false;
19326
+ _this.extractAnotation(annotation, documentViewer);
19327
+ console.log(annotation);
19328
+ }
19338
19329
  });
19330
+ ;
19331
+ };
19332
+ PdftronComponent.prototype.extractAnotation = function (annotation, documentViewer) {
19333
+ if (annotation['image']) {
19334
+ // convert base64 signature into file and emit it to out side
19335
+ var base64Img = annotation['image']['currentSrc'];
19336
+ var arr = base64Img.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
19337
+ while (n--) {
19338
+ u8arr[n] = bstr.charCodeAt(n);
19339
+ }
19340
+ var name = mime.replace('/', '.');
19341
+ var myFile = new File([u8arr], 'mySignature.png', { type: mime });
19342
+ this.SignatureEvent.emit({ data: myFile, eventName: 'export' });
19343
+ }
19344
+ else {
19345
+ this.extractAnnotationSignature(annotation, documentViewer);
19346
+ }
19339
19347
  };
19340
19348
  PdftronComponent.prototype.extractAnnotationSignature = function (annotation, docViewer) {
19341
19349
  return __awaiter(this, void 0, void 0, function () {
@@ -19343,24 +19351,36 @@
19343
19351
  var _this = this;
19344
19352
  return __generator(this, function (_a) {
19345
19353
  canvas = document.createElement('canvas');
19346
- pageMatrix = docViewer.getDocument().getPageMatrix(annotation[0].PageNumber ? annotation[0].PageNumber : 1);
19354
+ pageMatrix = docViewer.getDocument().getPageMatrix(annotation.PageNumber);
19347
19355
  // Set the height & width of the canvas to match the annotation
19348
- canvas.height = annotation[0].Height;
19349
- canvas.width = annotation[0].Width;
19356
+ canvas.height = annotation.Height;
19357
+ canvas.width = annotation.Width;
19350
19358
  ctx = canvas.getContext('2d');
19351
19359
  // Translate the Annotation to the top Top Left Corner of the Canvas ie (0, 0)
19352
- ctx.translate(-annotation[0].X, -annotation[0].Y);
19360
+ ctx.translate(-annotation.X, -annotation.Y);
19353
19361
  // Draw the Annotation onto the Canvas
19354
19362
  annotation.draw(ctx, pageMatrix);
19355
19363
  // Convert the Canvas to a Blob Object for Upload
19356
19364
  canvas.toBlob(function (blob) {
19357
19365
  // Call your Blob Storage Upload Function
19358
- _this.SignatureEvent.emit({ data: blob, eventName: 'export' });
19366
+ var name = blob.type.replace('/', '.');
19367
+ var myFile = new File([blob], name);
19368
+ _this.SignatureEvent.emit({ data: myFile, eventName: 'export' });
19359
19369
  });
19360
19370
  return [2 /*return*/];
19361
19371
  });
19362
19372
  });
19363
19373
  };
19374
+ PdftronComponent.prototype.deleteAnnotation = function () {
19375
+ var _this = this;
19376
+ var documentViewer = this.webViewerInstance.docViewer;
19377
+ var SignatureCreateTool = documentViewer.getTool('AnnotationCreateSignature');
19378
+ SignatureCreateTool.on('signatureDeleted', function (annotation, index) {
19379
+ console.log('there were annotations deleted');
19380
+ _this.userSignatures.splice(index, 1);
19381
+ _this.SignatureEvent.emit({ data: { signature: annotation, index: index }, eventName: 'delete' });
19382
+ });
19383
+ };
19364
19384
  PdftronComponent.prototype.addDownloadButton = function () {
19365
19385
  var _this = this;
19366
19386
  this.webViewerInstance.setHeaderItems(function (header) {
@@ -19501,14 +19521,17 @@
19501
19521
  ]);
19502
19522
  var group = void 0;
19503
19523
  if (this.editingType === 'signDoc') {
19504
- group = "toolbarGroup-Insert";
19524
+ this.webViewerInstance.enableElements([
19525
+ 'toolbarGroup-Insert'
19526
+ ]);
19505
19527
  }
19506
19528
  else if (this.editingType === 'annotate') {
19507
- group = "toolbarGroup-Annotate";
19529
+ this.webViewerInstance.enableElements([
19530
+ 'toolbarGroup-Shapes',
19531
+ 'toolbarGroup-Edit',
19532
+ 'toolbarGroup-Annotate',
19533
+ ]);
19508
19534
  }
19509
- this.webViewerInstance.enableElements([
19510
- group
19511
- ]);
19512
19535
  }
19513
19536
  else {
19514
19537
  this.webViewerInstance.enableElements([