コード例 #1
0
        public ActionResult DownloadPDF()
        {
            try
            {
                var model = new GeneratePDFModel();

                //get the information to display in pdf from database
                //for the time
                //Hard coding values are here, these are the content to display in pdf
                var content = "<h2>WOW Rotativa<h2>" +
                 "<p>Ohh This is very easy to generate pdf using Rotativa <p>";
                var logoFile = @"/Images/logo.png";

                model.PDFContent = content;
                model.PDFLogo = Server.MapPath(logoFile);

                //Use ViewAsPdf Class to generate pdf using GeneratePDF.cshtml view
                return new Rotativa.ViewAsPdf("GeneratePDF", model) { FileName = "firstPdf.pdf" };
            }
            catch (Exception ex)
            {

                throw;
            }
        }
コード例 #2
0
        public ActionResult DownloadPDF(int SuggId)
        {
            try
            {
                ISuggestionService suggestionService = new SuggestionService();
                suggestion suggestions = suggestionService.GetSuggestionById(SuggId);


               

                var model = new GeneratePDFModel();

                //get the information to display in pdf from database
                //for the time
                //Hard coding values are here, these are the content to display in pdf 

                var logoFile = @"/Images/logo.png";


                model.PDFLogo = Server.MapPath(logoFile);
                QRCodeEncoder en = new QRCodeEncoder();
                Image a = en.Encode("WLEED FLY 2015" + suggestions.offre.id + " " + suggestions.offre1.id);

                a.Save(Server.MapPath(@"~/Content/qr.bmp"), ImageFormat.Bmp);
                var content = "<div><table style='float: left' cellspacing='3'><tr><td><h1>trader 1 Username :"******"session"] + "<h1></td><td> </td><tr><td><h1>Offer Name:" + Session["cuser"].ToString() + "<h1></td><td> </td></tr></table></div>" +
              "<div><table  style='float: left' cellspacing='3'><tr><td><h1>trader 2 Username :<h1></td><td> </td><tr><td><h1>Offer Name:" + suggestions.offre1.name + "<h1></td><td> </td></tr></table></div>" + "<img src=" + char.ConvertFromUtf32(34) + Server.MapPath(@"~/Content/qr.bmp") + char.ConvertFromUtf32(34) + ";>";
                // @"~/Content/qr.bmp"
                //Use ViewAsPdf Class to generate pdf using GeneratePDF.cshtml view
                model.PDFContent = content;

                return new Rotativa.ViewAsPdf("GeneratePDF", model) { FileName = "firstPdf.pdf" };

            }
            catch (Exception)
            {

                throw;
            } 

        }