Search This Blog

iTextSharp and how to add metadata

posted on Saturday, May 3, 2014

Another chapter in the iTextSharp tutorials! It seems that there's a pretty big demand for these kind of tutorials so I'll do my best to add some more in the future. If you're looking for something specific, feel free to let me know and I'll see what I can do ;)

Today I've got something pretty basic lined up for you: metadata!

As you might or might not know, you can add metadata such as author, title, keywords, ... to a PDF file to specify some specifics about who created the file, when and why.

This is a small and simple example but I figured that the iTextSharp newbies might appreciate it, so let's get to it!

To see this metadata, go to File > Properties...

Below you can find a below and after image of the PDFs metadata. To implement this, all you need to do is add one line of code per property you want to change and that's it!!!

Metadata - before
Metadata - after

The code to add, it's all there's to it:

document.AddTitle("iTextSharp PDF Title");
document.AddAuthor("iTextSharp PDF Author");
document.AddSubject("iTextSharp PDF Subject");
document.AddCreator("iTextSharp PDF Creator");
document.AddKeywords("iTextSharp, PDF, keywords");

Note: you can't change the document producer. iText(Sharp) has "hardcoded" this to display it's own name along with the library version. I've noticed that other PDF-editor-platforms (whatever) do the same thing so don't hate on iText for it.

Could be useful :)


  1. If I dont want to show metadata in document property. So how do I need to do?
    If I open pdf document and right click on content select Document Property, I don't want to show to user. Read and Modify metadata in pdf file using iTextsharp in wpf c# VS2012.

    1. Hi Shrikant Jadhav, have you tried emptying these fields?

  2. This comment has been removed by the author.