如何将面板转换为PDF格式 [英] How I can Convert Panel Into PDF Format
本文介绍了如何将面板转换为PDF格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每一个,
我想通过使用Asp.net以PDF格式保存一个面板,我的意思是我在一个网页上使用了1个面板,显示来自此面板上数据库的数据,现在我想将这些面板数据转换为pdf,那么如何将该面板转换为PDF格式。
如果你有任何代码,请发帖。
提前感谢
hi every one ,
I want to Save One Panel In PDF Format Through Using Asp.net, I mean I used 1 Panels On One Web Page ,and display data from the database on this panel,and now i want to convert these panel data into pdf, So How I can Convert That Panel Into PDF Format.
Please if you have any code, then please post.
thanks in advance
推荐答案
一种可能性是使用iTextSharp创建PDF文档。请参阅: http://sourceforge.net/projects/itextsharp/ [ ^ ]。
One possibility is to use iTextSharp to create the PDF document. See: http://sourceforge.net/projects/itextsharp/[^].
这是我们可以实现的用于将面板数据转换为pdf的代码。
首先我们需要在bin文件夹中添加一个itextsharp.dll,你可以从这里下载 http://sourceforge.net/projects/itextsharp/ [ ^ ]
This is the code which we can implement for convert panel data into pdf.
For this first of all we need add a itextsharp.dll in your bin folder, You can download this from here http://sourceforge.net/projects/itextsharp/[^]
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using System.Xml;
using iTextSharp.text.html;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using CityBusinessLogics;
using System.Collections.Generic;
using System.Net;
using System.Threading;
public void pdf()
{
print();
string attachment = "attachment; filename=ApplicationForm.pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
Panel1.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();
}
这篇关于如何将面板转换为PDF格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文