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

Saveas pdf without user input

Community Beginner ,
Aug 22, 2023 Aug 22, 2023

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

chloeh99272324_0-1692709558783.png

 

TOPICS
Actions and scripting , Windows
473
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

Community Expert , Aug 22, 2023 Aug 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:

 

pdfSave
...
Translate
Adobe
Community Expert ,
Aug 22, 2023 Aug 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:

 

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
Community Beginner ,
Aug 22, 2023 Aug 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 );

 

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
Community Expert ,
Aug 22, 2023 Aug 22, 2023

What version of Photoshop is rasterizing the PDF?

 

Is the longest pixel edge > 32,000px?

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
Community Beginner ,
Aug 22, 2023 Aug 22, 2023

Photoshop version 24.7

and no, the sizes of the files im using are 
3742x1994
3860x2419
2726x1994
3521x2621
But then it seems to stretch them all to 3521x2621

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
Community Beginner ,
Aug 23, 2023 Aug 23, 2023
LATEST

Fixed it using the open options I saw in a different post of yours. Thanks.

 

var pdfOpenOpts = new PDFOpenOptions();
pdfOpenOpts.antiAlias = true;
pdfOpenOpts.bitsPerChannel = BitsPerChannelType.EIGHT;
// MEDIABOX | CROPBOX | BLEEDBOX | TRIMBOX | ARTBOX
pdfOpenOpts.cropPage = CropToType.MEDIABOX;
pdfOpenOpts.mode = OpenDocumentMode.RGB;
pdfOpenOpts.resolution = 300;
pdfOpenOpts.suppressWarnings = true;
pdfOpenOpts.usePageNumber = true;
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
Community Beginner ,
Aug 22, 2023 Aug 22, 2023

It seems to be taking the canvas size from the last file it uses (it also is the one with the highest height) and then stretching all other files vertically and horizontally to fit that canvas size as it opens them, but it hasnt used that file at all when it opens the first file so i dont know why it would use its dimensions instead of the current files?

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