我是iTextSharp
编码的新手。我在VS2010中从 html string 创建pdf文件。包含html表的html字符串,我想将其转换为pdf文件。我已经开发了一个自己的代码,它成功地创建了PDF文件但是当我去打开文件时,它会显示消息
Adobe Reader无法打开“XXX.pdf”,因为它不是受支持的文件,或者因为文件已损坏
但我没有得到我错的地方 我开发的代码如下:
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();
谁能告诉我哪里出错了?????