Skip to main content
Participant
March 26, 2024
Question

custom save button

  • March 26, 2024
  • 2 replies
  • 641 views

Hi Everyone. I am making a simple fillable form PDF and I want to put a save button that when pressed it will automatically set the name of the file to what is in the text field "Ebox Work Order Number" and save it to a folder on my network. Is that possible to do at all?

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
March 26, 2024

If the form is for you, or for use on a computer you control, then yes you can. 

Read this article:

https://www.pdfscripting.com/public/How-to-Save-a-PDF-2.cfm

 

Saving is a restricted action in Acrobat.  To save to a specific file name requires a script, which can only be reliably run in Acrobat. So this feature can only be accomplished in Acrobat Pro/Reader on the desktop app, from a privileged script.

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
bebarth
Community Expert
Community Expert
March 26, 2024

Hi,

It's only possible if you write an application script, that means you will have to place a .js file in local on the computer of each user.

@+

Participant
March 26, 2024

even if the PDF form is stored on the network as well?? what would the application script look like? Because right now only 4 people would be filling out the form so I would be able to put that script on each computer.

bebarth
Community Expert
Community Expert
March 29, 2024

Hi,

Sorry, I didn't notice your request!

Attached is an example with this script for the "SAVE AS" button:

if (/^[a-zA-Z0-9]+$/.test(this.getField("orderNumber").value)) {
	try {
		Save_orderNumber(this.path.substr(0,this.path.lastIndexOf("/")+1)+this.getField("orderNumber").value+".pdf");
		this.resetForm();
	} catch(e) {
		this.getField("theScript").display=display.visible;
		app.alert("The \"austin36331818118t.js\" file is not installed on this computer.");
	}
} else app.alert("Please enter a correct Order Number");
this.dirty=false;

For working, you must place a .js file in the JavaScript Acrobat  folder of each computer. You can name it as you want but it must contain this script:

Save_orderNumber=app.trustedFunction(function(newFilePath) {
	app.beginPriv();
	this.saveAs({
		cPath: newFilePath,
		bCopy: true,
		bPromptToOverwrite: true
	});
	app.endPriv();
})

Here, the new file will be saved in the same folder as the original file.

You can modify the condition of your order number or the parameters method.

@+