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
Many scripts are free to download thanks to the support of users. Help me keep developing new scripts by supporting my work. Click the PayPal button to contribute any amount. Thank you.

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 2022 William Campbell
All Rights Reserved
https://www.marspremedia.com/contact

Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted.

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?", true, 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 2022 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 {
            app.pdfExportPreferences.properties = {
                "acrobatCompatibility": AcrobatCompatibility.ACROBAT_8,
                "bleedBottom": 0,
                "bleedInside": 0,
                "bleedMarks": false,
                "bleedOutside": 0,
                "bleedTop": 0,
                "colorBars": false,
                "colorBitmapCompression": BitmapCompression.AUTO_COMPRESSION,
                "colorBitmapSampling": Sampling.BICUBIC_DOWNSAMPLE,
                "colorBitmapSamplingDPI": 72,
                "colorTileSize": 128,
                "compressTextAndLineArt": true,
                "compressionType": PDFCompressionType.COMPRESS_STRUCTURE,
                "cropImagesToFrames": true,
                "cropMarks": false,
                "effectivePDFDestinationProfile": "sRGB IEC61966-2.1",
                "effectivePDFXProfile": PDFProfileSelector.USE_NO_PROFILE,
                "exportAsSinglePages": false,
                "exportGuidesAndGrids": false,
                "exportLayers": false,
                "exportNonprintingObjects": false,
                "exportReaderSpreads": false,
                "exportWhichLayers": ExportLayerOptions.EXPORT_VISIBLE_PRINTABLE_LAYERS,
                "generateThumbnails": true,
                "grayTileSize": 128,
                "grayscaleBitmapCompression": BitmapCompression.AUTO_COMPRESSION,
                "grayscaleBitmapSampling": Sampling.BICUBIC_DOWNSAMPLE,
                "grayscaleBitmapSamplingDPI": 72,
                "includeBookmarks": true,
                "includeHyperlinks": true,
                "includeICCProfiles": ICCProfiles.INCLUDE_ALL,
                "includeSlugWithPDF": false,
                "includeStructure": true,
                "interactiveElementsOption": InteractiveElementsOptions.APPEARANCE_ONLY,
                "monochromeBitmapCompression": MonoBitmapCompression.CCIT4,
                "monochromeBitmapSampling": Sampling.BICUBIC_DOWNSAMPLE,
                "monochromeBitmapSamplingDPI": 600,
                "omitBitmaps": false,
                "omitEPS": false,
                "omitPDF": false,
                "openInFullScreen": false,
                "optimizePDF": true,
                "pageInformationMarks": false,
                "pageRange": PageRange.ALL_PAGES,
                "pdfColorSpace": PDFColorSpace.RGB,
                "pdfDestinationProfile": "sRGB IEC61966-2.1",
                "pdfDisplayTitle": PdfDisplayTitleOptions.DISPLAY_FILE_NAME,
                "pdfMagnification": PdfMagnificationOptions.FIT_PAGE,
                "pageMarksOffset": 0.125,
                "pdfMarkType": MarkTypes.DEFAULT_VALUE,
                "pdfPageLayout": PageLayoutOptions.SINGLE_PAGE,
                "pdfXProfile": PDFProfileSelector.USE_NO_PROFILE,
                "printerMarkWeight": PDFMarkWeight.P25PT,
                "registrationMarks": false,
                "standardsCompliance": PDFXStandards.NONE,
                "subsetFontsBelow": 100,
                "thresholdToCompressColor": 72,
                "thresholdToCompressGray": 72,
                "thresholdToCompressMonochrome": 600,
                "useDocumentBleedWithPDF": false,
                "useSecurity": false,
                "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.properties = {
                colorBitmapQuality: compression,
                colorBitmapSamplingDPI: resolution,
                grayscaleBitmapQuality: compression,
                grayscaleBitmapSamplingDPI: resolution,
                thresholdToCompressColor: resolution,
                thresholdToCompressGray: resolution,
                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;
        }
    }

})();
Many scripts are free to download thanks to the support of users. Help me keep developing new scripts by supporting my work. Click the PayPal button to contribute any amount. Thank you.
Download
PDF Proof

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

Custom solutions based on any script, or completely new ideas, are possible at reasonable cost. Contact William for more information.

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 products purchased from this site, or for programming custom solutions, are the purchase of a non-exclusive license to use the software and do not grant the purchaser any degree of ownership of the software. Author of the intellectual property and copyright holder William Campbell retains 100% ownership of all code used in all products and custom solutions.

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.