Sei sulla pagina 1di 779

bb c

JavaScriptfor Acrobat® API Reference

May 2015

Adobe® Acrobat® DC SDK

Adobe® Acrobat® DC SDK JavaScript™ for Acrobat API Reference for Microsoft® Windows® and Mac OS®

Edition 1.0, May 2015

If this guide is distributed with software that includes an end user agreement, this guide, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written permission of Adobe Systems Incorporated. Please note that the content in this guide is protected under copyright law even if it is not distributed with software that includes an end user license agreement.

The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies that may appear in the informational content contained in this guide.

Please remember that existing artwork or images that you may want to include in your project may be protected under copyright law. The unauthorized incorporation of such material into your new work could be a violation of the rights of the copyright owner. Please be sure to obtain any permission required from the copyright owner.

Any references to company names, company logos and user names in sample material or sample forms included in this documentation and/or software are for demonstration purposes only and are not intended to refer to any actual organization or persons.

Adobe, the Adobe logo, Acrobat, Distiller, FrameMaker, LiveCycle, PostScript and Reader are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries.

Apple and Mac OS are trademarks of Apple Computer, Inc., registered in the United States and other countries.

JavaScript is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries.

Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

All other trademarks are the property of their respective owners.

Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.

Notice to U.S. Government End Users. The Software and Documentation are “Commercial Items,” as that term is defined at 48 C.F.R. §2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as such terms are used in 48 C.F.R. §12.212 or 48 C.F.R. §227.7202, as applicable. Consistent with 48 C.F.R. §12.212 or 48 C.F.R. §§227.7202-1 through 227.7202-4, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (a) only as Commercial Items and (b) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished-rights reserved under the copyright laws of the United States. Adobe Systems Incorporated, 345 Park Avenue, San Jose, CA 95110-2704, USA. For U.S. Government End Users, Adobe agrees to comply with all applicable equal opportunity laws including, if appropriate, the provisions of Executive Order 11246, as amended, Section 402 of the Vietnam Era Veterans Readjustment Assistance Act of 1974 (38 USC 4212), and Section 503 of the Rehabilitation Act of 1973, as amended, and the regulations at 41 CFR Parts 60-1 through 60-60, 60-250, and 60-741. The affirmative action clause and regulations contained in the preceding sentence shall be incorporated by reference.

Contents

Contents

1 Preface

1

What’s in this guide?

1

Who should read this guide?

1

Related documentation

1

Syntax

1

Paths

2

Safe path

2

Privileged context

2

Privileged versus non-privileged context

2

User preferences

3

Quick bars

3

Domain names in code samples

5

1 JavaScript API

1

Alerter

 

2

Alerter methods

2

dispatch

2

AlternatePresentation

5

AlternatePresentation properties

5

active

5

type

5

AlternatePresentation methods

5

start

6

stop

6

annotAttachment

7

annotAttachment properties

7

contentStream

7

creationDate

8

MIMEtype

8

modDate

8

name

8

pathname

9

size

9

Annotation

10

Annotation

types

10

Annotation

properties

12

alignment

13

attachment

14

AP

14

arrowBegin

15

arrowEnd

16

attachIcon

16

author

17

borderEffectIntensity

17

borderEffectStyle

18

callout

18

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

4

cAttachmentPath

18

caretSymbol

19

contents

19

creationDate

20

dash

20

delay

21

doc

21

doCaption

22

fillColor

22

gestures

23

hidden

23

inReplyTo

24

intent

24

leaderExtend

25

leaderLength

25

lineEnding

25

lock

26

modDate

26

name

27

noteIcon

27

noView

28

opacity

28

overlayText

29

page

29

point

30

points

31

popupOpen

31

popupRect

32

print

32

quads

32

rect

33

readOnly

33

refType

33

repeat

34

richContents

34

richDefaults

35

rotate

36

seqNum

36

soundIcon

36

state

37

stateModel

37

strokeColor

37

style

38

subject

38

textFont

39

textSize

39

toggleNoView

40

type

40

vertices

41

width

41

Annotation methods

