Karan Karan - 1 year ago 151
ASP.NET (C#) Question

iTextSharp .NET PDF - unable to change PDF Producer

I am using iTextSharp product to change the PDF properties as follows.
I am unable to change the "PDF Producer" property at all. Please suggest, where am i getting wrong.

The code line
info["Producer"] = "My producer";

is not working as it should be.

string sourcePath = tbPath.Text;
IList<string> dirs = null;
string pdfName = string.Empty;
string OutputPath = string.Empty;

DirectoryInfo di = new DirectoryInfo(sourcePath);
DirectoryInfo dInfo = Directory.CreateDirectory(sourcePath + "\\" + "TempDir");

OutputPath = Path.Combine(sourcePath,"TempDir");

dirs = Directory.GetFiles(di.FullName, "*.pdf").ToList();

for (int i = 0; i <= dirs.Count - 1; i++)
PdfReader pdfReader = new PdfReader(dirs[i]);
using (FileStream fileStream = new FileStream(Path.Combine(OutputPath, Path.GetFileName(dirs[i])),

PdfStamper pdfStamper = new PdfStamper(pdfReader, fileStream);

Dictionary<string, string> info = pdfReader.Info;
info["Title"] = "";
info["Author"] = "";
info["Producer"] = "My producer"; ////THIS IS NOT WORKING..

pdfStamper.MoreInfo = info;


Answer Source

You can only change the producer line if you have a license key. A license key needs to be purchased from iText Software. Instructions on how to apply the license key are sent along with that key.

If you want to use iText for free, you can't change the producer line. See the license header of every file in the open source version of iText:

 * In accordance with Section 7(b) of the GNU Affero General Public License,
 * a covered work must retain the producer line in every PDF that is created
 * or manipulated using iText.

For your info: iText Group has successfully sued a German company that changed the producer line without purchasing a license. You can find some documents related to this case here: IANAL: What developers should know about IP and Legal (slide 57-62)

By the way, I won a JavaOne Rockstar award with this talk: https://twitter.com/itext/status/704278659012681728

enter image description here

Summarized: if you don't have a commercial license for iText, you can not legally change the producer line in iText. If you have a commercial license, you need to apply the license key.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download