3 回答

TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個(gè)贊
在進(jìn)行了一些挖掘之后,我找到了一種很好的方式來(lái)實(shí)現(xiàn)ITextSharp所需的功能。
這是一些示例代碼,如果將來(lái)會(huì)幫助其他人:
protected void Page_Load(object sender, EventArgs e)
{
Document document = new Document();
try
{
PdfWriter.GetInstance(document, new FileStream("c:\\my.pdf", FileMode.Create));
document.Open();
WebClient wc = new WebClient();
string htmlText = wc.DownloadString("http://localhost:59500/my.html");
Response.Write(htmlText);
List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), null);
for (int k = 0; k < htmlarraylist.Count; k++)
{
document.Add((IElement)htmlarraylist[k]);
}
document.Close();
}
catch
{
}
}
- 3 回答
- 0 關(guān)注
- 422 瀏覽
添加回答
舉報(bào)