|
Best practice is to use the Doc.Catalog.Metadata
property, but occasionally you may find that you need to work with
the old Info store.
This example shows you how you can create and set data in this
store. It requires some knowledge of the Adobe PDF Specification.
See the following for details:.
The ISO PDF Specification, ISO 32000-1:2008 PDF 1.7; Table: 317,
page 550.
The ISO PDF
Specification, ISO 32000-2:2017 PDF 2.0; Table: 349, page 712.
Looking at the specification we can see that the document
properties we want to change are referenced from an entry called
Info in the document trailer. So we create a new PDF dictionary and
reference it from the trailer, then we insert our summary
information into the object, finally we save.
Doc doc = new Doc();
doc.Page = doc.AddPage();
doc.AddText("My first document...");
int theID = doc.AddObject("<< >>");
doc.SetInfo(-1, "/Info:Ref", theID.ToString());
doc.SetInfo(theID, "/Title:Text", "ABCpdf");
doc.SetInfo(theID, "/Author:Text", "WebSupergoo");
doc.SetInfo(theID, "/Subject:Text", "ABCpdf Documentation");
doc.SetInfo(theID, "/Keywords:Text", "ABCpdf,PDF,Docs");
doc.SetInfo(theID, "/Creator:Text", "WebSupergoo");
DateTime theDate = DateTime.Now;
doc.SetInfo(theID, "/CreationDate:Text", theDate);
doc.SetInfo(theID, "/ModDate:Text", theDate);
doc.SetInfo(theID, "/Trapped:Name", "False");
doc.Save(Server.MapPath("docprops.pdf"));
|
|
|