iTextSharp应用,生成pdf
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
public void PDF(string html)
{
Document dom = new Document(); //创建文档
PdfWriter.GetInstance(dom, new FileStream(Server.MapPath("test") + Guid.NewGuid() + ".pdf", FileMode.Create));//初始化写入流
BaseFont bf = BaseFont.CreateFont(@"C:\Windows\Fonts\STZHONGS.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED) \\设置字体
Font font = new Font(bf, 20);
dom.Open(); //打开文档
dom.Add(new Paragraph(html, font)) \\写入内容
dom.Close(); //关闭文档
}