Exemple #1
0
        public async Task <bool> jsCrearPDFTramite()
        {
            return(await Task.Run(() =>
            {
                try
                {
                    var configuracionService = new ConfiguracionService();
                    var ruta = configuracionService.GetFormatoTramite(IdSesionTipoTramite);
                    var bytesPdf = System.IO.File.ReadAllBytes(ruta);

                    Response.Clear();
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.Charset = "";
                    Response.BufferOutput = true;
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("Content-Disposition", "attachment;filename=Requisitos.pdf");
                    Response.AddHeader("Content-Length", bytesPdf.Length.ToString());
                    Response.BinaryWrite(bytesPdf);
                    Response.Flush();
                    Response.End();
                }
                catch (Exception ex)
                {
                    RespuestaError(ex);
                }
                return true;
            }));
        }
Exemple #2
0
        // application/vnd.openxmlformats-officedocument.wordprocessingml.document  --> DOCX
        // application/msword                                                       --> DOC


        public async Task <FileResult> jsCrearDOCXTramite()
        {
            return(await Task.Run(() =>
            {
                var configuracionService = new ConfiguracionService();
                var ruta = configuracionService.GetFormatoTramite(IdSesionTipoTramite);
                ruta = ruta.Replace("pdf", "docx");
                var bytesPdf = System.IO.File.ReadAllBytes(ruta);

                return File(bytesPdf, "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                            "Requisitos.docx");
            }));
        }