ipetduckies
ipetduckies

Reputation: 21

Linking a FileAttachment Annotation to the File

As the title suggests I'm trying to understand how to link a FileAttachment annotation with the actual file in javasacript. There are no properties that do this while I'm performing the addAnnot function. So after I've used addAnnot to create the annotation how would I link it to open an actual file?

Appreciate the help

Upvotes: 0

Views: 548

Answers (1)

joelgeraci
joelgeraci

Reputation: 4917

Something like this but with a few caveats. First, you need to use a device independent path to the PDF, you can find out more in the Acrobat JS reference. Also, if you want to attach the file without user interaction, the script must be in a privileged context. Again, more on that in the JS reference. If you want the user to be able to select the file, leave cAttachmentPath empty and they'll get a file selection dialog. Note: Many file types like executables, .js, etc. can be attached but then not extracted by Acrobat or Reader for security reasons.

var annot = this.addAnnot({
    page: 0,
    type: "FileAttachment",
    point: [0,0],
    cAttachmentPath: "/c/temp/foo.pdf"
 });

Upvotes: 1

Related Questions