Наследование: AsPdfResultBase
 /*
  * Configura algumas propriedades do PDF, inclusive o nome do arquivo gerado,
  * Porem agora ele baixa o pdf ao inves de mostrar no browser
  */
 public ActionResult PDFConfigurado()
 {
     var pdf = new ViewAsPdf
     {
         ViewName = "Modelo",
         FileName = "NomeDoArquivoPDF.pdf",
         PageSize = Size.A4,
         IsGrayScale = true,
         PageMargins = new Margins{Bottom = 5, Left = 5, Right = 5, Top = 5},
     };
     return pdf;
 }
        public async Task<ActionResult> Venda([Bind(Include ="DataInicial, DataFinal")] Relatorio relatorio)
        {
           
            bool isAutenticado = CheckUsuarioAdminAutenticado();

            if (!isAutenticado)
            {
                return RedirectToAction("Index", "LoginAdmin");
            }

            InitMenuAdmin();

            var pdf = new ViewAsPdf
            {
                ViewName = "VendaRelatorio"
            };

            var sessionAdmin = Session["autenticacaoAdmin"] as SessionAutenticacaoAdmin;
            var usuario = db.Usuario.Where(x => x.Id == sessionAdmin.Id).FirstOrDefault();
            
            ViewBag.Filtros = relatorio;
            ViewBag.Usuario = usuario;

            var vendas = db.Venda.Where(x => x.Data >= relatorio.DataInicial && x.Data <= relatorio.DataFinal).ToList();
            ViewBag.Vendas = vendas;

            return pdf;
        }
        /*
         * Pode passar um modelo para a view que vai ser utilizada para gerar o PDF
         */
        public ActionResult PDFComModel()
        {
            var modelo = new Usuario
                             {
                                 Nome = "Cleyton Ferrari",
                                 Site = "http://cleytonferrari.com"
                             };

            var pdf = new ViewAsPdf
            {
                ViewName = "Modelo",
                Model = modelo
            };

            return pdf;
        }
 /*
  * Retorna um PDF diretamente no browser com as configurações padrões
  * ViewName é setado somente para utilizar o proprio Modelo anterior
  * Caso não queira setar o ViewName, você deve gerar a view com o mesmo nome da action
  */
 public ActionResult PDFPadrao()
 {
     var pdf = new ViewAsPdf
                   {
                       ViewName = "Modelo"
                   };
     return pdf;
 }
Пример #5
1
        public ActionResult BuscaRegistros(string os)
        {
            var pdf = new ViewAsPdf(pontoModel.PesquisaPontosOs(os))
            {
                ViewName = "Modelo",
                CustomSwitches = "--print-media-type --header-center \"Redemaq Minas\""

            };
            return pdf;
        }
        public void Print(ParkingTicket ticket, object args = null)
        {
            var r = new ViewAsPdf("Rpt01_ParkingTicketIn", ticket);

              r.PageSize = Rotativa.Options.Size.A6;
              r.PageOrientation = Rotativa.Options.Orientation.Portrait;

              var fileName = ticket.Id + ".pdf";
              var filePath = HttpContext.Current.Server.MapPath("~/App_Data/" + fileName);

              var bytes = r.BuildPdf((ControllerContext)args);
              System.IO.File.WriteAllBytes(filePath, bytes);
        }
Пример #7
1
        public void Print(ParkingTicket ticket, object args = null)
        {
            //throw new NotImplementedException();

              var r = new ViewAsPdf("RPT_01_PakingTicket_In", ticket);
              r.PageSize = Rotativa.Options.Size.A6;
              r.PageOrientation = Rotativa.Options.Orientation.Portrait;

              var fName = ticket.ID + ".PDF";
              var fPath = HttpContext.Current. Server.MapPath("~/App_Data/" + fName);

              var bytes = r.BuildPdf((ControllerContext) args);
              System.IO.File.WriteAllBytes(fPath, bytes);
        }
