Just remember that this is the OLDER (deprecated) metadata form in PDF – you 
should really be looking into XMP.

Leonard

From: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Reply-To: Post here 
<[email protected]<mailto:[email protected]>>
Date: Mon, 16 Jan 2012 03:58:11 -0800
To: Post here 
<[email protected]<mailto:[email protected]>>
Subject: Re: [iText-questions] C # example to Add/Modify metadata to an 
existing PDF file

Figured it out finally.  It may be useful for others.

The following C sharp code will serve both purposes.

public static void ManipulatePdf(String src, String dest)
        {
            PdfReader reader = new PdfReader(src);
            PdfStamper stamper = new PdfStamper(reader, new FileStream(dest, 
FileMode.Create, FileAccess.Write, FileShare.None));
            var info = reader.Info;

            //Existing MetaData Modification
            info["Author"] = "XXXXX";
            info["Title"] = "XXXXX";
            info["Keywords"] = "XXXXX";
            info["Subject"] = "XXXXX";

     //Custom MetaData Addition
            info.Add("Mykey1", "myValue1");
            info.Add("Mykey2", "myValue2");
            info.Add("Mykey3", "myValue3");
            info.Add("Mykey4", "myValue4");

                            stamper.MoreInfo = info;
            //Very imp. Without this flag custom metadata won’t be added.
            stamper.FormFlattening = true;
            stamper.Close();
        }

Regards
-Saurabh

From: Kumar5, Saurabh - Dell Team
Sent: Friday, January 13, 2012 11:29 AM
To: 
'[email protected]<mailto:'[email protected]>'
Subject: C # example to Add/Modify metadata to an existing PDF file

Hi,

Could you please send some  c Sharp examples which does the following.


1.       Modify Existing metadata like Author etc.

2.       Add New Metadata like CustomMessage etc.




Regards
-Saurabh
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to