This example shows how to insert document properties. Document properties can be viewed from Acrobat Reader and most commonly provide information on the document Title and Author.

This example requires some knowledge of the Adobe PDF Specification. Section 9.2.1 of the document details the way in which document properties are stored. Section 3.8.2 of the document details the way that dates are specified within PDF documents.

 

   
Src
 
     

First we create an ABCpdf Doc object and add some simple content.

Set theDoc = Server.CreateObject("ABCpdf3.Doc")
theDoc.Page = theDoc.AddPage()
theDoc.AddText "My first document..."

 

   
Dest
 
     

Looking at the Adobe PDF Specification we can see that the document properties we want to change are referenced from an entry called "/Info" in the document trailer. So our first step is to create a new PDF dictionary and reference it from the this entry.

theID = theDoc.AddObject("<< >>")
theDoc.SetInfo -1, "/Info:Ref", theID

 

   
Add
 
     

Now we have to insert our summary information into the object we've just added. Dates are generally specified as strings in the format "D:YYYYMMDD" but for our purposes we'll just include the year.

theDoc.SetInfo theID, "/Title:Text", "ABCpdf"
theDoc.SetInfo theID, "/Author:Text", "WebSupergoo"
theDoc.SetInfo theID, "/Subject:Text", "ABCpdf Documentation"
theDoc.SetInfo theID, "/Keywords:Text", "ABCpdf,PDF,Docs"
theDoc.SetInfo theID, "/Creator:Text", "WebSupergoo"
theDoc.SetInfo theID, "/Producer:Text", "WebSupergoo"
theDoc.SetInfo theID, "/CreationDate:Text", "D:2003"
theDoc.SetInfo theID, "/ModDate:Text", "D:2003"
theDoc.SetInfo theID, "/Trapped:Name", "False"

 

   
Save
 
     

Finally we save.

theDoc.Save "c:\mypdfs\docprops.pdf"

 

   

 

Browser Based Help. Published by chm2web software.