Skip to main content
Participating Frequently
April 2, 2019
Question

HelIo, I have an Attachment button but I would like the attachment name to show in a text box. The attachment is mandatory but I'm not sure how to do this. Can you help me please? Thank you. JB.

  • April 2, 2019
  • 1 reply
  • 623 views

HelIo, I have an Attachment button but I would like the attachment name to show in a text box. The attachment is mandatory but I'm not sure how to do this. Can you help me please? Thank you. JB.

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
April 2, 2019

There are a couple of ways to do this. For example, put this code in a folder level script.

this.getField("AttachName").value = dataObjects[0].name;

This code puts the "name" of the first attachment into a field named "AttachName".

You'll need to change the field name to match the one on your PDF.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
JaybrewcaAuthor
Participating Frequently
April 3, 2019

Hello Thom,

     Tank you for your response. Forgive my ignorance but, I Don't know what you mean by "Folder level " script. Could you enlighten me?

John

Thom Parker
Community Expert
Community Expert
April 3, 2019

My bad, I meant Document Level Script. These scripts are run when the PDF is opened, so that the attachment name is always refreshed. Here's an article on it.

Basic Document Level (Document Open) Scripts

If a script is used to add the attachment, then another way to do this is to place the name into the field in the same script that adds it.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often