从签名板Ionic 3发送签名 [英] Send signature from signature pad Ionic 3

查看:70
本文介绍了从签名板Ionic 3发送签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过电子邮件发送我的签名,但我没有做到

I want to send my signature in an email but I don't manage to do it

这是我的代码:

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();
  }

}

你能帮我吗?我迷路了,当我按下按钮时,打开的电子邮件中有我的文字,但没有图片

Can you help me? I'm lost, when I press the button, the email is opened there is my text but not the image

这是插件签名板和emailcomposer

It's the plugin signature pad and the emailcomposer

推荐答案

有点晚了,但是我能够使它正常工作.

A little late, but I was able to get this working.

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

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

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

Now just replace the attachment like so:

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
    });

  }

这篇关于从签名板Ionic 3发送签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