mashtullah's solution to "Save As Function PDF"

Am not sure if i understood your question well but try out the code below.<\/p>\n\n

put this in your document script...<\/strong><\/p>\n

function<\/span> <\/span>doSaveFile<\/span>()<\/span> <\/span>{<\/span>\n\n <\/span>if<\/span> <\/span>(<\/span>app<\/span>.<\/span>alert<\/span>({<\/span>cMsg:<\/span> <\/span>&<\/span>quot<\/span>;<\/span>Do<\/span> <\/span>you<\/span> <\/span>wish<\/span> <\/span>to<\/span> <\/span>save<\/span> <\/span>this<\/span> <\/span>document<\/span>?&<\/span>quot<\/span>;,<\/span>nIcon:<\/span>2<\/span>,<\/span> <\/span>nType:<\/span> <\/span>3<\/span>})<\/span> <\/span>==<\/span> <\/span>4<\/span>){<\/span>\n//<\/span> <\/span>build<\/span> <\/span>file<\/span> <\/span>name<\/span>\nvar<\/span> <\/span>newFileName<\/span> <\/span>=<\/span> <\/span>this<\/span>.<\/span>getField<\/span>(<\/span>&<\/span>quot<\/span>;<\/span>textfield1&quot<\/span>;)<\/span>.<\/span>value<\/span> <\/span>+<\/span> <\/span>&<\/span>quot<\/span>;<\/span>.&<\/span>quot<\/span>;<\/span> <\/span>+<\/span> <\/span>this<\/span>.<\/span>getField<\/span>(<\/span>&<\/span>quot<\/span>;<\/span>textfield2&quot<\/span>;)<\/span>.<\/span>value<\/span> <\/span>+<\/span> <\/span>&<\/span>quot<\/span>;<\/span>.&<\/span>quot<\/span>;<\/span> <\/span>\n+<\/span> <\/span>this<\/span>.<\/span>getField<\/span>(<\/span>&<\/span>quot<\/span>;<\/span>textfield3&quot<\/span>;)<\/span>.<\/span>value<\/span>+&<\/span>quot<\/span>;<\/span>.&<\/span>quot<\/span>;<\/span>+<\/span>this<\/span>.<\/span>getField<\/span>(<\/span>&<\/span>quot<\/span>;<\/span>textfield4&quot<\/span>;)<\/span>.<\/span>value<\/span>+<\/span> <\/span>&<\/span>quot<\/span>;<\/span>.&<\/span>quot<\/span>;<\/span> <\/span>+<\/span>this<\/span>.<\/span>getField<\/span>(<\/span>&<\/span>quot<\/span>;<\/span>textfield5&quot<\/span>;)<\/span>.<\/span>value<\/span>+&<\/span>quot<\/span>;<\/span>.<\/span>pdf&quot<\/span>;;<\/span>\n\n//<\/span> <\/span>Split<\/span> <\/span>the<\/span> <\/span>current<\/span> <\/span>path<\/span> <\/span>into<\/span> <\/span>an<\/span> <\/span>array<\/span> <\/span>so<\/span> <\/span>that<\/span> <\/span>we<\/span> <\/span>can<\/span> <\/span>remove<\/span> <\/span>the<\/span> <\/span>current<\/span> <\/span>file<\/span> <\/span>name<\/span>\n    <\/span>var<\/span> <\/span>curPath<\/span> <\/span>=<\/span> <\/span>this<\/span>.<\/span>path<\/span>.<\/span>split<\/span>(<\/span>&<\/span>quot<\/span>;<\/span>/<\/span>);<\/span>\n\n    <\/span>//<\/span> <\/span>Remove<\/span> <\/span>current<\/span> <\/span>file<\/span> <\/span>name<\/span>\n    <\/span>curPath<\/span>.<\/span>pop<\/span>();<\/span>\n\n    <\/span>//<\/span> <\/span>Add<\/span> <\/span>our<\/span> <\/span>new<\/span> <\/span>file<\/span> <\/span>name<\/span> <\/span>to<\/span> <\/span>the<\/span> <\/span>array<\/span>\n    <\/span>curPath<\/span>.<\/span>push<\/span>(<\/span>NewFileName<\/span>);<\/span>\n\n    <\/span>//<\/span> <\/span>Glue<\/span> <\/span>back<\/span> <\/span>together<\/span> <\/span>our<\/span> <\/span>array<\/span> <\/span>to<\/span> <\/span>get<\/span> <\/span>our<\/span> <\/span>new<\/span> <\/span>path<\/span>\n    <\/span>var<\/span> <\/span>newPath<\/span>=<\/span>curPath<\/span>.<\/span>join<\/span>(<\/span>&<\/span>quot<\/span>;<\/span>/&<\/span>quot<\/span>;);<\/span>\n\n    <\/span>app<\/span>.<\/span>beginPriv<\/span>();<\/span>  <\/span>\n    <\/span>var<\/span> <\/span>checkFlag<\/span> <\/span>=<\/span> <\/span>app<\/span>.<\/span>openDoc<\/span>({<\/span> <\/span>cPath:<\/span> <\/span>newPath<\/span>,<\/span> <\/span>bHidden:<\/span> <\/span>true<\/span> <\/span>});<\/span> <\/span>\n    <\/span>app<\/span>.<\/span>endPriv<\/span>();<\/span>\n    <\/span>if<\/span>(<\/span>checkFlag<\/span>)<\/span>\n    <\/span>{<\/span>\n        <\/span>app<\/span>.<\/span>alert<\/span>({<\/span>cMsg:<\/span> <\/span>&<\/span>quot<\/span>;<\/span>File<\/span> <\/span>already<\/span> <\/span>exists<\/span>...&<\/span>quot<\/span>;,<\/span>cTitle:<\/span> <\/span>&<\/span>quot<\/span>;<\/span> <\/span>File<\/span> <\/span>save<\/span> <\/span>error&quot<\/span>;});<\/span>\n    <\/span>}<\/span>\n    <\/span>else<\/span>\n    <\/span>{<\/span>\n        <\/span>this<\/span>.<\/span>saveAs<\/span>(<\/span>newPath<\/span>);<\/span>\n    <\/span>}<\/span>\n}<\/span>\n\n}<\/span>\n<\/pre><\/div>\n

put this in your button's mouseUp event...<\/strong><\/p>\n

doSaveFile<\/span>();<\/span>\n<\/pre><\/div>\n

Incase of anything let me know.<\/p>\n

Am not sure if i understood your question well but try out the code below. **put this in your document script...** function doSaveFile() { if (app.alert({cMsg: "Do you wish to save this document?",nIcon:2, nType: 3}) == 4){ // build file name var newFileName = this.getField("textfield1").value + "." + this.getField("textfield2").value + "." + this.getField("textfield3").value+"."+this.getField("textfield4").value+ "." +this.getField("textfield5").value+".pdf"; // Split the current path into an array so that we can remove the current file name var curPath = this.path.split("/); // ("/"); // Remove current file name curPath.pop(); // Add our new file name to the array curPath.push(NewFileName); // Glue back together our array to get our new path var newPath=curPath.join("/"); app.beginPriv(); var checkFlag = app.openDoc({ cPath: newPath, bHidden: true }); app.endPriv(); if(checkFlag) { app.alert({cMsg: "File already exists...",cTitle: " File save error"}); } else { this.saveAs(newPath); } } } **put this in your button's mouseUp event...** doSaveFile(); Incase of anything let me know.
Am not sure if i understood your question well but try out the code below. **put this in your document script...** function doSaveFile() { if (app.alert({cMsg: "Do you wish to save this document?",nIcon:2, nType: 3}) == 4){ // build file name var newFileName = this.getField("textfield1").value + "." + this.getField("textfield2").value + "." + this.getField("textfield3").value+"."+this.getField("textfield4").value+ "." +this.getField("textfield5").value+".pdf"; // Split the current path into an array so that we can remove the current file name var curPath = this.path.split("/"); // Remove current file name curPath.pop(); // Add our new file name to the array curPath.push(NewFileName); // Glue back together our array to get our new path var newPath=curPath.join("/"); app.beginPriv(); var checkFlag = app.openDoc({ cPath: newPath, bHidden: true }); app.endPriv(); }); if(checkFlag) { app.alert({cMsg: "File already exists...",cTitle: " File save error"}); } else { this.saveAs(newPath); } } } **); } app.endPriv(); } } **put this in your button's mouseUp event...** doSaveFile(); Incase of anything let me know.

User: mashtullah

Question: Save As Function PDF

Back to question