public ActionResult PrintToPdf(int id) { try { var entity = _resumeService.GetDetails(id); byte[] bytes = null; using (var stream = new MemoryStream()) { _pdfService.PrintResume(stream, entity); bytes = stream.ToArray(); } return(File(bytes, "application/pdf", string.Format("{0}_Resume.pdf", entity.Name))); } catch (Exception) { //ErrorNotification(exc); return(RedirectToAction("Index")); } }