Setting PDF properties

123 views
Skip to first unread message

David

unread,
Feb 22, 2011, 7:46:10 AM2/22/11
to PDFTron PDFNet SDK
Hi there,

I'm trying to remove the properties from a PDF, been through the
example code and it all seems to be fine...except after saving and
opening the file the properties are still there, code I'm using is:

PDFNet.Initialize();
PDFDoc d = new PDFDoc(fileName);
d.InitSecurityHandler();

PDFDocInfo docInfo = d.GetDocInfo();
docInfo.SetAuthor("");
docInfo.SetCreationDate(new Date());
docInfo.SetCreator("");
docInfo.SetKeywords("");
docInfo.SetModDate(new Date());
docInfo.SetProducer("");
docInfo.SetSubject("");
docInfo.SetTitle("");

d.Save(GetCleanedName(fileName, "PropertiesRemoved"),
pdftron.SDF.SDFDoc.SaveOptions.e_linearized);
d.Close();


The above works fine if I create a new pdf programatically, however
with a precreated file the changes are not saved.

Sample problematic pdf here:
http://www.filefactory.com/file/c46748a/n/RemoveProperties.pdf

Support

unread,
Feb 22, 2011, 2:13:34 PM2/22/11
to PDFTron PDFNet SDK
The most likely problem is that this file also contains an XMP
metadata steam. You could remove the XMP stream as follows:
doc.GetRoot().Erase("Metadata");

David

unread,
Feb 23, 2011, 5:47:43 AM2/23/11
to PDFTron PDFNet SDK
That works, many thanks!
Reply all
Reply to author
Forward
0 new messages