pdf is not opening by Adobe reader, created by using iTextSharp

I am new in iTextSharp coding. I am creating pdf file in VS2010 from html string . The html string containing html table that I want convert it into a pdf file. I have develop a code by own, which successfully create PDF file but when I go to open file, its shows message that

Adobe Reader could not open 'XXX.pdf' because it is either not a supported file or because file has been damage

but I am not getting where I am going wrong The code that I develop is as follows:

        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=PendingOrderItems.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        DataTable oTable = HtmlTableParser.ParseTable(hftbPdfData.Text);
        GridView oTempGridview = new GridView();
        oTempGridview.AllowPaging = false;
        oTempGridview.DataSource = oTable;
        oTempGridview.DataBind();
        StringWriter oStrWriter = new StringWriter();
        HtmlTextWriter ohTextWriter = new HtmlTextWriter(oStrWriter);
        oTempGridview.RenderControl(ohTextWriter);
        StringReader oStringReader = new StringReader(oStrWriter.ToString());
        Document oDocument = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
        HTMLWorker oHTMLWorker = new HTMLWorker(oDocument);
        oDocument.Open();
        oHTMLWorker.Parse(oStringReader);
        oDocument.Close();
        Response.Write(oStringReader);
        Response.End();

Can anyone tell me where I am going wrong?????

链接地址: http://www.djcxy.com/p/46742.html

上一篇: 使用itextsharp和asp.net将字节转换为pdf

下一篇: pdf不会由Adobe Reader使用iTextSharp创建