下面介绍下怎么添加属性,代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
Document doc = new Document();
try
{
PdfWriter.GetInstance(doc, new FileStream(Server.MapPath("Elaine.pdf"), FileMode.Create));
doc.Open();
doc.AddTitle("bestTitle");//标题
doc.AddSubject("TestPDF");//主题
doc.AddKeywords("PDF");//关键字
doc.AddAuthor("Elaine");//作者
doc.AddCreationDate();//创建时间
doc.Add(new Paragraph("Today is my second time to create a PDF!")); //为当前的文档添加内容
}
catch (Exception DOCEx)
{
Response.Write(DOCEx.Message);
}
finally
{
if (doc.IsOpen())
{
doc.Close();
}
}
}
效果图: