我正在尝试为浏览器中当前呈现的页面制作 pdf。我使用 Angular 11 和 nodejs 作为服务器。一切正常,但是当我检查我的 pdf 目录时,我发现它生成了 3 个 pdf,然后我调试了我的代码,发现我的 API 调用了 3 次,但我只得到了一次响应。
component.ts
failed to execute ['dot', '-Kdot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH
service.ts
downlode(id: any) {
this.spinner = true;
this.pdf_downlode.downlode_pdf(id).subscribe((res: Blob) => {
console.log('res');
saveAs(res, 'report.pdf');
this.spinner = false;
});
}
api.js
get_record(id: any) {
return this.http.get(`${environment.convert}/${id}`);
}
在我的控制台中,我得到了这样的输出顺序:-
<块引用>下载api调用 响应发送, 下载api调用 响应发送, 下载api调用 响应发送