Copy link to clipboard
Copied
Hello Everyone,
I'm trying to save PDF of activeDocument using a script for convenience, any ideas?
#target photoshop;
var saveFile = File(Folder.desktop + "/test.pdf");
SavePDF(saveFile);
function SavePDF(saveFile){
pdfSaveOptions = new PDFSaveOptions();
activeDocument.saveAs(File(saveFile), pdfSaveOptions, true, Extension.LOWERCASE);
};
Copy link to clipboard
Copied
#target photoshop;
var saveFile = File(Folder.desktop + "/test.pdf");
SavePDF(saveFile);
function SavePDF(saveFile){
pdfSaveOptions = new PDFSaveOptions();
activeDocument.saveAs(File(saveFile), pdfSaveOptions, true, Extension.LOWERCASE);
};
Copy link to clipboard
Copied
Thank you!
I've added try and catch to the code and also take active document's name:
#target photoshop;
try
{
var savePath = activeDocument.path;
var saveFile = File(savePath + "/" + app.activeDocument.name + ".pdf");
SavePDF(saveFile);
}
catch(e)
{
savePath = Folder.selectDialog("select folder");
var saveFile = File(savePath + "/" + app.activeDocument.name + ".pdf");
SavePDF(saveFile);
}
function SavePDF(saveFile){
pdfSaveOptions = new PDFSaveOptions();
activeDocument.saveAs(File(saveFile), pdfSaveOptions, true, Extension.LOWERCASE);
};
by the way, I haven't tried try and catch too many times, I wanted to know if there's a better way to do it where I only need to write once these two lines:
var saveFile = File(savePath + "/" + app.activeDocument.name + ".pdf");
SavePDF(saveFile);
Copy link to clipboard
Copied
#target photoshop;
try {
savePath = activeDocument.path;
}catch(e){
savePath = Folder.selectDialog("select folder");
}
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var saveFile = File(savePath + "/" + Name + ".pdf");
SavePDF(saveFile);
function SavePDF(saveFile){
pdfSaveOptions = new PDFSaveOptions();
activeDocument.saveAs(File(saveFile), pdfSaveOptions, true, Extension.LOWERCASE);
};
Copy link to clipboard
Copied
Thank you again for that