Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to add meta information of PDF file using iTextSharp with C-Sharp

In this article, we are going to learn how to add Meta information of PDF file using itextsharp in asp.net with C#. First, you need to download iTextSharp dll from the internet. Click on the link to download https://github.com/itext/itextsharp.

Related article:

How to generate PDF file using iTextSharp in C#.

Once file is downloaded, extract it, now you will find 6 more .rar file. Again extract itextsharp-dll-core.rar file, after that add reference of itextsharp.dll to your project.

In code-behind file:

Add below nampespaces.


using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;

Complete C# code:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AddMetaInfo();
}
}
public void AddMetaInfo()
{
// create filestream object
FileStream fs = new FileStream(Server.MapPath("Example.pdf"), FileMode.Create);

// create document object
Document doc = new Document();

// create PdfWriter instance which will write at file filestream
PdfWriter.GetInstance(doc, fs);

// opening the dociment
doc.Open();

// creating paragraph object
Paragraph para = new Paragraph("Add meta information");
para.Alignment = Element.ALIGN_CENTER;

// Adding meta info
doc.AddTitle("C# iTextSharp");
doc.AddAuthor("ASPArticles.com");
doc.AddSubject("Adding meta information of pdf");
doc.AddKeywords("ASP.Net Articles, iTextSharp, PDF, add Meta Info to PDF");
doc.AddCreator("iTextSharp dll");

// adding pargraph to document
doc.Add(para);

doc.Close();
}

Once pdf file is generated, Open the file-> go to file menu -> click on Properties then you will see the meta information as shown below.



This post first appeared on ASPArticles, please read the originial post: here

Share the post

How to add meta information of PDF file using iTextSharp with C-Sharp

×

Subscribe to Asparticles

Get updates delivered right to your inbox!

Thank you for your subscription

×