Skip to main content
stephenmcateer
Known Participant
January 18, 2023
Answered

Photoshop scripting: pdfSaveOpts.layers does not work

  • January 18, 2023
  • 2 replies
  • 484 views

When I try save a PDF using scripts, the pdfSaveOpts.layers = false has no effect.

That is, the script saves the document as a PDF but when select the option to save withour layers, the resulting file contains all layers of the original document.

 

1. Version of the app: Photoshop 24.0.1

2. Platform and OS version: Windows 10 Ver. 22H2

3. Basic steps to reproduce the problem: Use the Photoshop Script Events Manager to run the script below. Photoshop Event should be Save Document

4. Expected result and actual result: The script should save a copy of the current file as a PDF with no layers. However, it saves a PDF with all layers incorporated into the PDF.

 

====

Here is the script I'm using:

 


var saveFile = File("~/Desktop/"+app.activeDocument.activeLayer.name+".pdf")

pdfSaveOpts = new PDFSaveOptions();


 pdfSaveOpts.layers = false; // does not work for me

activeDocument.saveAs(saveFile, pdfSaveOpts, true);

 

This topic has been closed for replies.
Correct answer Stephen Marsh

@stephenmcateer wrote:

 

4. Expected result and actual result: The script should save a copy of the current file as a PDF with no layers. However, it saves a PDF with all layers incorporated into the PDF.

 

 

Wouldn’t false be set to exclude layers?

 

https://theiviaxx.github.io/photoshop-docs/Photoshop/PDFSaveOptions/layers.html

 

2 replies

stephenmcateer
Known Participant
January 18, 2023

Yes. I posted the wrong version of the script Stephen. Thanks for pointing that out. I'll see if I can amend the original post. Cheers.

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
January 18, 2023

@stephenmcateer wrote:

 

4. Expected result and actual result: The script should save a copy of the current file as a PDF with no layers. However, it saves a PDF with all layers incorporated into the PDF.

 

 

Wouldn’t false be set to exclude layers?

 

https://theiviaxx.github.io/photoshop-docs/Photoshop/PDFSaveOptions/layers.html

 

stephenmcateer
Known Participant
January 18, 2023

 Update: this is not a bug. I hadn't updated the script I was using to set the 'pdfSaveOpts.layers' to 'false'.

Apologies and thanks to @Stephen Marsh for pointing out my mistake.