Ejemplo n.º 1
0
        public void ConvertWord()
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition",
                               "attachment;filename=ListaClienteWord.doc");
            Response.Charset     = "";
            Response.ContentType = "application/vnd.ms-word ";
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            TodosClientes.AllowPaging = false;
            TodosClientes.DataBind();
            TodosClientes.RenderControl(hw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }
Ejemplo n.º 2
0
        public void ConvertPDF()
        {
            Response.AddHeader("content-disposition", "attachment;filename=ListaClientePDF.pdf");
            Response.ContentType = "application/pdf ";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            TodosClientes.AllowPaging = false;
            TodosClientes.DataBind();
            TodosClientes.RenderControl(hw);
            StringReader sr     = new StringReader(sw.ToString());
            Document     DocPDF = new Document(PageSize.A3, 10f, 10f, 10f, 0f);
            PdfWriter    writer = PdfWriter.GetInstance(DocPDF, Response.OutputStream);

            DocPDF.Open();
            XMLWorkerHelper.GetInstance().ParseXHtml(writer, DocPDF, sr);
            DocPDF.Close();
            Response.Write(DocPDF);
            Response.End();
        }