Skip to main content
Participant
August 22, 2023
Answered

Saveas pdf without user input

  • August 22, 2023
  • 1 reply
  • 458 views

Hi,
I'm trying to automate a process and batch handle a bunch of files. When I get to the saving, however, it pops up with a prompt and won't continue to the next files without user input confirming the save options. Is there anyway to surpress this popup?

I've tried using app.displayDialogs = DialogModes.NO but this just stops the dialog but doesnt actually save the file or continue onto the other files. It doesnt give me a popup if I dont change/set any of the PDFSaveOptions but then the PDF output isnt correct (it comes out squashed vertically).

#target photoshop
// PDF Options;
var sfwOptions = new PDFSaveOptions();  
sfwOptions.PDFCompatibility = PDFCompatibility.PDF14;
sfwOptions.embedThumbnail = true;
sfwOptions.preserveEditing = true;
sfwOptions.presetFile = "[High Quality Print]";	


function saveFile(fileName) {
	var theNewName =splits[0] + fileName;
	// Save PNG
	var saveFile = new File( outputFolder + '/' + theNewName + '.pdf' );
	//activeDocument.exportDocument( saveFile, ExportType.SAVEFORWEB, sfwOptions );  
	activeDocument.saveAs(saveFile,sfwOptions);
	// Undo changes (go back to previous state)
	myDocument.activeHistoryState = savedState;	
}

 

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

This DOM code doesn't trigger a dialog:

 

var saveFile = File("~/Desktop/" + activeDocument.name.replace(/\.[^\.]+$/, ''));
SavePDF(File(saveFile + ".pdf"));

function SavePDF(saveFile) {   
    pdfSaveOptions = new PDFSaveOptions();   
    pdfSaveOptions.PDFCompatibility = PDFCompatibility.PDF14;
    pdfSaveOptions.embedThumbnail = true;
    pdfSaveOptions.preserveEditing = true;
    activeDocument.saveAs(saveFile, pdfSaveOptions, true, Extension.LOWERCASE);   
}

 

But this line does:

 

pdfSaveOptions.presetFile = "[High Quality Print]";

 

Another option is to use AM code recorded by the ScriptingListener plugin:

 

1 reply

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
August 22, 2023

This DOM code doesn't trigger a dialog:

 

var saveFile = File("~/Desktop/" + activeDocument.name.replace(/\.[^\.]+$/, ''));
SavePDF(File(saveFile + ".pdf"));

function SavePDF(saveFile) {   
    pdfSaveOptions = new PDFSaveOptions();   
    pdfSaveOptions.PDFCompatibility = PDFCompatibility.PDF14;
    pdfSaveOptions.embedThumbnail = true;
    pdfSaveOptions.preserveEditing = true;
    activeDocument.saveAs(saveFile, pdfSaveOptions, true, Extension.LOWERCASE);   
}

 

But this line does:

 

pdfSaveOptions.presetFile = "[High Quality Print]";

 

Another option is to use AM code recorded by the ScriptingListener plugin:

 

Ohh DeerAuthor
Participant
August 22, 2023

Thanks that worked!
In my post I mentioned it being exported wrong without the settings but ive realised that seems to be an issue with it opening the pdf. its stretching it vertically for some reason any idea why this might be?
If i open it manually the file is 1994px in height however the script opened it at a height of 2621px

var fileRef = new File( input+'/'+filename );
var doc_a = app.open( fileRef );

 

Stephen Marsh
Community Expert
Community Expert
August 22, 2023

What version of Photoshop is rasterizing the PDF?

 

Is the longest pixel edge > 32,000px?