42

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

5

destroy

42

getProps

42

getStateInModel

43

setProps

44

transitionToState

44

AnnotRichMedia

46

AnnotRichMedia properties

46

activated

46

context3D

46

name

47

page

47

rect

47

subtype

47

AnnotRichMedia methods

48

callAS

48

Annot3D

50

Annot3D properties

50

activated

50

context3D

50

innerRect

51

name

51

page

51

rect

51

app

53

app properties

53

activeDocs

53

calculate

54

constants

54

focusRect

55

formsVersion

55

fromPDFConverters

55

fs

56

fullscreen

56

language

57

media

57

monitors

58

numPlugIns

58

openInPlace

59

platform

59

plugIns

59

printColorProfiles

60

printerNames

60

runtimeHighlight

61

runtimeHighlightColor

61

thermometer

61

toolbar

62

toolbarHorizontal

62

toolbarVertical

62

viewerType

63

viewerVariation

63

viewerVersion

64

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

6

app methods

64

addMenuItem

64

addSubMenu

66

addToolButton

67

alert

69

beep

71

beginPriv

71

browseForDoc

71

clearInterval

73

clearTimeOut

73

endPriv

73

execDialog

74

execMenuItem

87

getNthPlugInName

90

getPath

90

goBack

91

goForward

92

hideMenuItem

92

hideToolbarButton

92

launchURL

93

listMenuItems

93

listToolbarButtons

94

loadPolicyFile

95

mailGetAddrs

95

mailMsg

96

newDoc

97

newCollection

99

newFDF

99

openDoc

100

openFDF

102

popUpMenu

103

popUpMenuEx

103

removeToolButton

105

response

105

setInterval

106

setTimeOut

107

trustedFunction

108

trustPropagatorFunction

111

app.media

116

app.media properties

116

align

116

canResize

117

closeReason

117

defaultVisible

118

ifOffScreen

118

layout

119

monitorType

119

openCode

120

over

120

pageEventNames

121

raiseCode

122

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

7

raiseSystem

122

renditionType

122

status

123

trace

123

version

124

windowType

124

app.media methods

124

addStockEvents

125

alertFileNotFound

125

alertSelectFailed

126

argsDWIM

126

canPlayOrAlert

127

computeFloatWinRect

127

constrainRectToScreen

128

createPlayer

128

getAltTextData

130

getAltTextSettings

131

getAnnotStockEvents

132

getAnnotTraceEvents

132

getPlayers

132

getPlayerStockEvents

133

getPlayerTraceEvents

133

getRenditionSettings

134

getURLData

134

getURLSettings

135

getWindowBorderSize

136

openPlayer

136

removeStockEvents

138

startPlayer

138

Bookmark

139

Bookmark properties

139

children

139

color

139

doc

140

name

140

open

141

parent

141

style

141

Bookmark methods

142

createChild

142

execute

142

insertChild

143

remove

143

setAction

144

catalog

145

catalog properties

145

isIdle

145

jobs

145

catalog methods

145

getIndex

146

remove

146

CatalogJob

147

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

8

CatalogJob properties

147

path

147

type

147

status

147

Certificate

149

Certificate properties

149

binary

149

issuerDN

149

keyUsage

150

MD5Hash

150

privateKeyValidityEnd

150

privateKeyValidityStart

151

SHA1Hash

151

serialNumber

151

subjectCN

151

subjectDN

152

ubRights

152

usage

153

validityEnd

154

validityStart

155

Collab

156

Collab methods

156

addStateModel

156

documentToStream

157

removeStateModel

157

color

158

Color arrays

158

color properties

158

color methods

159

convert

159

equal

160

colorConvertAction

161

colorConvertAction properties

161

action

161

alias

161

colorantName

162

convertIntent

162

convertProfile

162

embed

163

isProcessColor

163

matchAttributesAll

163

matchAttributesAny

164

matchIntent

165

matchSpaceTypeAll

165

matchSpaceTypeAny

166

preserveBlack

167

useBlackPointCompensation

167

Collection

168

Collection properties

