Auch wenn das Beispiel schon gut funktionierte, war mir der Aufbau immer noch etwas zu kompliziert, daher habe ich eine neue Version entworfen.
Das Beispiel zeigt 4 Möglichkeiten ein Formular zu speichern.
Long ago I've posted a sample to demonstrate how you can save forms with new file names in desired directories.
Weell, even if the sample was working I always felt a bit unsatisfied with its structure so I I've designed a new version.
It show 4 methods to save a form.
Folder Level Script – JavaScript
var lcbSaveAs = app.trustedFunction( function (vDoc, vPath) { app.beginPriv(); vDoc.saveAs({cPath: vPath}); app.endPriv(); });
Funktion zum Speichern mittels Folder Level Script
//
Function to save through folder level script
function lcbSave (vDoc, vPath, vCurrentName, vDefaultName) { if (vCurrentName === vDefaultName) { try { event.target.lcbSaveAs(vDoc, vPath); xfa.host.messageBox("File was saved under:\r\r" + vPath.toUpperCase(), "File Saved", 3, 0); xfa.form.execInitialize(); } catch (error) { xfa.host.messageBox(error.toString().replace("RaiseError: ", "") + "\r\rEnsure the destination folder exists and there isn't already a file with the same file name in that folder!\n\n" + error, "Failed to save file", 0, 0); } } else { app.execMenuItem("SaveAs"); } }
//
Script to create save path in sub folder (just one of the methodes)
var vSlash = "/", vNewName = Topic1.Variables.FormName.rawValue, vNewPath = Topic1.Variables.CurrentPath.rawValue, vSubfolder = Topic1.Variables.Subfolder.rawValue, vCurrentName = event.target.documentFileName, vCurrentPath = event.target.path, vDefaultName = vDefaultFileName.value, vSeparator = Topic1.Variables.Separator.boundItem(Topic1.Variables.Separator.getDisplayItem(Topic1.Variables.Separator.selectedIndex)), vDate = util.printd("ddmmyyyy", new Date()); if (vCurrentName === vDefaultName) { if (vNewName !== null && vNewPath !== null) { vNewPath += vSubfolder; vNewPath += vSlash; vNewPath += vNewName.replace(/[\s\!\?\<\>\'\"\*\/\\\=\?\^\`\{\}\|\~]+/g, vSeparator); vNewPath += vSeparator; vNewPath += vDate; vNewPath += ".pdf"; console.println(vNewPath); } else { vNewPath = vCurrentPath; } } this.rawValue = vNewPath;
Beispiel – Zip-Datei mit Formular, Folder Level Script und Unterordner
//
Example – Zip file containing form, folder level script and sub folders
https://documentcloud.adobe.com/link/track?uri=urn%3Aaaid%3Ascds%3AUS%3Ab00d4d56-9bd9-4500-99d4-b233387bfe92