我正在为我的角度应用程序进行PDF查看和下载,在这里我想在一个部分上下载pdf,但是在此之前,我想在我的角度模板上显示pdf,我被困在那儿,我怎么能为此,请先寻求帮助,谢谢。 这是我正在下载的代码,如何更改此代码,以便甚至可以在UI上看到它。
onSubmitPolicyPDF() {
let formValuePolicyPDF: any = {
cst_policy_number: this.submitprop.data.policy_number,
}
this.policyService.policyPDF(formValuePolicyPDF)
.pipe()
.subscribe(poldownloaddata => {
this.poldownloaddata = poldownloaddata,
console.log('poldownloaddata: ', poldownloaddata);
console.log(atob(this.poldownloaddata.data.pdf_ccnt));
const linkSource = 'data:application/pdf;base64,' + this.poldownloaddata.data.pdf_ccnt;
// const linkSource = (atob(this.previewdata.data.pdf_ccnt));
const downloadLink = document.createElement("a");
const fileName = "policy.pdf";
downloadLink.href = linkSource;
downloadLink.download = fileName;
downloadLink.click();
(error: any) => this.errorMessage = <any>error
}
)
}