I tell you that I have a routine in C # that forms a pdf that leaves it in a variable
var pdfDoc = new iTextSharp.text.Document(PageSize.Letter);
// lineas de código para formar el pdf
res.Payload = pdfDoc;
pdfDoc.Close();
fileStream.Dispose();
TestUtils.VerifyPdfFileIsReadable(pdfFilePath);
res.Success = true;
return res;
In the variable res.payload it brings the pdf object that if it is saved in the Server in the Back, I have verified it, I do not find how to bring to the front in Angular 4 that file in the variable and that I leave it in an object variable in Angular, here the code in Angular of the call to the service and the call, the object if it comes with the information of the pdf, but I ask for help to know how to see it and save it in the client:
this.usuariosService.geUsersReport()
.subscribe(
res => { if (res.success) { let doc = res.payload;
// En la variable res.payload viene el ItextSharp Document y lo he verificado, ¿como verlo y salvarlo en el cliente?
}
this.toastr.success('Registro!', 'Datos correctos!');
}, error => {
this.toastr.error(error.error.message, 'Error - ' + error.error.errorCode);
// this.submitted = false;
}, () => {
// this.submitted = false;
}
);
Here comes the variable with the Document in the service:
public geUsersReport(): Observable<FileResponse<Object>> {
var BearerToken = 'Bearer ' + localStorage.getItem('token');
httpOptions.headers = httpOptions.headers.set('Authorization', BearerToken);
return this.http.get<FileResponse<Object>>(
this.baseUrl + "/api/adminuser/getusersreport",
httpOptions
).pipe(
catchError(this.errorService.handleError)
);
}
}