168

fields

168

initialDoc

168

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

9

initialView

169

Collection methods

169

addField

169

getField

170

removeField

171

collectionField

172

collectionField properties

172

name

172

order

172

readOnly

173

sort

173

text

174

type

174

console

175

console methods

175

clear

175

hide

175

println

175

show

176

Data

177

Data properties

177

creationDate

177

description

177

MIMEType

178

modDate

178

name

178

path

178

size

179

Data methods

179

getFieldValue

179

setFieldValue

179

dbg

181

dbg properties

181

bps

181

dbg methods

182

c

182

cb

182

q

182

sb

182

si

183

sn

184

so

184

sv

184

Dialog

185

Dialog methods

185

enable

185

end

185

load

186

store

186

DirConnection

187

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

10

canList

187

canDoCustomSearch

187

canDoCustomUISearch

188

canDoStandardSearch

188

groups

188

name

189

uiName

189

DirConnection methods

189

search

189

setOutputFields

191

Directory

193

Directory properties

193

info

193

Directory methods

195

connect

195

Doc

197

Doc properties

197

alternatePresentations

198

author

199

baseURL

199

bookmarkRoot

200

calculate

200

collection

200

creationDate

201

creator

201

dataObjects

201

delay

202

dirty

202

disclosed

203

docID

204

documentFileName

204

dynamicXFAForm

204

external

205

filesize

205

hidden

206

hostContainer

206

icons

207

info

207

innerAppWindowRect

209

innerDocWindowRect

209

isModal

210

keywords

210

layout

210

media

211

metadata

211

modDate

213

mouseX

213

mouseY

214

noautocomplete

214

numFields

215

numPages

215

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

11

numTemplates

216

path

216

outerAppWindowRect

216

outerDocWindowRect

217

pageNum

217

pageWindowRect

217

permStatusReady

218

producer

218

requiresFullSave

218

securityHandler

219

selectedAnnots

219

sounds

220

spellDictionaryOrder

220

spellLanguageOrder

221

subject

221

templates

221

title

222

URL

222

viewState

222

xfa

224

XFAForeground

225

zoom

226

zoomType

226

Doc methods

227

addAnnot

228

addField

229

addIcon

231

addLink

231

addRecipientListCryptFilter

232

addRequirement

233

addScript

235

addThumbnails

235

addWatermarkFromFile

235

addWatermarkFromText

237

addWeblinks

239

applyRedactions

240

bringToFront

241

calculateNow

241

certifyInvisibleSign

241

closeDoc

242

colorConvertPage

243

createDataObject

244

createTemplate

245

deletePages

246

deleteSound

246

embedDocAsDataObject

246

embedOutputIntent

247

encryptForRecipients

247

encryptUsingPolicy

249

exportAsFDF

252

exportAsFDFStr

253

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

12

exportAsText

254

exportAsXFDF

254

exportAsXFDFStr

255

exportDataObject

256

exportXFAData

258

extractPages

259

flattenPages

260

getAnnot

261

getAnnotRichMedia

261

getAnnot3D

262

getAnnots

262

getAnnotsRichMedia

263

getAnnots3D

264

getColorConvertAction

264

getDataObject

265

getDataObjectContents

265

getField

266

getIcon

267

getLegalWarnings

268

getLinks

272

getNthFieldName

272

getNthTemplate

273

getOCGs

273

getOCGOrder

273

getPageBox

274

getPageLabel

274

getPageNthWord

275

getPageNthWordQuads

275

getPageNumWords

276

getPageRotation

276

getPageTransition

277

getPreflightAuditTrail

277

getPrintParams

277

getSound

278

getTemplate

278

getURL

279

getUserUnitSize

279

gotoNamedDest

280

importAnFDF

281

importAnXFDF

281

importDataObject

281

importIcon

282

importSound

283

importTextData

284

importXFAData

285

insertPages

286

mailDoc

286

mailForm

287

movePage

288

newPage

288

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

13

preflight

290

print

291

removeDataObject

292

removeField

293

removeIcon

293

removeLinks

293