Пример #8
0
        public JsonResult Email(int id)
        {
            try
            {
                var invoice = db.Invoices
                              .Include(i => i.InvoiceDetails)
                              .Include(i => i.Payments)
                              .Include(i => i.Client)
                              .FirstOrDefault(i => i.Id == id);
                var fileName  = string.Format("Invoice_{0}_{1}.pdf", invoice.Id, invoice.Date.ToString("MM-dd-yyyy"));
                var client    = db.Clients.FirstOrDefault(c => c.Id == invoice.Client.Id);
                var viewAsPef = new Rotativa.ViewAsPdf("~/Views/Sales/Print.cshtml", invoice)
                {
                    FileName        = fileName,
                    PageSize        = Size.Letter,
                    PageOrientation = Orientation.Portrait,
                    PageMargins     = { Left = 1, Right = 1 }
                };

                byte[] bytesPDFData = viewAsPef.BuildPdf(ControllerContext);
                var    stream       = new MemoryStream(bytesPDFData);
                var    emailService = new SendEmailService(db);
                emailService.SendInvoiceToClient(invoice, client, stream, fileName);

                return(Json(new { Result = true, Data = new { ClientId = client.Id }, Message = "The Invoice has send" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }
        public ActionResult Produtos()
        {
            ProdutoBll produtoBll = new ProdutoBll();

            List<Produto> produtos = produtoBll.ListarProdutosAtivos();

            var pdf = new ViewAsPdf
            {
                ViewName = "Produtos",
                Model = produtos
            };
            return pdf;
        }
        public ActionResult Clientes()
        {
            List<Cliente> clientes = ClienteBll.ListarClientes();

            var pdf = new ViewAsPdf
            {
                ViewName = "~/Views/Relatorios/Admin/Clientes.cshtml",
                PageSize = Size.A4,
                IsGrayScale = true,
                PageMargins = new Margins { Bottom = 5, Left = 5, Right = 5, Top = 5 },
                Model = clientes
            };

            return pdf;            
        }
Пример #11
0
 /*
  * Configura algumas propriedades do PDF, inclusive o nome do arquivo gerado,
  * Porem agora ele baixa o pdf ao inves de mostrar no browser
  */
 public ActionResult PDFConfigurado()
 {
     if (Roles.IsUserInRole(User.Identity.Name, "administrador") || (System.Web.Security.Roles.IsUserInRole(User.Identity.Name, "gerencia")))
     {
     var pdf = new ViewAsPdf(pontoModel.todosPontos())
     {
         FileName = "RelatorioDePonto.pdf",
         PageSize = Size.A4,
         IsGrayScale = true,
         CustomSwitches = "--print-media-type --header-center \"Redemaq Minas\"",
         PageMargins = new Margins { Bottom = 5, Left = 5, Right = 5, Top = 5 },
     };
     return pdf;
     }
     return Redirect("/Shared/Error");
 }
Пример #12
0
        public ActionResult PdfAction(string id, DateTime? fromDate, DateTime? toDate)
        {
            var produto = library.carregarProduto(id);
            ViewBag.Produto = produto;
            ViewBag.InfoFilter = (fromDate != null) ? "filtrado de " + fromDate.Value.ToString() + " até " + toDate.Value.ToString() : "Todas as movimentações";

            var pdf = new ViewAsPdf
            {
                ViewName = "PdfAction",
                Model = TempData["mov"],
                FileName =  "Relatorio_" + produto.id +"_" + produto.nome + ".pdf",
                PageSize = Size.A4,
                IsGrayScale = true,
                PageMargins = new Margins { Bottom = 5, Left = 5, Right = 5, Top = 5 }
            };

            return pdf;
        }
Пример #13
0
        /*
         * Pode passar um modelo para a view que vai ser utilizada para gerar o PDF
         */
        public ActionResult Modelo()
        {
            if (Roles.IsUserInRole(User.Identity.Name, "administrador") || (System.Web.Security.Roles.IsUserInRole(User.Identity.Name, "gerencia")))
            {
            //var modelo = new Usuario
            //{
            //    Login = "******",
            //};

            var pdf = new ViewAsPdf(pontoModel.todosPontosFechados())
            {
                ViewName = "Modelo",
                CustomSwitches = "--print-media-type --header-center \"Redemaq Minas\""
                //Model = modelo
            };

            return pdf;
            }
             return Redirect("/Shared/Error");
        }
        public ActionResult RelatorioCliente(int?pagina, Boolean?pdf)
        {
            var listaClientes = SimulacaoDB.GetAllClientes();

            if (pdf != true)
            {
                int numeroRegistros = 3;
                int numeroPagina    = (pagina ?? 1);
                return(View(listaClientes.ToPagedList(numeroPagina, numeroRegistros)));
            }
            else
            {
                int pagNumero = 1;

                var relatorioPDF = new Rotativa.ViewAsPdf
                {
                    ViewName    = "_Relatorio",
                    IsGrayScale = true,
                    Model       = listaClientes.ToPagedList(pagNumero, listaClientes.Count)
                };
                return(relatorioPDF);
            }
        }
        public async Task<ActionResult> Clientes()
        {

            bool isAutenticado = CheckUsuarioAdminAutenticado();

            if (!isAutenticado)
            {
                return RedirectToAction("Index", "LoginAdmin");
            }

            InitMenuAdmin();

            var pdf = new ViewAsPdf
            {
                ViewName = "ClienteRelatorio"
            };

            var sessionAdmin = Session["autenticacaoAdmin"] as SessionAutenticacaoAdmin;
            var usuario = db.Usuario.Where(x => x.Id == sessionAdmin.Id).FirstOrDefault();
            
            ViewBag.Usuario = usuario;

            var pessoas = db.Pessoa.ToList();
            ViewBag.Pessoas = pessoas;

            return pdf;
        }
        public ActionResult GenerateInvoice(int id, string type)
        {
            //return View("InvoicesTemplates/invoice-en");
            var invoiceDetails = this.invoices.InvoiceDetails(id);
            ViewAsPdf file;

            if (type == "bg")
            {
                file = new ViewAsPdf("InvoicesTemplates/invoice-bg", invoiceDetails)
                {
                    FileName = ("Invoice BG - " + DateTime.Now + ".pdf")
                };
            }
            else
            {
                file = new ViewAsPdf("InvoicesTemplates/invoice-en", invoiceDetails)
                {
                    FileName = ("Invoice EN - " + DateTime.Now + ".pdf")
                };
            }

            return file;
        }
        public ActionResult GenerateContractTemplate(int providerId, int contractId)
        {
            var contractsData = this.contracts.GenerateContractTemplate(providerId, contractId);
            var contract = contractsData.Contract;

            ViewBag.InvoiceSum = contractsData.Sum;
            ViewBag.Client = contractsData.Client;
            ViewBag.Provider = contractsData.Provider;
            ViewBag.Channels = contractsData.Channels;
            ViewBag.Invoices = contractsData.Invoices;
            ViewBag.Trds = contractsData.Trds;
            ViewBag.MgSubs = contractsData.MgSubs;
            ViewBag.Cps = contractsData.Cps;
            ViewBag.ClientContractType = contractsData.ClientContractType;

            ViewAsPdf file;

            switch (contractsData.ContractTemplate)
            {
                case ContractTemplate.Box:
                    file = new ViewAsPdf("ContractsTemplates/Box", contract)
                    {
                        FileName = ("Box contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.EbuLa:
                    file = new ViewAsPdf("ContractsTemplates/Ebu_la", contract)
                    {
                        FileName = ("Ebu La contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.Ectv:
                    file = new ViewAsPdf("ContractsTemplates/Ectv", contract)
                    {
                        FileName = ("Ectv contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.Fashionone:
                    file = new ViewAsPdf("ContractsTemplates/Fashionone", contract)
                    {
                        FileName = ("Fashionone contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.Fcw:
                    file = new ViewAsPdf("ContractsTemplates/Fcw", contract)
                    {
                        FileName = ("Fcw contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.Fishing:
                    file = new ViewAsPdf("ContractsTemplates/Fishing", contract)
                    {
                        FileName = ("Fishing contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.Imagine:
                    file = new ViewAsPdf("ContractsTemplates/Imagine", contract)
                    {
                        FileName = ("Imagine contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.Roma:
                    file = new ViewAsPdf("ContractsTemplates/Roma", contract)
                    {
                        FileName = ("Roma contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.SuperOne:
                    file = new ViewAsPdf("ContractsTemplates/SuperOne", contract)
                    {
                        FileName = ("Super One contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.Bulsat:
                    file = new ViewAsPdf("ContractsTemplates/Bulsat", contract)
                    {
                        FileName = ("Bulsat VIRGIN XCHANGE contract - " + DateTime.Now + ".pdf")
                    };

                    return file;
                case ContractTemplate.CREA:
                    file = new ViewAsPdf("ContractsTemplates/CREA/CREA", contract)
                    {
                        FileName = ("CREA contract - " + DateTime.Now + ".pdf")
                    };

                    return file;
                case ContractTemplate.DSTV:
                    file = new ViewAsPdf("ContractsTemplates/DSTV/DSTV", contract)
                    {
                        FileName = ("DSTV contract - " + DateTime.Now + ".pdf")
                    };

                    return file;
                case ContractTemplate.Moviestar:
                    file = new ViewAsPdf("ContractsTemplates/Moviestar/Moviestar", contract)
                    {
                        FileName = ("Moviestar contract - " + DateTime.Now + ".pdf")
                    };
                    return file;
                case ContractTemplate.P4TV:
                    file = new ViewAsPdf("ContractsTemplates/P4TV/P4TV", contract)
                    {
                        FileName = ("P4TV contract - " + DateTime.Now + ".pdf")
                    };

                    return file;
                case ContractTemplate.SCT:
                    file = new ViewAsPdf("ContractsTemplates/SCT/SCT", contract)
                    {
                        FileName = ("SCT contract - " + DateTime.Now + ".pdf")
                    };

                    return file;
                case ContractTemplate.TheWorld:
                    file = new ViewAsPdf("ContractsTemplates/THE_WORLD/THE_WORLD", contract)
                    {
                        FileName = ("THE_WORLD contract - " + DateTime.Now + ".pdf")
                    };

                    return file;
                case ContractTemplate.UATV:
                    file = new ViewAsPdf("ContractsTemplates/UATV/UATV", contract)
                    {
                        FileName = ("UATV contract - " + DateTime.Now + ".pdf")
                    };

                    return file;
            }

            return new EmptyResult();
        }
        public ActionResult RelatorioCarrosCadastradosPDF(string dataInicial,string dataFinal,string[] modelos,FormCollection formulario)
        {
            var allvalues = formulario["modelos"].Split(',').Select(x => int.Parse(x));

            foreach (var item in allvalues)
            {
                string teste = item.ToString();
            }

            List<RelatorioCarrosCadastrados_Result> listaCarros = new List<RelatorioCarrosCadastrados_Result>();

            using (CarOnlineEntities DB = new CarOnlineEntities())
            {

                listaCarros = DB.RelatorioCarrosCadastrados(dataInicial, dataFinal).ToList<RelatorioCarrosCadastrados_Result>();
            }
            if(modelos!=null)
                listaCarros.Where(lc => modelos.Contains(lc.Modelo));
            var pdf = new ViewAsPdf
            {
                ViewName = "RelatorioCarrosCadastrados",
                Model = listaCarros
            };
            return pdf;
        }
        public ActionResult RelatorioCarrosVendidosPDF(FormCollection formulario)
        {
            List<RelatorioCarrosVendidos_Result> listaVendas = new List<RelatorioCarrosVendidos_Result>();
            int marca  = Convert.ToInt32(formulario["ListaMarcas"]);
            int modelo = Convert.ToInt32(formulario["ListaModelos"]);
            string porMarca = formulario["porMarca"];
            string porModelo = formulario["porModelo"];

            if (porMarca == null)
                marca = 0;
            if (porModelo == null)
                modelo = 0;
            using (CarOnlineEntities DB = new CarOnlineEntities())
            {
                listaVendas = DB.RelatorioCarrosVendidos(formulario["dataInicial"], formulario["dataFinal"],marca,modelo).ToList<RelatorioCarrosVendidos_Result>();
                double TotalVenda = 0;
                foreach (var registro in listaVendas)
                {
                    TotalVenda += registro.ValorVenda;
                }
                @ViewBag.TotalVenda = TotalVenda;
            }
            var pdf = new ViewAsPdf
            {
                ViewName = "RelatorioCarrosVendidos",
                Model = listaVendas
            };
            return pdf;
        }
Пример #20
0
 /*
  * Retorna um PDF diretamente no browser com as configurações padrões
  * ViewName é setado somente para utilizar o proprio Modelo anterior
  * Caso não queira setar o ViewName, você deve gerar a view com o mesmo nome da action
  */
 public ActionResult PDFPadrao()
 {
     if (Roles.IsUserInRole(User.Identity.Name, "administrador") || (System.Web.Security.Roles.IsUserInRole(User.Identity.Name, "gerencia")))
     {
     var pdf = new ViewAsPdf(pontoModel.todosPontos());
     return pdf;
     }
     return Redirect("/Shared/Error");
 }
Пример #21
0
        public ActionResult Test()
        {
            var pdfResult = new ViewAsPdf("Create")
            {
                FileName = "PurchaseInvoice.pdf",
                CustomSwitches ="--footer-center \"Name: " + "S&B Pallets LTD." + "  Date: " + DateTime.Now.Date.ToString("MM/dd/yyyy") + "Page: [1]/[1]\"" +" --footer-line --footer-font-size \"9\" --footer-spacing 6 --footer-font-name \"calibri light\""
            };

               return pdfResult;
        }