从签名板Ionic 3发送签名

时间:2017-07-13 12:24:34

标签: typescript ionic-framework ionic3

我想通过电子邮件发送我的签名,但我没有设法做到这一点

这是我的代码:

import { Component, ViewChild } from '@angular/core';
import { NavController} from 'ionic-angular';
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
import { EmailComposer } from '@ionic-native/email-composer';

@Component({
  selector: 'page-envoie',
  templateUrl: 'envoie.html',
  providers: [SignaturePad, EmailComposer]
})
export class EnvoiePage {

  @ViewChild(SignaturePad) public signaturePad: SignaturePad;

  public signatureImage : string;
  public signaturePadOptions: Object = {
        'minWidth': 2,
        'canvasWidth': 340,
        'canvasHeight': 200 };

        public Cancel: string;

  constructor(public navCtrl: NavController, private emailComposer: EmailComposer){

    this.signatureImage = this.signaturePad.toDataURL();

    this.Cancel = this.signatureImage;

  }

   drawComplete() {

    this.signatureImage = this.signaturePad.toDataURL();
    this.emailComposer.open({
      to:      'lol@me.com',
      attachments: [this.signatureImage],
      subject: 'Avis de passage',
      body:    'test',
      isHtml: true
    });

  }

  drawClear() {
    this.signaturePad.clear();
  }

}
你能帮帮我吗?我输了,当我按下按钮时,电子邮件被打开,有我的文字而不是图像

它是插件签名板和emailcomposer

1 个答案:

答案 0 :(得分:0)

有点晚了,但是我能够使它工作。

签名中的data:image/png;base64,需要使用

删除
  this.signatureImage = this.signaturePad.toDataURL().replace('data:image/png;base64,', '');

现在只需像这样替换附件:

drawComplete() {

    this.signatureImage = this.signaturePad.toDataURL().replace('data:image/png;base64,', '');
    
    this.emailComposer.open({
      to:      'lol@me.com',
      attachments: ['base64:icon.png//'+this.signatureImage],
      subject: 'Avis de passage',
      body:    'test',
      isHtml: true
    });

  }