PDF Proof

Script for Adobe InDesign

The purpose of the script is twofold:

1. Export a proof PDF of an InDesign document. Not that it’s tough to do without a script, using PDF Presets, but I wanted the exported file named a particular way for proofs, and always named the same way. I got tired of doing it manually each time.

2. Share this tool of convenience (and consistency) with other users. If you want proofs named differently, it’s easy to edit this simple script so it names exported PDFs however suits your needs. The script also serves as a template to create other scripts that export PDFs of InDesign documents. The script can export using different properties by altering the process() function, where all PDF Export Preference properties are listed. Also, further options are easily added to the interface.

  • Choice of resolution
  • Pages or spreads
  • Adds suffix “_proof” to PDF file name
  • Replaces spaces with underscores to make file name web-friendly
  • Adapt open source to customize or create other scripts
Download
PDF Proof
Help me keep making new scripts by supporting my work. Click the PayPal button to contribute any amount you choose. Thank you. William Campbell

How to use the script

The interface is single section with two options: a choice of Resolution, and the choice Pages or Spreads. Set the desired resolution, and whether to export in pages or in spreads, then click the OK button to begin. The PDF is exported in the background. That’s all there is to it.

Source code

(download button below)

/*
PDF Proof
Copyright 2024 William Campbell
All Rights Reserved
https://www.marspremedia.com/contact

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

*/

