The following script uses the Save() method to alter the format in which a file is saved. Using this method requires more code than SimpleSave() but offers a whole range of customization options. It takes three pages in the Scripting Guide to document the possibilities. Whatever changes you want to make, however, can be accomplished by following the model shown here:
- Use GetSaveDefaultParams() to get a list of parameters whose default settings can be altered.
- Use new PropVals() to create an empty parameter list to be used to return information about the Save() operation.
- Use GetPropIndex() to locate one or more of these properties of interest.
- Reset that properties value in the parameter list.
- Call Save() passing in the save as name, and the two parameter lists.
function saveAsPdf(doc) {
var saveParams, name, i, baseName, status, fullName;
name = doc.Name;
baseName = dropSuffix(name);//drops everything from last period
fullName = baseName + ".pdf";
saveParams = GetSaveDefaultParams();
returnParams = new PropVals();
i = GetPropIndex(saveParams, Constants.FS_FileType);
saveParams[i].propVal.ival =Constants.FV_SaveFmtPdf;
doc.Save(fullName, saveParams, returnParams);
i = GetPropIndex(returnParams, Constants.FS_SaveNativeError);
status = returnParams[i].propVal.ival;
if (status === Constants.FE_Success) {
return (true);
} else {
return (false);
}
}
var saveParams, name, i, baseName, status, fullName;
name = doc.Name;
baseName = dropSuffix(name);//drops everything from last period
fullName = baseName + ".pdf";
saveParams = GetSaveDefaultParams();
returnParams = new PropVals();
i = GetPropIndex(saveParams, Constants.FS_FileType);
saveParams[i].propVal.ival =Constants.FV_SaveFmtPdf;
doc.Save(fullName, saveParams, returnParams);
i = GetPropIndex(returnParams, Constants.FS_SaveNativeError);
status = returnParams[i].propVal.ival;
if (status === Constants.FE_Success) {
return (true);
} else {
return (false);
}
}
No comments:
Post a Comment