公司里面用的iTextSharp(教程)---关于PDF的属性设置

下面介绍下怎么添加属性,代码如下:

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();
                }
            }
 
        }

效果图:

image

作者:Elaine
交流QQ:392989505
原文地址:https://www.cnblogs.com/ITGirl00/p/3473675.html