(function () {

    var title = "PDF Proof";

    if (!/indesign/i.test(app.name)) {
        alert("Script for InDesign", title, false);
        return;
    }

    // Script variables.
    var doc;
    var i;

    // Reusable UI variables.
    var g; // group
    var p; // panel
    var w; // window

    // Permanent UI variables.
    var btnCancel;
    var btnOk;
    var rb072;
    var rb096;
    var rb120;
    var rb150;
    var rbPages;
    var rbSpreads;

    // SETUP

    if (!app.documents.length) {
        alert("Open a document", title, false);
        return;
    }
    doc = app.activeDocument;
    if (!doc.saved) {
        alert("Save document first", title, false);
        return;
    }
    // Check for overset text.
    for (i = 0; i < doc.stories.length; i++) {
        if (doc.stories[i].overflows) {
            if (!confirm("Document contains overset text.\nContinue?", false, title)) {
                return;
            }
            break;
        }
    }
    // Check for links missing or modified.
    for (i = 0; i < doc.links.length; i++) {
        if (!(doc.links[i].status == 1282237028 || doc.links[i].status == 1852797549)) {
            // Not embedded or normal.
            if (!confirm("Links are missing or modified.\nContinue?", false, title)) {
                return;
            }
            break;
        }
    }

    // CREATE USER INTERFACE

    w = new Window("dialog", title);
    w.alignChildren = "fill";

    // Options.
    p = w.add("panel");
    p.alignChildren = "center";
    p.margins = [24, 24, 24, 18];
    p.spacing = 24;

    // Resolution.
    g = p.add("group");
    g.add("statictext", undefined, "Resolution:");
    g = g.add("group");
    g.margins = [0, 6, 0, 0];
    rb072 = g.add("radiobutton", undefined, "72");
    rb096 = g.add("radiobutton", undefined, "96");
    rb120 = g.add("radiobutton", undefined, "120");
    rb150 = g.add("radiobutton", undefined, "150");

    // Pages or spreads.
    g = p.add("group");
    rbPages = g.add("radiobutton", undefined, "Pages");
    rbSpreads = g.add("radiobutton", undefined, "Spreads");

    // Action Buttons
    g = w.add("group");
    g.alignment = "center";
    btnOk = g.add("button", undefined, "OK");
    btnCancel = g.add("button", undefined, "Cancel");

    // Panel Copyright
    p = w.add("panel");
    p.add("statictext", undefined, "Copyright 2024 William Campbell");

    // SET UI VALUES

    rb072.value = true;
    rbPages.value = true;

    // UI ELEMENT EVENT HANDLERS

    btnOk.onClick = function () {
        w.close(1);
    };
    btnCancel.onClick = function () {
        w.close(0);
    };

    // DISPLAY THE DIALOG

    if (w.show() == 1) {
        try {
            process();
        } catch (e) {
            alert("An error has occurred.\nLine " + e.line + ": " + e.message, title, true);
        }
    }

    //====================================================================
    //               END PROGRAM EXECUTION, BEGIN FUNCTIONS
    //====================================================================

    function process() {
        var compression;
        var docBaseName;
        var filePdf;
        var folder;
        var pdfFileName;
        var resolution;
        // Preserve preferences.
        var preserve = {
            pdfExportPreferences: app.pdfExportPreferences.properties
        };
        try {
            try {
                app.pdfExportPreferences.exportAsSinglePages = false;
            } catch (_) {
                // Feature not present in older versions; ignore.
            }
            try {
                app.pdfExportPreferences.pdfDisplayTitle = PdfDisplayTitleOptions.DISPLAY_FILE_NAME;
            } catch (_) {
                // Feature not present in older versions; ignore.
            }
            app.pdfExportPreferences.acrobatCompatibility = AcrobatCompatibility.ACROBAT_8;
            app.pdfExportPreferences.bleedBottom = 0;
            app.pdfExportPreferences.bleedInside = 0;
            app.pdfExportPreferences.bleedMarks = false;
            app.pdfExportPreferences.bleedOutside = 0;
            app.pdfExportPreferences.bleedTop = 0;
            app.pdfExportPreferences.colorBars = false;
            app.pdfExportPreferences.colorBitmapCompression = BitmapCompression.AUTO_COMPRESSION;
            app.pdfExportPreferences.colorBitmapSampling = Sampling.BICUBIC_DOWNSAMPLE;
            app.pdfExportPreferences.colorBitmapSamplingDPI = 72;
            app.pdfExportPreferences.colorTileSize = 128;
            app.pdfExportPreferences.compressTextAndLineArt = true;
            app.pdfExportPreferences.compressionType = PDFCompressionType.COMPRESS_STRUCTURE;
            app.pdfExportPreferences.cropImagesToFrames = true;
            app.pdfExportPreferences.cropMarks = false;
            app.pdfExportPreferences.exportGuidesAndGrids = false;
            app.pdfExportPreferences.exportLayers = false;
            app.pdfExportPreferences.exportNonprintingObjects = false;
            app.pdfExportPreferences.exportReaderSpreads = false;
            app.pdfExportPreferences.exportWhichLayers = ExportLayerOptions.EXPORT_VISIBLE_PRINTABLE_LAYERS;
            app.pdfExportPreferences.generateThumbnails = true;
            app.pdfExportPreferences.grayTileSize = 128;
            app.pdfExportPreferences.grayscaleBitmapCompression = BitmapCompression.AUTO_COMPRESSION;
            app.pdfExportPreferences.grayscaleBitmapSampling = Sampling.BICUBIC_DOWNSAMPLE;
            app.pdfExportPreferences.grayscaleBitmapSamplingDPI = 72;
            app.pdfExportPreferences.includeBookmarks = true;
            app.pdfExportPreferences.includeHyperlinks = true;
            app.pdfExportPreferences.includeICCProfiles = ICCProfiles.INCLUDE_ALL;
            app.pdfExportPreferences.includeSlugWithPDF = false;
            app.pdfExportPreferences.includeStructure = true;
            app.pdfExportPreferences.interactiveElementsOption = InteractiveElementsOptions.APPEARANCE_ONLY;
            app.pdfExportPreferences.monochromeBitmapCompression = MonoBitmapCompression.CCIT4;
            app.pdfExportPreferences.monochromeBitmapSampling = Sampling.BICUBIC_DOWNSAMPLE;
            app.pdfExportPreferences.monochromeBitmapSamplingDPI = 600;
            app.pdfExportPreferences.omitBitmaps = false;
            app.pdfExportPreferences.omitEPS = false;
            app.pdfExportPreferences.omitPDF = false;
            app.pdfExportPreferences.openInFullScreen = false;
            app.pdfExportPreferences.optimizePDF = true;
            app.pdfExportPreferences.pageInformationMarks = false;
            app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
            app.pdfExportPreferences.pdfColorSpace = PDFColorSpace.RGB;
            app.pdfExportPreferences.pdfDestinationProfile = "sRGB IEC61966-2.1";
            app.pdfExportPreferences.pdfMagnification = PdfMagnificationOptions.FIT_PAGE;
            app.pdfExportPreferences.pageMarksOffset = 0.125;
            app.pdfExportPreferences.pdfMarkType = MarkTypes.DEFAULT_VALUE;
            app.pdfExportPreferences.pdfPageLayout = PageLayoutOptions.SINGLE_PAGE;
            app.pdfExportPreferences.pdfXProfile = PDFProfileSelector.USE_NO_PROFILE;
            app.pdfExportPreferences.printerMarkWeight = PDFMarkWeight.P25PT;
            app.pdfExportPreferences.registrationMarks = false;
            app.pdfExportPreferences.standardsCompliance = PDFXStandards.NONE;
            app.pdfExportPreferences.subsetFontsBelow = 100;
            app.pdfExportPreferences.thresholdToCompressColor = 72;
            app.pdfExportPreferences.thresholdToCompressGray = 72;
            app.pdfExportPreferences.thresholdToCompressMonochrome = 600;
            app.pdfExportPreferences.useDocumentBleedWithPDF = false;
            app.pdfExportPreferences.useSecurity = false;
            app.pdfExportPreferences.viewPDF = false;
            // 72 and 96 quality minimum.
            // 120 and 150 quality medium.
            compression = CompressionQuality.MINIMUM;
            resolution = 72;
            if (rb096.value) {
                resolution = 96;
            } else if (rb120.value) {
                compression = CompressionQuality.MEDIUM;
                resolution = 120;
            } else if (rb150.value) {
                compression = CompressionQuality.MEDIUM;
                resolution = 150;
            }
            app.pdfExportPreferences.colorBitmapQuality = compression;
            app.pdfExportPreferences.colorBitmapSamplingDPI = resolution;
            app.pdfExportPreferences.grayscaleBitmapQuality = compression;
            app.pdfExportPreferences.grayscaleBitmapSamplingDPI = resolution;
            app.pdfExportPreferences.thresholdToCompressColor = resolution;
            app.pdfExportPreferences.thresholdToCompressGray = resolution;
            app.pdfExportPreferences.exportReaderSpreads = rbSpreads.value;
            // Base name is file name without extension.
            docBaseName = doc.name.replace(/\.[^\.]*$/, "");
            // Replace spaces with underscore.
            pdfFileName = docBaseName.replace(/ /g, "_");
            // Add suffix "_proof" unless already present.
            if (!/proof/.test(pdfFileName)) {
                pdfFileName += "_proof";
            }
            // Add extension.
            pdfFileName += ".pdf";
            // Export.
            folder = doc.filePath;
            filePdf = new File(folder.fullName + "/" + pdfFileName);
            doc.asynchronousExportFile(ExportFormat.PDF_TYPE, filePdf);
        } finally {
            // Restore preferences.
            app.pdfExportPreferences.properties = preserve.pdfExportPreferences;
        }
    }

})();
Help me keep making new scripts by supporting my work. Click the PayPal button to contribute any amount you choose. Thank you. William Campbell
Download
PDF Proof

For help installing scripts, see How to Install and Use Scripts in Adobe Creative Cloud Applications.

IMPORTANT: scripts are developed for the latest Adobe Creative Cloud applications. Many scripts work in CC 2018 and later, even some as far back as CS6, but may not perform as expected, or run at all, when used in versions prior to 2018. Photoshop features Select Subject and Preserve Details 2.0 definitely fail prior to CC 2018 (version 19) as the features do not exist in earlier versions. For best results use the latest versions of Adobe Creative Cloud applications.

IMPORTANT: by downloading any of the scripts on this page you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.

IMPORTANT: fees paid for software products are the purchase of a non-exclusive license to use the software product and do not grant the purchaser any degree of ownership of the software code. Author of the intellectual property and copyright holder William Campbell retains 100% ownership of all code used in all software products regardless of the inspiration for the software product design or functionality.