コード例 #1
0
        public void ConvertWord()
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition",
                               "attachment;filename=ListaProveedorWord.doc");
            Response.Charset     = "";
            Response.ContentType = "application/vnd.ms-word ";
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            TodosProveedores.AllowPaging = false;
            TodosProveedores.DataBind();
            TodosProveedores.RenderControl(hw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }
コード例 #2
0
        public void ConvertPDF()
        {
            Response.AddHeader("content-disposition", "attachment;filename=ListaProveedorPDF.pdf");
            Response.ContentType = "application/pdf ";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            TodosProveedores.AllowPaging = false;
            TodosProveedores.DataBind();
            TodosProveedores.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();
        }