Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create PDF of activeDocument

Engaged ,
Apr 09, 2019 Apr 09, 2019

Hello Everyone,

I'm trying to save PDF of activeDocument using a script for convenience, any ideas?

TOPICS
Actions and scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Apr 09, 2019 Apr 09, 2019

#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);

};

Translate
Adobe
Guide ,
Apr 09, 2019 Apr 09, 2019

#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);

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 09, 2019 Apr 09, 2019

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 10, 2019 Apr 10, 2019

#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);  

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 11, 2019 Apr 11, 2019
LATEST

Thank you again for that

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines