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

Dokumentseite mithilfe von Dialog (execDialog) speichern

mibu1mt
Registered: Mar 3 2011
Posts: 17
Answered

Hallo,
 
folgende Zielstellung.
Ich möchte bestimmte Seiten eines PDF's an einem bestimmten Ort abspeichern.
Die benötigten Seiten sowie den Ort möchte ich auch aus einem Dialog heraus dyamisch abfragen. Der Dialog und die zugehörige Funktion wird mithilfe des Buttons DCT_backend2 generiert.
 
Problem: Wie verarbeite ich die dynamischen Daten aus dem Dialog richtig?
 
Ich habe mir bereits trustedFunction 'mySaveAs' 'myNewDoc' gebaut, die normalerweise funktionieren. Allerdings kann ich innerhalb der commit-Function des Dialogs diese Funktionen nicht aufrufen.. Erhalte einen raiseError, der sagt man müsse erst einen Vorgang beenden.
 
Mein Code soweit: (folder-level .js datei)
 
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(doc) {
app.beginPriv();
var newDoc = app.newDoc();
return newDoc;
app.endPriv();
});
 
app.addToolButton({
cName: "dct_tool_button2",
cExec: "SaveMultiplePages();",
cTooltext: "Sichern mehrerer Seiten als Produktteil",
cEnable: true,
cLabel: "Mehrere Seiten sichern",
nPos: -1
});
 
// aktion button DCT_Backend
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);

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) {
 
var results = dialog.store();
var von = results["fnam"] - 1;
var bis = results["lnam"] - 1;
 
createNewDoc(); // HIER ENTSTEHT DER FEHLER
 
},
 
description:
 
........
 
};

app.execDialog(dialog1);

}

My Product Information:
Acrobat Pro 10.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You did not specify the "seite" parameter.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

mibu1mt
Registered: Mar 3 2011
Posts: 17
funktioniert auch nicht mit paramterübergabe:

Code: createNewDoc(von);

Fehlermeldung:
*
RaiseError: Diese Datei kann nicht geöffnet werden, da in Acrobat noch ein Vorgang läuft. Beenden Sie den Vorgang in Acrobat, bevor Sie diese Datei öffnen.Error()@:0
(0)@App:Exec:3
([object ADMDialog])@App:Exec:100
execDialog([object Object])@:0
SaveMultiplePages()@App:Exec:200
@App:Exec:1
*

RaiseError in english:
This file cannot be opened, because there's a progress running in acrobat. Close process in Acrobat before you open this file.

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Why are you calling createNewDoc() from within the dialog?
I suggest you do it after the dialog has closed.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

mibu1mt
Registered: Mar 3 2011
Posts: 17
because i need variables 'von' and 'bis' from dialog input..
how to get them outside the dialog function? usually this functions just returns "ok" or "cancel"...

try67
Expert
Registered: Oct 30 2008
Posts: 2398
You use the dialog.store() command in the dialog's commit method to get an array of the input values, which you can then assign to variables that you declared *outside* of the dialog.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

mibu1mt
Registered: Mar 3 2011
Posts: 17
yes, i have these input values stored in variables inside the dialog (vars : von,bis)

i need them outside the dialog! because inside the dialog i cannot call function createNewDoc.

outside the dialog it is possible to call the function.


ps: if you have a better approach to store pdf files with dynamic user input, please tell me..

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
Place this outside of the dialog:

var von;
var bis;

And then this inside of it:

von = results["fnam"] - 1;
bis = results["lnam"] - 1;

Then you will be able to use them after the dialog closes.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Edit: I thought you were asking the user for their name, but I see now that you're asking for a page range.
You can do it using two app.response() commands, like so:

var firstPage = app.response("Enter the first page number:","");
var lastPage = app.response("Enter the last page number:","");

It's not as nice as a dialog, but it's much easier to code.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

mibu1mt
Registered: Mar 3 2011
Posts: 17
Thank you very very much, both options are working.

MfG, Michael