C# 使用C将面板内容中的所有内容导出为PDF#
我有一个面板,面板内有一个gridview和图表(fusion图表)。我想做的是将面板中的所有内容作为图像导出到PDF中。到目前为止,我只能导出gridview,图表根本没有显示出来。如何将面板内容中的所有内容作为图像导出为pdf格式?请。救命啊。这是我的密码: 我正在使用ITEXT SharpC# 使用C将面板内容中的所有内容导出为PDF#,c#,asp.net,C#,Asp.net,我有一个面板,面板内有一个gridview和图表(fusion图表)。我想做的是将面板中的所有内容作为图像导出到PDF中。到目前为止,我只能导出gridview,图表根本没有显示出来。如何将面板内容中的所有内容作为图像导出为pdf格式?请。救命啊。这是我的密码: 我正在使用ITEXT Sharp protected void btnExport_Click(object sender, EventArgs e) { Response.ContentType = "application/
protected void btnExport_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnlPerson.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
尝试使用将控件绘制为位图,然后将该位图绘制到PDF中 Draw to bitmap(绘制到位图)将控件绘制到位图中-将其视为点击打印屏幕 那么在这种情况下,
Bitmap bm = new Bitmap(mygraph.Bounds.Width, mygraph.Bounds.Height);
mygraph.DrawToBitmap(new System.Drawing.Bitmap(),new System.Drawing.Rectangle(0,0,mygraph.Bounds.Width,mygraph.Bounds.Height)
pdfwriterthingy.writebitmap(bm);
您的pdf导出器能够编写位图,这是我的一大飞跃。据我所知,融合图表是在浏览器上呈现的Javascript。在这种情况下,将其HTML“呈现”为PDF不会特别成功 熔合图提供,您需要使用它们 以下是Fusion Charts网站提供的更多资源:
- (向下滚动至“将图表导出为图像/PDF演示”