removePreflightAuditTrail

294

removeRequirement

294

removeScript

294

removeTemplate

295

removeThumbnails

295

removeWeblinks

296

replacePages

296

resetForm

297

saveAs

297

scroll

300

selectPageNthWord

300

setAction

301

setDataObjectContents

302

setOCGOrder

303

setPageAction

303

setPageBoxes

304

setPageLabels

304

setPageRotations

305

setPageTabOrder

306

setPageTransitions

306

spawnPageFromTemplate

307

submitForm

308

syncAnnotScan

313

timestampSign

314

validatePreflightAuditTrail

314

Doc.media

316

Doc.media properties

316

canPlay

316

Doc.media methods

317

deleteRendition

318

getAnnot

318

getAnnots

319

getOpenPlayers

319

getRendition

320

newPlayer

320

Embedded PDF

322

Embedded PDF properties

322

messageHandler

322

Embedded PDF methods

323

postMessage

323

Error

324

Error properties

325

fileName

325

lineNumber

325

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

14

 

message

326

name

326

Error methods

326

toString

326

event

327

 

Event type/name combinations

327

App/Init

327

Batch/Exec

327

Bookmark/Mouse Up

328

Console/Exec

328

Doc/DidPrint

328

Doc/DidSave

328

Doc/Open

328

Doc/WillClose

329

Doc/WillPrint

329

Doc/WillSave

329

External/Exec

329

Field/Blur

329

Field/Calculate

330

Field/Focus

330

Field/Format

330

Field/Keystroke

331

Field/Mouse Down

331

Field/Mouse Enter

332

Field/Mouse Exit

332

Field/Mouse Up

332

Field/Validate

332

Link/Mouse Up

333

Menu/Exec

333

Page/Open

333

Page/Close

333

Screen/Blur

334

Screen/Close

334

Screen/Focus

334

Screen/InView

334

Screen/Mouse Down

335

Screen/Mouse Enter

335

Screen/Mouse Exit

335

Screen/Mouse Up

335

Screen/Open

336

Screen/OutView

336

Document Event Processing

336

Form event processing

337

Multimedia event processing

337

event properties

338

change

338

Example

338

changeEx

338

commitKey

340

fieldFull

340

keyDown

341

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

15

modifier

341

name

342

rc

342

richChange

343

richChangeEx

343

richValue

344

selEnd

345

selStart

346

shift

346

source

346

target

347

targetName

347

type

348

value

348

willCommit

349

EventListener

350

EventListener methods

350

afterBlur

351

afterClose

351

afterDestroy

352

afterDone

352

afterError

352

afterEscape

353

afterEveryEvent

353

afterFocus

354

afterPause

354

afterPlay

354

afterReady

355

afterScript

356

afterSeek

357

afterStatus

357

afterStop

358

onBlur

358

onClose

358

onDestroy

359

onDone

359

onError

360

onEscape

360

onEveryEvent

360

onFocus

361

onGetRect

361

onPause

362

onPlay

362

onReady

362

onScript

362

onSeek

363

onStatus

363

onStop

364

Events

365

Events methods

365

add

365

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

16

 

dispatch

366

remove

367

FDF

368

 

FDF properties

368

deleteOption

368

isSigned

368

numEmbeddedFiles

369

FDF methods

369

addContact

369

addEmbeddedFile

370

addRequest

371

close

371

mail

372

save

372

signatureClear

373

signatureSign

373

signatureValidate

374

Field

376

 

Field versus widget attributes

377

Field properties

378

alignment

378

borderStyle

379

buttonAlignX

379

buttonAlignY

380

buttonFitBounds

381

buttonPosition

381

buttonScaleHow

382

buttonScaleWhen

382

calcOrderIndex

383

charLimit

383

comb

384

commitOnSelChange

385

currentValueIndices

385

defaultStyle

386

defaultValue

388

doNotScroll

388

doNotSpellCheck

388

delay

389

display

389

doc

390

editable

390

exportValues

391

fileSelect

392

fillColor

392

hidden

393

highlight

393

lineWidth

