These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

"Save As" automatically according to pop-up input

guveng
Registered: Sep 8 2010
Posts: 2

Everytime I save documents I need to rename them with a renaming convention depending on what type of document it is. Is there a way to automize this?

e.g. a pop up window can ask several questions

1. enter company name --- free text
2. enter date --- freetext
3. select type --- dropdown

when you click submit the pdf saves and names it self "companyname_date_type.pdf"

Is this possible at all ?

Any other ideas ?

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Yes, it's possible. You'll have to create a folder-level JavaScript that uses the saveAs method in a trusted function, and a custom dialog to prompt the user to enter the data, but it's possible. Have you done much JavaScript programming in Acrobat?
guveng
Registered: Sep 8 2010
Posts: 2
I haven't done Java in Acrobat unfortunately.
mibu1mt
Registered: Mar 3 2011
Posts: 17
George_Johnson wrote:
Yes, it's possible. You'll have to create a folder-level JavaScript that uses the saveAs method in a trusted function, and a custom dialog to prompt the user to enter the data, but it's possible. Have you done much JavaScript programming in Acrobat?
that's what i want to do. is there an example for the issue somwhere?
i have trouble calling my create and save functions from the dialog function..

when i call a trusted save function in the dialog's commit area, i get a raise error.


My Code:
createNewDoc = app.trustedFunction(function(seite) {
app.beginPriv();
var newDoc = app.newDoc();
newDoc.insertPages({
nPage: -1,
cPath: "/c/temp/temp.pdf",
nStart: seite
});
filename = "/C/TEMP/testneu.pdf";
newDoc.deletePages({
nStart:1
});
mySaveAs(newDoc, filename);
app.endPriv();
});

mySaveAs = app.trustedFunction(function(doc,path) {
app.beginPriv();
doc.saveAs(path);
app.endPriv();
});
myNewDoc = app.trustedFunction(function() {
app.beginPriv();
var newDoc = app.newDoc();
return newDoc;
app.endPriv();
});

function dotheDialog(dialog,doc){
dialog.doc = doc;
var retn = app.execDialog( dialog );
}// add a toolbutton "DCT_Backend"
app.addToolButton({
cName: "dct_tool_button1",
cExec: "SaveOnePage();",
cTooltext: "Sichern einer Seite als Produktteil",
cEnable: true,
cLabel: "Eine Seite sichern",
nPos: -1
});

app.addToolButton({
cName: "dct_tool_button2",
cExec: "SaveMultiplePages();",
cTooltext: "Sichern mehrerer Seiten als Produktteil",
cEnable: true,
cLabel: "Mehrere Seiten sichern",
nPos: -1
});

// aktion nachdem button DCT_Backend
function SaveOnePage(){

//hole document eigenschaften
infoArr = new Array();
infoArr[0] = this.metadata;
infoArr[1] = this.documentFileName;
infoArr[2] = this.pageNum;
infoArr[3] = this.path;
infoArr[4] = this.filesize;
infoArr[5] = this.numPages;

//speichern des aktuellen pdf als temporäres pdf
var myFileName = "temp" + ".pdf";
myFileName = "/C/TEMP/" + myFileName;
mySaveAs(this, myFileName);

// erzeuge neues dokument aus aktueller pdf seite
// createNewDoc(infoArr[2]); // hier rummst es
}function SaveMultiplePages(){

//hole document eigenschaften
infoArr = new Array();
infoArr[0] = this.metadata;
infoArr[1] = this.documentFileName;
infoArr[2] = this.pageNum;
infoArr[3] = this.path;
infoArr[4] = this.filesize;
infoArr[5] = this.numPages;

//speichern des aktuellen pdf als temporäres pdf
var myFileName = "temp" + ".pdf";
myFileName = "/C/TEMP/" + myFileName;
mySaveAs(this, myFileName);
dokument = myNewDoc();

var dialog1 = {
initialize: function (dialog) {
// Create a static text containing the current date.
var todayDate = dialog.store()["date"];
//todayDate = "Date: " + util.printd("mmmm dd, yyyy", new Date());
//dialog.load({ "date": todayDate });
},
commit:function (dialog) { // called when OK pressed

var results = dialog.store();
// Now do something with the data collected
var von = results["fnam"] - 1;
var bis = results["lnam"] - 1;
CreateNewDoc(von); // --> Raise Error
},
description:
{
name: "Auswahl der zu speichernden Seiten", // Dialog box title
align_children: "align_left",
width: 350,
height: 200,
elements:
[
{
type: "cluster",
name: "Seitenbereich wählen",
align_children: "align_left",
elements:
[
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "ab Seitenzahl: "
},
{
item_id: "fnam",
type: "edit_text",
alignment: "align_fill",
width: 30,
height: 20
}
]
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "bis Seitenzahl: "
},

{
item_id: "lnam",
type: "edit_text",
alignment: "align_fill",
width: 30,
height: 20
}
]
},
]
},

{
alignment: "align_right",
type: "ok_cancel",
ok_name: "Ok",
cancel_name: "Abbrechen"
}
]
}
};
dotheDialog( dialog1, dokument );
}