Skip to main content
Participant
March 19, 2025
Question

Issue scripting SaveAs PDF/X-4:2008

  • March 19, 2025
  • 1 reply
  • 181 views

I have a script that is saving the current document with preset PDF/X-4:2008.  It mostly works fine except we have found a specific file (about 49mb) that when saved with the script gets saved, it is about 759mb.  I can replicate the behavior manually if using no preset and have "Preserve Illustrator Editing Capabilities" checked.  In the script, I am setting PDFSaveOptions.preserveEditability to false.  What am I missing?  TIA

 

This is my script:

function savePrintFile() {
    if (app.documents.length === 0) {
        alert("No document open.");
        return;
    }

    var doc = app.activeDocument;
    
    // Open save dialog to name file and select location
    var currentFile = new File(doc.fullName)
    var saveFile = currentFile.saveDlg();
    if (saveFile) {
        // Save as PDF/X4
        var saveOptions = new PDFSaveOptions();         
        //This string has to match a preset found in Adobe Illustrator.  If the preset is not installed on the user's computer, this will fail the script
        saveOptions.pDFPreset = '[PDF/X-4:2008]';		

		// Disable Illustrator editability		
        saveOptions.preserveEditability = false;
		
        doc.saveAs(saveFile, saveOptions);

		return saveFile;
    }
}

1 reply

Participant
March 20, 2025

This can be closed.  I changed my code to the following and it works properly:

function savePrintFile() {
    if (app.documents.length === 0) {
        alert("No document open.");
        return;
    }

    var doc = app.activeDocument;
    
    // Open save dialog to name file and select location
    var currentFile = new File(doc.fullName)
    var saveFile = currentFile.saveDlg();
    if (saveFile) {
        // Save as PDF/X4
        var saveOptions = new PDFSaveOptions();         

        saveOptions.pDFXStandard = PDFXStandard.PDFX42007;
        saveOptions.compatibility = PDFCompatibility.ACROBAT7;

		// Disable Illustrator editability		
        saveOptions.preserveEditability = false;
        
        //Compression Settings
        saveOptions.colorCompression = CompressionQuality.AUTOMATICJPEGMAXIMUM;
        saveOptions.colorDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;
        saveOptions.colorDownsampling = 300;
        saveOptions.colorDownsamplingImageThreshold = 450;

        saveOptions.grayscaleCompression = CompressionQuality.AUTOMATICJPEGMAXIMUM;
        saveOptions.grayscaleDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;
        saveOptions.grayscaleDownsampling = 300;
        saveOptions.grayscaleDownsamplingImageThreshold = 450;

        saveOptions.monochromeCompression = MonochromeCompression.CCIT4;
        saveOptions.monochromeDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;
        saveOptions.monochromeDownsampling = 300;
        saveOptions.monochromeDownsamplingImageThreshold = 450;
		
        doc.saveAs(saveFile, saveOptions);

		return saveFile;
    }
}
Participant
March 20, 2025

Although I would like to know whether setting pDFPreset should be bringing along all of the preset properties.  It would be very helpful if it did.