开发者

Export page content to PDF using a iTextSharp (include buttons and grids)

开发者 https://www.devze.com 2023-02-12 16:45 出处:网络
How to export my aspx page (include buttons and Grids) to PDF? Searching the web I found iTextSharp, but it works only with normal html.

How to export my aspx page (include buttons and Grids) to PDF?

Searching the web I found iTextSharp, but it works only with normal html. If my page has Grids or Buttons, these do not appear in PDF.

My current code for export to PDF. This code exports only basic html (no buttons or grids).

string attachment = "attachment; filename=AllPage.pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "applica开发者_运维百科tion/pdf";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
GridView1.AllowPaging = false;
GridView1.DataBind();
GridView1.RenderControl(htextw);
Document document = new Document();
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
StringReader str = new StringReader(stw.ToString());
HTMLWorker htmlworker = new HTMLWorker(document);
htmlworker.Parse(str);
document.Close();
Response.Write(document);
Response.End();


Just use wkhtmltopdf. It'll handle anything short of an ActiveX control.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号