Skip to main content
Participating Frequently
February 6, 2025
Question

save an attachment in a specific name with script.

  • February 6, 2025
  • 3 replies
  • 365 views

Goodmorning,
I have created a button with a script that saves the last page and send it as an attachment

 

var d = this.extractPages(this.pageNum);
d.mailDoc({cTo: "test@gmail.nl", cSubject: "Information" + (this.pageNum+1) + " from " + this.documentFileName, bUI: false});
d.closeDoc(true);

 

The only thing i can't figure out is how to save the attachment in a specific name.

Does anybody has an idea how i can add this ?

And is it possible to add textfields from within the pdf file to the file name ?

For example mut-Text15 


Thank you very much for youre help !

3 replies

try67
Community Expert
Community Expert
February 14, 2025

To be able to do it you would need to install a script file on the local computer of each user. Can you do that?

try67
Community Expert
Community Expert
February 14, 2025

PS. I hope you know this is not going to work in Reader, only in Acrobat...

Adobe Employee
February 14, 2025

Hi Marten,

 

When a file attachment is imported using the importDataObject method, the value of its Data.name property is assigned by that method’s cName parameter. However, when a file is attached using the UI, its name is automatically assigned. The attachments are assigned the sequential names “Untitled Object”, “Untitled Object 2”, “Untitled Object 3”, and so on.

This is how you can assign name to attachment:
this.exportDataObject({ cName: "MyPDF.pdf", nLaunch: 2 });

 

Let us know if it helps or not.

 

Thanks

Sanchi

Bernd Alheit
Community Expert
Community Expert
February 6, 2025

Try the forum for Adobe Acrobat.