Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Failed to load PDF document.
- this._comms.downLoadCertificate(certificateNumber).subscribe((data) => {
- this.downloadFile(data);
- this.completeLoad();
- }
- downloadFile(response: any) {
- var fileContent = new Blob([response.fileContents], {type:
- 'application/pdf' });
- FileSaver.saveAs(fileContent, response.fileDownloadName);
- }
- downLoadCertificate(certificateNumber: string) {
- let headers = new Headers({
- responseType: ResponseContentType.ArrayBuffer
- });
- return this._http.get(`${baseUrl}api/UserAdmin/DownloadCertificate/${certificateNumber}`
- , { headers: headers })
- .map(res => res.json())//
- .catch(super.handleError)
- [HttpGet]
- [Route("api/UserAdmin/DownloadCertificate/{certificateNumber}")]
- public System.Web.Mvc.FileResult DownloadCertificate(string certificateNumber)
- {
- string path = HttpContext.Current.Server.MapPath("~/Certificates/certificate_#" + certificateNumber + ".pdf");
- System.Web.Mvc.FileContentResult result = new System.Web.Mvc.FileContentResult(File.ReadAllBytes(path), "application/pdf")
- {
- FileDownloadName = certificateNumber + ".pdf"
- };
- return result;
- }
Add Comment
Please, Sign In to add comment