private void GenerarCertificadosRenta(GenerarCertificadosViewModel listadoCert) { var year = DateTime.Now.AddYears(-1); foreach (CertificadoViewModel cert in listadoCert.listadoColaboradores) { string nombreApellidos = cert.nombreApellidos.Replace(' ', '_'); nombreApellidos = nombreApellidos.Replace(',', '_'); string fileName = "Certificado_" + nombreApellidos + ".pdf"; // Se establecen los parámetros del PDF var actionPDF = new Rotativa.ActionAsPdf("generateCertificadoPDF", cert) { FileName = fileName, PageSize = Rotativa.Options.Size.A4, PageOrientation = Rotativa.Options.Orientation.Portrait, PageMargins = { Left = 1, Top = 1, Right = 1, Bottom = 1 } }; // Se escribe en un array de bytes byte[] applicationPDFData = actionPDF.BuildPdf(ControllerContext); // Se guarda en disco /*string path = "~/App_Data/Certificados/" + year + "/" + fileName; * string path2 = Server.MapPath(path);*/ string path2 = "~/App_Data/Certiificados/"; savePDFOnDisk(applicationPDFData, path2, fileName); } }
public ActionResult PrintDetaje(int id) { ViewBag.Derguesi = Session["emri"].ToString(); var q = new Rotativa.ActionAsPdf("Detaje", new { id = id }); return(q); }
public ActionResult WithdrawAsPDF(int idOfEconomyAccount) { // Here we have the View itself, this one includes the website header and footer var withdrawConfirmationDocument = new Rotativa.ActionAsPdf("Withdraw", new { idOfEconomyAccount }); return(withdrawConfirmationDocument); }
public ActionResult PrintEconomyAccountSummaryAsPDF(int idOfEconomyAccount) { // Here we have the View itself, this one includes the website header and footer var report = new Rotativa.ActionAsPdf("EconomyAccountSummary", new { idOfEconomyAccount }); return(report); }
public ActionResult PrintDPI(int id) { var cookies = Request.Cookies.AllKeys.ToDictionary(k => k, k => Request.Cookies[k].Value); var report = new Rotativa.ActionAsPdf("DPI", new { id }) { FormsAuthenticationCookieName = System.Web.Security.FormsAuthentication.FormsCookieName, Cookies = cookies }; return(report); }
public ActionResult NewPDF(int?id) { var newPDF = new Rotativa.ActionAsPdf("Certificate/" + id.ToString()) { PageOrientation = 0, PageSize = Rotativa.Options.Size.A5 }; return(newPDF); }
// GET: ExamplePDF public ActionResult Index() { string fname = "PruebaPdf3" + Guid.NewGuid().ToString() + ".pdf"; string filePath = Server.MapPath("~/PDF/" + fname); Example E = new Example { Name = "Juan12", SurName = "Novales12" }; var actionPDF = new Rotativa.ActionAsPdf("GeneraPDF", E) { FileName = filePath, PageOrientation = Rotativa.Options.Orientation.Landscape, PageMargins = { Left = 1, Right = 1 } }; byte[] applicationPDFData = actionPDF.BuildPdf(ControllerContext); var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write); fileStream.Write(applicationPDFData, 0, applicationPDFData.Length); return(actionPDF); }
public JsonResult UrlAsPDF(int reportId, bool withInsights, bool withChartInsights, bool withComments, string reportName, string from, string to) { var response = new NotificationsResponse(); try { var pdf = new Rotativa.ActionAsPdf("MainToPdf", new { reportId = reportId, withComments = withComments, withInsights = withInsights, withChartInsights = withChartInsights, chartId = 0, from = from, to = to }) { FileName = reportName + ".pdf", IsJavaScriptDisabled = false, PageMargins = { Left = 10, Right = 10 } }; _log.Warn("Started"); byte[] applicationPDFData = pdf.BuildPdf(ControllerContext); var path = Server.MapPath("~/Reports/Pdf"); var fileName = reportName + WebSecurity.CurrentUserId + ".pdf"; if (!System.IO.Directory.Exists(path + "/" + WebSecurity.CurrentUserId.ToString())) { System.IO.Directory.CreateDirectory(path + "/" + WebSecurity.CurrentUserId.ToString()); } var directory = new DirectoryInfo(path + "/" + WebSecurity.CurrentUserId.ToString()); path = System.IO.Path.Combine(path, WebSecurity.CurrentUserId.ToString(), fileName); System.IO.File.WriteAllBytes(path, applicationPDFData); var fileUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Url.Content("~") + "/Reports/Pdf/" + WebSecurity.CurrentUserId.ToString() + "/" + fileName; var filesOrdered = directory.GetFiles().OrderByDescending(x => x.LastWriteTime); if (filesOrdered.Count() > 10) { var files = filesOrdered.Skip(10).ToList(); foreach (var file in files) { file.Delete(); } } var notificationDto = new NotificationDto() { CreateBy = WebSecurity.CurrentUserId, Text = "Your \"" + reportName + "\" PDF is ready <a href='" + fileUrl + "' target='_blank'>here</a>", WasViewed = false, CreatedDate = DateTime.Now }; if (_notificationService.AddNotification(notificationDto).Acknowledgment) { response.Notification = notificationDto; response.Acknowledgment = true; response.Message = "Success"; } else { response.Acknowledgment = false; response.Message = "Error"; } _notificationService.DeleteNotifications(WebSecurity.CurrentUserId); } catch (Exception ex) { ViewBag.myData = "error: " + ex.Message; _log.Error("---- Exception Creating PDF: " + ex.Message + " ----");//("Exception Creating PDF", ex.Message); response.Acknowledgment = false; response.Message = "Error"; } return(Json(response, JsonRequestBehavior.AllowGet)); //return RedirectToAction("MainToPdf", new { reportId = reportId });; }
public ActionResult Convert(int id) { var report = new Rotativa.ActionAsPdf("PdfView", new { id = id }); return(report); }
public ActionResult GenerateResultReport() { var report = new Rotativa.ActionAsPdf("Index"); return(report); }
public ActionResult PrintAllRooms(int?id) { var report = new Rotativa.ActionAsPdf("Details", new { id = id }); return(report); }
public ActionResult PrintPDF(int?id) { var report = new Rotativa.ActionAsPdf("ShowPDF", new { id = id }); return(report); }
public ActionResult DownloadPDF(int?Id) { var r = new Rotativa.ActionAsPdf("PDF", new { id = Id }); return(r); }
public ActionResult ReceiptToPdf(int id) { var result = new Rotativa.ActionAsPdf("Receipt", new { id = id }); return(result); }
public ActionResult PayRateAsPDF(int idOfRate) { var report = new Rotativa.ActionAsPdf("PayRate", new { idOfRate }); return(report); }
public ActionResult InvoiceToPdf(int id) { var result = new Rotativa.ActionAsPdf("Invoice", new { id = id }); return(result); }
public ActionResult PrescriptionToPdf(int id) { var result = new Rotativa.ActionAsPdf("Prescription", new { id = id }); return(result); }
/// <summary> /// Print Employees details /// </summary> /// <returns></returns> public ActionResult PrintAllEmployee() { var report = new Rotativa.ActionAsPdf("Employees"); return(report); }
public ActionResult Print(int id) { var report = new Rotativa.ActionAsPdf("PrintCareTracking", new { careTrackingID = id }); return(report); }
/// <summary> /// Print employee details /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult PrintEmployee(int id) { var report = new Rotativa.ActionAsPdf("Employee", new { id = id }); return(report); }
public ActionResult PrintRIGEOT(String id) { var report = new Rotativa.ActionAsPdf("RIGEOT", id); return(report); }
public ActionResult PrintContact(int?id) { var report = new Rotativa.ActionAsPdf("Contact", new { id = id }); return(report); }