Exemplo n.º 1
0
        public async Task <ActionResult> MoviesToPdf()
        {
            var movies = _repository.List <Movie>()
                         .Select(MovieDTO.FromMovie).Take(1);
            //return new ViewAsPdf("Index", movies);
            var rpt = new Rotativa.AspNetCore.ViewAsPdf();

            //rptLandscape.Model = Model;
            rpt.PageOrientation = Rotativa.AspNetCore.Options.Orientation.Portrait;
            rpt.PageSize        = Rotativa.AspNetCore.Options.Size.A4;
            rpt.ViewName        = "Index";
            rpt.Model           = movies;
            var context = this.ControllerContext;

            byte[] arr = await rpt.BuildFile(context);

            System.IO.File.WriteAllBytes(Path.Combine(iHostingEnvironment.WebRootPath, "PDFStorage", "File" + Guid.NewGuid() + ".pdf"), arr);
            Console.WriteLine("ASDASDASDASD" + this.ControllerContext.HttpContext.RequestServices.GetService(typeof(ITempDataProvider)).ToString() + "ASDASDASDASDASDASDASDDS");
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public async Task <string> Post([FromBody] object value)
        {
            var k = new Rotativa.AspNetCore.ViewAsPdf("OrderConfirmation", JsonConvert.DeserializeObject <Paidorder>(value.ToString()));

            return(Convert.ToBase64String(await k.BuildFile(ControllerContext)));
        }