首页 > 解决方案 > Html to Pdf Format Angular

问题描述

Hello i want to convert from html to pdf format and send it as a file to my backend, so i can save it in my server, i tried using jspdf but its not working

SendMail() {
  var doc = new jspdf();
doc.fromHTML('<h1>Hello World!</h1>', 20, 20);

var blob = new Blob([doc.output("blob")], { type: "application/pdf" });

let lruta = 'report/' + 'test';

this.uploaderService.uploadfile(blob, lruta).subscribe(
  response => {
    this.fetcher = response;
    this.blockUI.stop();
  }, error => {
    this.blockUI.stop();
  }
);
}

This is my service UploadFile

uploadfile(cabecera, ruta) {
    const formData = new FormData();  
    formData.append('file', cabecera[0]);
    formData.append('ruta', ruta);
    return this._http.post(this.apiUrl + this.serviceUrl + 'gestion/uploadrevision', formData);
  }

When i replace blob with this.file in my this.uploaderService.uploadfile it works, but i dont want to download and upload my file

file: any;
  onFileChange(event) {
    this.file = event.target.files;
  }

标签: htmlangularjspdf

解决方案


推荐阅读