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 :)
If I dont want to show metadata in document property. So how do I need to do?
ReplyDeleteIf 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.
Hi Shrikant Jadhav, have you tried emptying these fields?
DeleteThis comment has been removed by the author.
ReplyDelete