Ejemplo n.º 1
0
 public ActionResult IndexWithAccessToDocumentAndWriter()
 {
     var model = new PdfExample
     {
         Heading = "Heading",
         Items = new List<BasketItem>
         {
             new BasketItem
             {
                 Id = 1,
                 Description = "Item 1",
                 Price = 1.99m
             },
             new BasketItem
             {
                 Id = 2,
                 Description = "Item 2",
                 Price = 2.99m
             }
         }
     };
     return new PdfActionResult(model, (writer, document) =>
     {
         document.SetPageSize(new Rectangle(500f, 500f, 90));
         document.NewPage();
     });
 }
Ejemplo n.º 2
0
        public ActionResult SaveToAppData()
        {
            var model = new PdfExample
            {
                Heading = "Heading",
                Items = new List<BasketItem>
                {
                    new BasketItem
                    {
                        Id = 1,
                        Description = "Item 1",
                        Price = 1.99m
                    },
                    new BasketItem
                    {
                        Id = 2,
                        Description = "Item 2",
                        Price = 2.99m
                    }
                }
            };

            byte[] pdfOutput = ControllerContext.GeneratePdf(model, "IndexWithAccessToDocumentAndWriter");
            string fullPath = Server.MapPath("~/App_Data/FreshlyMade.pdf");

            if (SysIO.File.Exists(fullPath))
            {
                SysIO.File.Delete(fullPath);
            }
            SysIO.File.WriteAllBytes(fullPath, pdfOutput);

            return View("SaveToAppData");
        }
Ejemplo n.º 3
0
 public ActionResult Index()
 {
     var model = new PdfExample {
         Heading = "Heading",
         Items = new List<BasketItem>(){
             new BasketItem {
              Id = 1,
              Description = "Item 1",
              Price = 1.99m},
             new BasketItem {
                 Id = 2,
                 Description = "Item 2",
                 Price = 2.99m }
         }
     };
     return new PdfActionResult(model);
 }