394

multiline

395

multipleSelection

395

name

395

numItems

396

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

17

page

396

password

397

print

398

radiosInUnison

398

readonly

398

rect

399

required

400

richText

400

richValue

401

rotation

402

strokeColor

403

style

404

submitName

404

textColor

405

textFont

405

textSize

407

type

407

userName

408

value

408

valueAsString

409

Field methods

409

browseForFileToSubmit

410

buttonGetCaption

410

buttonGetIcon

411

buttonImportIcon

411

buttonSetCaption

412

buttonSetIcon

413

checkThisBox

414

clearItems

414

defaultIsChecked

415

deleteItemAt

415

getArray

416

getItemAt

416

getLock

417

insertItemAt

417

isBoxChecked

418

isDefaultChecked

418

setAction

419

setFocus

420

setItems

420

setLock

421

signatureGetModifications

422

signatureGetSeedValue

423

signatureInfo

424

signatureSetSeedValue

425

signatureSign

433

signatureValidate

435

FullScreen

437

FullScreen properties

437

backgroundColor

437

clickAdvances

437

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

18

cursor

437

defaultTransition

438

escapeExits

438

isFullScreen

439

loop

439

timeDelay

439

transitions

440

usePageTiming

440

useTimer

441

global

442

Creating global properties

442

Deleting global properties

442

Global object security policy

443

global methods

443

setPersistent

444

subscribe

444

HostContainer

446

HostContainer properties

446

messageHandler

446

HostContainer methods

448

postMessage

448

Icon

449

Icon Stream

450

identity

451

identity properties

451

corporation

451

email

451

loginName

451

name

452

Index

453

Index properties

453

available

453

name

453

path

454

selected

454

Index methods

454

build

454

Link

456

Link properties

456

borderColor

456

borderWidth

456

highlightMode

456

rect

457

Link methods

457

setAction

457

Marker

458

Marker properties

458

frame

458

index

458

name

458

time

459

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

19

Markers

460

Markers properties

460

player

460

Markers methods

460

get

460

MediaOffset

462

MediaOffset properties

462

frame

462

marker

462

time

463

MediaPlayer

464

MediaPlayer properties

464

annot

464

defaultSize

464

doc

465

events

465

hasFocus

465

id

466

innerRect

466

isOpen

467

isPlaying

467

markers

467

outerRect

468

page

468

settings

469

uiSize

469

visible

470

MediaPlayer methods

470

close

470

open

471

pause

471

play

472

seek

472

setFocus

473

stop

474

triggerGetRect

474

where

475

MediaReject

476

MediaReject properties

476

rendition

476

MediaSelection

477

MediaSelection properties

477

selectContext

477

players

478

rejects

478

rendition

478

MediaSettings

480

MediaSettings properties

480

autoPlay

480

baseURL

480

bgColor

481

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

20

bgOpacity

481

data

481

duration

482

endAt

483

floating

483

layout

484

monitor

485

monitorType

485

page

486

palindrome

486

players

487

rate

487

repeat

488

showUI

488

startAt

489

visible

489

volume

490

windowType

490

Monitor

492

Monitor properties

492

colorDepth

492

isPrimary

492

rect

493

workRect

493

Monitors

494

Monitors methods

494

bestColor

494

bestFit

495

desktop

495

document

496

filter

496

largest

497

leastOverlap

497

mostOverlap

497

nonDocument

498

primary

498

secondary

499

select

499

tallest

499

widest

500

Net

501

Net properties

501

SOAP

501

Discovery

502

HTTP

502

Net methods

502

Net.HTTP

504

Net.HTTP methods

504

request

504

OCG

508

Adobe Acrobat SDK

JavaScript™ for Acrobat® API Reference

21

constants

508

initState

509

locked

509

name

509

state

510

OCG methods

510

getIntent

510

setAction

511

setIntent

511

PlayerInfo

513

PlayerInfo properties

513

id

513

mimeTypes

513

name

514

version

514

PlayerInfo methods

514

canPlay

514

canUseData

515

honors

515

PlayerInfoList