In backend I'm using FW1(Coldfusion FrameWork).
First code is of angular Ts file.
showPdf(){
let ReportPdf = new FormData();
ReportPdf.append('DateFrom',(<HTMLInputElement>document.getElementById("dateFrom")).value);
ReportPdf.append('DateTo',(<HTMLInputElement>document.getElementById("dateTo")).value);
ReportPdf.append('VendorId',this.labourReport.get('vendorName').value);
ReportPdf.append('ProjectID',this.labourReport.get('projectName').value);
this.hrservice.getLabourPdf(ReportPdf).subscribe(blob => {
console.log("--",blob);
importedSaveAs(blob, this.fileName);
}
)
}
2nd Code is of Angular Service File
public getLabourPdf(obj:any):Observable<any>{
return this.http.post(this.apiurl + 'report.reportpdf&reload=1' ,obj)
.pipe(
map((res: any) => {
return new Blob([res.blob()], { type: 'application/pdf' });
})
);
}
Last Code is of Fw1 Controller
function reportpdf(struct rc,struct headers){
var arguments.rc.response = StructNew();
arguments.rc.response.success = '';
local.response = variables.reportService.Data(VendorId=request.rc.VendorId ,projectId=request.rc.ProjectID,dateFrom = DateFormat(request.rc.DateFrom,"YYYY-MM-DD"),dateTo = DateFormat(request.rc.DateTo,"YYYY-MM-DD"));
rc.title = "labourReport";
arguments.rc.response.success = local.response;
variables.fw.setView("main.reportpdf");
}
This is What I'm getting in Api Response
%PDF-1.4
%����
2 0 obj
<</Filter/FlateDecode/Length 338>>stream
x���MO�@���+樗u��*WcM4jl��1
ԒZD����t�4K�Lvx���N����:�Ф050�PB���
^�f��-̟)��j�pRwպ��"Tؚ�]�����4O���.2I�ük� �D�9��Nȩɛ�d�[�!��|
�cV�e��0ϔl