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

Create PDF of activeDocument

Engaged ,
Apr 09, 2019 Apr 09, 2019

Copy link to clipboard

Copied

Hello Everyone,

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

TOPICS
Actions and scripting

Views

940

Translate

Translate

Report

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

};

Votes

Translate

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

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

};

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

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

};

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Thank you again for that

Votes

Translate

Translate

Report

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