Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string ruta         = Server.MapPath("~");
        string destinatario = Request.QueryString["destinatario"];
        string remitente    = Request.QueryString["remitente"];
        string iniciales    = Request.QueryString["iniciales"];
        int    cantHoras    = Int32.Parse(Request.QueryString["cantHoras"]);
        int    ciclo        = Int32.Parse(Request.QueryString["ciclo"]);
        string periodo      = Request.QueryString["periodo"];
        int    año          = Int32.Parse(Request.QueryString["año"]);

        GeneradorPDF generadorPDF  = new GeneradorPDF(ruta, destinatario, remitente, iniciales, cantHoras, ciclo, periodo, año);
        string       nombreArchivo = generadorPDF.generarInforme();

        HttpResponse respuesta = HttpContext.Current.Response;

        respuesta.ClearContent();
        respuesta.Clear();
        respuesta.ContentType = "Application/pdf";
        respuesta.AddHeader("Content-Disposition", "attachment; filename=" + nombreArchivo + ";");
        respuesta.TransmitFile(ruta + "\\PDFs\\" + nombreArchivo);
        respuesta.Flush();

        System.IO.File.Delete(ruta + "\\Pdfs\\" + nombreArchivo);

        respuesta.End();
    }
        public FileResult DescargarDG()
        {
            //Proceso proceso = obtenerProceso();
            Proceso proceso = HttpContext.Session.GetComplexData <Proceso>("Proceso");

            proceso.Solicitud.Participantes = ConsultaDeclaracionGastos.LeerDocumentos(proceso.DeclaracionGastos.Id, proceso.Solicitud.Participantes, proceso.Solicitud.Categorias);
            //proceso.Organizacion = ConsultaSolicitud.LeerOrganizacion(proceso.Solicitud.Id);
            GeneradorPDF generadorPDF = new GeneradorPDF(_converter);

            return(File(generadorPDF.PDF(proceso, "Declaración de gastos"), "application/pdf", "DeclaracionDeGastos.pdf"));
        }
Exemplo n.º 3
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            //string xml = SerializarXML.Serializar<Consulta>(Seleccionado);
            //MessageBox.Show(xml);
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter   = "PDF|*.pdf";
            saveFileDialog1.Title    = "Save an Pdf File";
            saveFileDialog1.FileName = "Consulta " + Seleccionado.Paciente.ToString() + " " + Seleccionado.Fecha.ToString("dd-MM-yyyy");;
            saveFileDialog1.ShowDialog();
            // If the file name is not an empty string open it for saving.
            if (saveFileDialog1.FileName != "")
            {
                GeneradorPDF generador = new GeneradorPDF(saveFileDialog1.FileName);
                generador.LeerTemplate(Seleccionado);
                Mensaje("msgOperacionOk");
            }
        }
Exemplo n.º 4
0
        public FileResult DescargarSolicitud()
        {
            Proceso      proceso      = obtenerProceso();
            GeneradorPDF generadorPDF = new GeneradorPDF(_converter);

            return(File(generadorPDF.PDF(proceso, "Solicitud"), "application/pdf", "Soliciud.pdf"));

            /*//var convertidor = new SynchronizedConverter(new PdfTools());
             * //var convertidor = new BasicConverter(new PdfTools());
             * var globalSettings = new GlobalSettings
             * {
             *  ColorMode = ColorMode.Color,
             *  Orientation = Orientation.Portrait,
             *  PaperSize = PaperKind.Letter,
             *
             *  //ColorMode = ColorMode.Color,
             *  //Orientation = Orientation.Portrait,
             *  //PaperSize = PaperKind.A4,
             *  //Margins = new MarginSettings { Top = 10 },
             *  DocumentTitle = "PDF Solicitud"
             * };
             * var objectSettings = new ObjectSettings
             * {
             *  PagesCount = true,
             *  HtmlContent = @"" + TemplatePDF.SolicitudPdf(proceso),
             *  //HtmlContent = TemplatePDF.SolicitudPdf(proceso),
             *  //WebSettings ={DefaultEncoding = "utf-8"},
             *  WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "assets", "estiloPDF.css") },
             *  //HeaderSettings = { FontName = "Arial", FontSize = 9, Right = "Page [page] of [toPage]", Line = true },
             *  //FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Center = "Report Footer" }
             * };
             * var pdf = new HtmlToPdfDocument()
             * {
             *  GlobalSettings = globalSettings,
             *  Objects = { objectSettings }
             * };
             * //var file = _converter.Convert(pdf);
             * byte[] file = _converter.Convert(pdf);
             * //byte[] file = convertidor.Convert(pdf);
             * return File(file, "application/pdf", "Soliciud.pdf");*/
        }