4
Creating and Modifying PDF Documents
Creating and Modifying PDF Files
Creating and Modifying PDF Files
Acrobat JavaScript provides support for dynamic PDF file creation and content generation.
This means that it is possible to dynamically create a new PDF file and modify its contents in
an automated fashion. This can help make a document responsive to user input and
enhance the workflow process.
To create a new PDF file, invoke the
app
object’s
newDoc()
method, as shown in the
example below:
var myDoc = app.newDoc();
Once this statement has been executed, you may add content by invoking methods
contained within the
doc
object, as indicated below in
Table 4.1:
T
ABLE
4.1
Acrobat JavaScript Usage for Creating Content in a PDF Document
Content
page
page
annot
field
icon
link
Object
Methods
doc
template
doc
doc
doc
doc
newPage, insertPages,
replacePages
spawn
addAnnot
addField
addIcon
addLink
addScript
addThumbnails
createChild,
insertChild
addWebLinks
createTemplate
document-level
doc
JavaScript
thumbnails
bookmark
web link
template
doc
doc.bookmarkRoot
doc
doc
68
Acrobat JavaScript Scripting Guide