public ActionResult PrintPostCard(PostCardFrontBack model) { var user = _userManager.GetUserDetailsByUserId(model.UserID); List <string> resultString = new List <string>(); model.cardFront = Utilities.ImagePathToBase64(model.cardFront); var result = new List <string>(); var byteArray = new PartialViewAsPdf("Partials/_pdfPostCard", model) { FileName = string.Format("HyggeMail-PostCard.pdf", LOGGEDIN_USER.FirstName, LOGGEDIN_USER.LastName), //PageMargins = new Rotativa.Options.Margins(7, 0, 0, 0), // PageHeight = 127, // PageWidth = 177.8, // PageOrientation = Rotativa.Options.Orientation.Portrait, // PageSize = Rotativa.Options.Size.A4 PageSize = Rotativa.Options.Size.A3, PageOrientation = Rotativa.Options.Orientation.Landscape, PageMargins = { Left = 0, Right = 0 }, // it's in millimeters PageWidth = 150, // it's in millimeters PageHeight = 200, }.BuildPdf(this.ControllerContext); //var path = HttpContext.Server.MapPath("/Uploads/PostCard-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"); var fileName = string.Format("HyggeMail-{0}-{1}.pdf", "PostCard", Utilities.GetTimestamp(DateTime.UtcNow)); var path = Utilities.GetPath(AttacmentsPath.UserProfileImages, fileName); var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write); fileStream.Write(byteArray, 0, byteArray.Length); fileStream.Close(); result.Add(AttacmentsPath.UserProfileImages.Replace("~/", "../../../") + fileName); _userManager.AddHistory(new UserHistoryModel() { UserFK = model.UserID, Type = "Order", Status = "Order Placed", TokenChange = "", AddedOn = DateTime.UtcNow, TokenAvailable = user.Object.CardsCount }); return(Json(new ActionOutput() { Results = result, Status = ActionStatus.Successfull })); }
public ActionResult PrintPostCard(AddUpdateImageEditorModel model) { List <string> resultString = new List <string>(); if (LOGGEDIN_USER.UserType == UserTypes.User) { var print = new PostCardFrontBack(); print.cardBack = model.CardBackWithFrame != null ? model.CardBackWithFrame : model.CardBack; print.cardFront = model.CardFront; var result = new List <string>(); var byteArray = new PartialViewAsPdf("Partials/_pdfPostCard", print) { FileName = string.Format("HyggeMail-PostCard.pdf", LOGGEDIN_USER.FirstName, LOGGEDIN_USER.LastName), //PageMargins = new Rotativa.Options.Margins(7, 0, 0, 0), //PageHeight = 127, //PageWidth = 177.8, //PageOrientation = Rotativa.Options.Orientation.Portrait, PageSize = Rotativa.Options.Size.A3, PageOrientation = Rotativa.Options.Orientation.Landscape, PageMargins = { Left = 0, Right = 0, Top = 11, Bottom = 0 }, // it's in millimeters PageWidth = 150, // it's in millimeters PageHeight = 200, }.BuildPdf(this.ControllerContext); //var path = HttpContext.Server.MapPath("/Uploads/PostCard-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"); var fileName = string.Format("HyggeMail-{0}-{1}.pdf", "PostCard", Utilities.GetTimestamp(DateTime.UtcNow)); var path = Utilities.GetPath(AttacmentsPath.UserProfileImages, fileName); var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write); fileStream.Write(byteArray, 0, byteArray.Length); fileStream.Close(); result.Add(AttacmentsPath.UserProfileImages.Replace("~/", "../../") + fileName); return(Json(new ActionOutput() { Results = result, Status = ActionStatus.Successfull })); } return(Json(new ActionOutput())); }
public ActionResult PrintPDF() { PostCardFrontBack model = new PostCardFrontBack(); return(View(model)); }