首页 > 解决方案 > 将多个PDF文件合并为一个角度8

问题描述

我正在尝试在角度 8 中组合多个 pdf。通过上传按钮选择多个文件时,现在我在文件列表或数组中拥有了选定的 pdf。在将合并的 pdf 文件发送到上传 API 发布方法之前,我想将 pdf 合并为具有某个名称的单个 PDF 文档。

html代码:

 <input #fileInput type="file" ngf-select ng-model="new_files" accept=".pdf" multiple
                        (change)="onFileChange($event)">
                    <span class="btn btn-primary"><i class="fas fa-upload"></i> Upload PDF(s)
                    </span>

.ts 代码

public onFileChange(event) {  
let files = event.target.files;          
if (event.target.files && event.target.files.length) {
  const [file] = event.target.files;
  const fileListAsArray = Array.from(event.target.files)
  console.log(fileListAsArray);     

  this.fileService.upload(file).subscribe(
    (result: any) => {         
     .loading = false;
      this.isSuccess = true;
      this.successMessage = 'uploaded successfully !!.';
    },
    (error) => {
      this.loading = false;
      console.error(error);
    });
}

}

如何将以下结果发送到 ASP.net core post web api 调用,以便我可以在服务器端处理 pdf 合并功能。

文件列表:

(2) [File, File] [0: File {name: "Test.pdf", lastModified: 1606692735736, lastModifiedDate: Mon Nov 30 2020 10:32:15 GMT+1100, webkitRelativePath: "", size: 30420, ... }]

[1: 文件 {name: "test1.pdf", lastModified: 1604532330799, lastModifiedDate: Thu Nov 05 2020 10:25:30 GMT+1100, webkitRelativePath: "", size: 1417916, ...}]

标签: javascriptarraysangularasp.net-core-webapidata-conversion

解决方案


推荐阅读