PDFExportPreference.pageRange CS4

I have a scripted export to a PDF, and I need to make sure it exports all pages. Currently, if the last export was a page range, it uses that range.
I have a PDFExportPreference variable (pdfPref), and when I try to set the pdfPref.pageRange, I get an error "Object does not support the property or method 'pageRange'." I have also tried app.PDFExportPreference.pageRange and get the same error.

Hi,
app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES
'pdf' is not uppercase ;-)
Hans

Similar Messages

  • [JS][CS4]PDF Export With RegExp Doesn't Include First Zero-Please Help

    This is a script we put together with the help of Jongware, Shonkyin and Kaysan a while back...
    Here's the link to the original thread:
    http://forums.adobe.com/thread/481958?tstart=0
    ( function() {
    if(app.documents.length != 0){
    var myFolder = app.activeDocument.filePath;
    if(myFolder != null){
    var myPageName, myFilePath, myFile;
    var myDocument = app.activeDocument;
         //var myBaseName = myDocumentName + "_" ;
              //1.  Update modified links, find and alert operator of missing links.
              var linksLog = updateLinks(myDocument, "");
         if (linksLog != "") {
              alert("Missing Links\n" + linksLog + "\nPlease resolve and try again.");
              return;
         function updateLinks(doc, log) {
              var myLinks = doc.links;
              for (var j = myLinks.length - 1; j >= 0; j--) {
                   switch (myLinks[j].status) {
                        case LinkStatus.normal :; case LinkStatus.linkEmbedded : break; // nothing to do
                        case LinkStatus.linkOutOfDate : myLinks[j].update(); break; // update
                        case LinkStatus.linkMissing :
                             log = log + "Link '" + myLinks[j].name + "' is missing\n";
                        break
                   } // end switch
              } // end for
              return log
         } // end updateLinks
    var my_suffix = decodeURI(app.activeDocument.name).replace(/^(\d+).*/, '$1');
    //my_suffix = Number(my_suffix);
    if (typeof (my_suffix) != 'number')
    my_suffix = Number(my_suffix);
    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
        if (myDocument.pages.item(myCounter).appliedSection.name != ""){
            myDocument.pages.item(myCounter).appliedSection.name = "";
    myPageName = myDocument.pages.item(myCounter).name;
    app.pdfExportPreferences.pageRange = myPageName;
    myFilePath = myFolder + "/" + "MyTest_" + (my_suffix + myCounter) + ".pdf";
    myFile = new File(myFilePath);
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
    myDocument.exportFile(ExportFormat.pdfType, myFile, false, "[Press Quality]");
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
        else{
            alert("No documents are open. Please open a document and try again.");
            exit();
    alert("Finished exporting");
    The problem is, I never considered pages 0 through 99. The script works perfect for 138-140 TEST 10_WORKER.indd. It creates PDFs named:
    MyTest_138.pdf
    MyTest_139.pd
    MyTest_140.pdf
    If the document name is 098-100 TEST 10_WORKER.indd, It creates PDFs named:
    MyTest_98.pdf -  should be MyTest_098.pdf 
    MyTest_99.pdf -  should be MyTest_099.pdf 
    MyTest_100.pdf - This is perferct
    And of course, the double 0s, 008-010 TEST 10_WORKER.indd
    MyTest_8.pdf -  should be MyTest_008.pdf 
    MyTest_9.pdf -  should be MyTest_009.pdf 
    MyTest_10.pdf -  should be MyTest_010.pdf 
    Why doesn't it use the first 0(s) in the name? 0 is a digit and every RegEx tester I've checked it with includes the zero.
    Any assistance with getting this script to use the leading zero if there is one would be greatly appreciated.
    Also, if there is a way to export each PDF from a multipage document which doesn't start with a number, it would be extremely helpful.
    Thanks in advance
    Danny

    The zeros aren't there because they never were there. Your loop starts at 0 and that could be a page number. To pad your page numbers to three-digit numbers, replace this line:
    myFilePath = myFolder + "/" + "MyTest_" + (my_suffix + myCounter) + ".pdf";
    with this one:
    myFilePath = myFolder + "/" + "MyTest_" + (my_suffix + pad(myCounter)) + ".pdf";
    and add the following function somewhere at the end of your script:
    function pad (n) {
        return ("00000"+n).slice(-3);
    Peter

  • Strange behavior with pageRange property (specifying ranges)

    Hello everyone,
    I'm trying to export two PDFs from one INDD in script. I want the first to include the first two pages and the second to include pages 3 through the last. When specifying a page range like this:
    app.pdfExportPreferences.pageRange = '3-' + _doc.pages.length;
    IDS always exports the full document as a PDF (doesn't skip pages 1 and 2).
    I tried this too (with spaces):
    app.pdfExportPreferences.pageRange = '3 - ' + _doc.pages.length;
    But it had the same result. I've run this script in the debugger and check the value of pageRange. It's correct (_doc.pages.length returns a valid last page number).
    If I do this:
    app.pdfExportPreferences.pageRange = '1';
    That works just fine.
    Is there a trick to exporting a range of pages that I'm not seeing? I've verified it on two machines (my local and the server).
    Thanks,
    Eric

    do your document starts from page number different than "1" ?? ;)
    use page.name rather page.documentoffset
    app.pdfExportPreferences.pageRange = _doc.pages[3].name + '-' + _doc.pages[-1].name
    (I'm not JS man so check brackets type, etc.)
    robin
    www.adobescripts.com

  • Export each page in a pagerange

    Dear all,
    How do I export each page in a pagerange using js - eg. I enter a pagerange "2-4,5" and InDesign exports 4 files with one page pr. file?
    From the examples included with InDesign I know how to export all the pages in a document as 1 page pr. export, or export a pagerange to one file (4 pages in one PDF file). But I can't seem to figure out how to couple a defined pagerange with looping through the document pages..
    Kind regards,
    Rasmus Olsen

    var myDocument = app.activeDocument;
    var myDocumentName = myDocument.name;
    var myFolder = Folder.selectDialog ("Choose a Folder");
    var unranged_array = unrange ("1-3,4")
    function unrange (s)
       return s.replace (/(\d+)-(\d+)/g, expand)
    function expand ()
       var expanded = [];
       var start = Number (arguments[1]);
       var stop = Number (arguments[2]);
       for (var i = start; i <= stop; i++)
          expanded.push (i);
       return expanded
    //alert(unranged_array);
    mySplit = unranged_array.split(',');
    for(var myCounter = 0; myCounter < mySplit.length; myCounter++) {
    myPageName = myDocument.pages.item(myCounter).name;
    //alert(myPageName)
    with(app.pdfExportPreferences) {
      pageRange = myPageName;
      viewPDF = false;
    myFilePath = myFolder + "/" + myDocumentName + "_" + myPageName + ".pdf";
    myFile = new File(myFilePath);
    myDocument.exportFile(ExportFormat.pdfType, myFile, false);
    And I even learned how to use the pre tag. Wow, this makes me wet :-)
    Thank you gentlemen, you are the best.
    Rasmus

  • BridgeTalk troubles

    I am trying to run an InDesign scirpt from Photoshop using a BridgeTalk example from Paul Riggott. The InDesign part works in ESTK with InDesign as the target but not as part of a Photoshop script through BridgeTalk.
    So I have some questions.
    1. What am I doing wrong?
    2. The script needs to work with both CS3 and CS4. Do I need to set the version in the BridgeTalk message.
    3. Is there a way to test if InDesign is running. Open it if not and close it if it wasn't already running.
    My code is bellow. It makes a multi page PDF for the list of 300px X 250px psd files on the desktop and saves the pdf there as well.
    var myImages = new Array();
    myImages.push(new File('~/Desktop/Layer Comp 1.psd'));
    myImages.push(new File('~/Desktop/Layer Comp 2.psd'));
    myImages.push(new File('~/Desktop/Layer Comp 3.psd'));
    myImages.push(new File('~/Desktop/Layer Comp 4.psd'));
    myImages.push(new File('~/Desktop/Layer Comp 5.psd'));
    myImages.push(new File('~/Desktop/Layer Comp 6.psd'));
    myImages.push(new File('~/Desktop/Layer Comp 7.psd'));
    myImages.push(new File('~/Desktop/Layer Comp 8.psd'));
    var pdfFile = new File('~/Desktop/myFirstTest.pdf')
    // adapted from Paul Riggott
    // Code for send message and handling response
    // in the sending application (any message-enabled application)
    var res = undefined;
    var bt = new BridgeTalk;
    bt.target = "indesign-6.0";
    // the script passed to the target application
    var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+myImages.toSource()+","+300+","+250+","+pdfFile+");");//define the work function and call it with arguments
    bt.body = myScript;
    bt.onResult = function( inBT ) {myReturnValue(inBT.body); }// call the result processing function
    // send the message and wait up to 10 sec for responce
    bt.send(20);
    // function to process the return string
    function myReturnValue(str){
         //process the results. here just assign strings
         res = str;
         caption = str;
    // wrap your script in a function
    // this function is in whatever DOM the bridgeTalk target is.
    // cann't have comments in the psRemote function
    function psRemote( images, w, h, pdfFile ){     
         function addDocument ( w, h ){
              var myDocument = app.documents.add(false);
              myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
              myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
              myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
              myDocument.documentPreferences.pageWidth = w;
              myDocument.documentPreferences.pageHeight = h;
              myDocument.documentPreferences.facingPages = false;
              var myMasterSpread = myDocument.masterSpreads.item(0);
              var myMarginPreferences = myMasterSpread.pages.item(0).marginPreferences;
              myMarginPreferences.left = 0;
              myMarginPreferences.top = 0;
              myMarginPreferences.right = 0;
              myMarginPreferences.bottom = 0;
              myMarginPreferences.columnCount = 1;
              myMarginPreferences.columnGutter = 0;
              myDocument.pages[0].appliedMaster = myMasterSpread;
              return myDocument;
         function addPage( doc ){
              var page = doc.pages.add();
              page.appliedMaster = NothingEnum.NOTHING;
              return page;
         function placeImage( doc, page, bounds, imageFile ){
              r = page.rectangles.add();
              r.geometricBounds = bounds;
              r.strokeWeight = 0;
              r.strokeColor = doc.swatches.item("None")
              r.place ( imageFile, false );
         function mySnippet( doc, pdfFile ){
              var myDocument = doc;
              with(app.pdfExportPreferences){
                   pageRange = PageRange.allPages;
                   acrobatCompatibility = AcrobatCompatibility.acrobat6;
                   exportGuidesAndGrids = false;
                   exportLayers = false;
                   exportNonPrintingObjects = false;
                   exportReaderSpreads = false;
                   generateThumbnails = false;
                   try{
                        ignoreSpreadOverrides = false;
                   catch(e){}
                   includeBookmarks = false;
                   includeHyperlinks = false;
                   includeICCProfiles = true;
                   includeSlugWithPDF = false;
                   includeStructure = false;
                   interactiveElements = false;
                   subsetFontsBelow = 0;
                   colorBitmapCompression = BitmapCompression.zip;
                   colorBitmapQuality = CompressionQuality.eightBit;
                   colorBitmapSampling = Sampling.none;
                   grayscaleBitmapCompression = BitmapCompression.zip;
                   grayscaleBitmapQuality = CompressionQuality.eightBit;
                   grayscaleBitmapSampling = Sampling.none;
                   monochromeBitmapCompression = BitmapCompression.zip;
                   monochromeBitmapSampling = Sampling.none;
                   compressionType = PDFCompressionType.compressNone;
                   compressTextAndLineArt = true;
                   contentToEmbed = PDFContentToEmbed.embedAll;
                   cropImagesToFrames = true;
                   optimizePDF = true;
                   bleedMarks = false;
                   colorBars = false;
                   cropMarks = false;
                   omitBitmaps = false;
                   omitEPS = false;
                   omitPDF = false;
                   pageInformationMarks = false;
                   pdfColorSpace = PDFColorSpace.unchangedColorSpace;
                   registrationMarks = false;
                   try{
                        simulateOverprint = false;
                   catch(e){}
                   useDocumentBleedWithPDF = false;
                   viewPDF = false;
              myDocument.exportFile( ExportFormat.pdfType, pdfFile, false );
         w = w+'pt';
         h = h+'pt';
         var bounds = ['0pt', '0pt', h, w ];
         var doc = addDocument( w, h );
         placeImage( doc, doc.pages.item(0), bounds, images[0] );
         if( images.length > 1 ){
              for( var i = 1; i < images.length; i++ ){
                   var page = addPage( doc );
                   placeImage( doc, page, bounds, images[i] );
         mySnippet( doc, pdfFile );
         doc.close(SaveOptions.NO);
         'done';

    Mike any bridgetalk message will launch the target app if its NOT already running as long as 'body' contains some string.
    In my ESTK data browser there are lots of options which come from the installed Adobe libraries for checking versioning etc.
    Does all this still exist in CS3 & CS4?
    In 'indesign4' [object Object] there is an 'isAppInstalledAndIsItTheLastestVersion' function() that I can use something like this…
    var getID = indesign4.isAppInstalledAndIsItTheLatestVersion('indesign', 4);
    if (getID) {
    alert('Correct Version of ID');
    if (!BridgeTalk.isRunning('indesign')) {
    BridgeTalk.launch('indesign');
    // indesign4.activate();
    // indesign4.executeScriptFile(scriptPath);
    else {
    alert('Incorrect Version of ID');
    I also have an 'apps' Array that I can check in…
    var x = apps[4];
    $.writeln(x);

  • How to edit xml link?

    First a few words about my context:
    I received a layout made on a CS3 version of InDesign. Now I am trying to create a procedure to automate the production of several pdf based on this layout. Manually the process would be to open the layout; edit the xml link with each xml source and create a corresponding pdf...
    First issue:
    In CS4 when I want to manually edit the xml link, the opened dialog prevent me (xml files are in gray) to select xml files, is it a well-known issue? How can I avoid it?
    Second question:
    How to edit the xml link from script?
    Last question - applescript question - :
    How to skip application dialogs? Like "This document miss some links, would you continue?"
    If you'd be able to help me, thanks in advance!

    Dear Loic_aigon
       Many thanks!
    But I used what you said!.
    But Still I'm facing the same problem [ not find : "image"]
    Here the below tag I used..
    <Figure id="f0020"><label>Figure 2 </label><caption>Dummy Figure </caption>
    <image href="C:/Program %20Files/VUG/clouds.jpg"></image></Figure>
    Program :
    //============== Start =====================//
    #include "E:/HariharaSudhan/XMDOM_TEST/xml_for_script-3.1/jsXMLParser/xmldom.js";
    var myFile = File("E:/HariharaSudhan/XMDOM_TEST/xml/test.xml");
    myFile.open("r");
    var myXMLString = String(myFile.read());
    var objDom = new XMLDoc(myXMLString, undefined);
    var domTree = objDom.docNode;
    $.writeln(domTree);
    var myImage = domTree.getElements("image");
    var myDoc = app.open(File("E:/HariharaSudhan/XMDOM_TEST/Indd/test.indd"), true);
    $.writeln(myImage);
    for(var i=0; i<myImage.length; i++)
    $.writeln( myImage[i].name);
    myImage[i].getAttribute("href").replace('file:///','');
      var myPage = doc.pages[0].duplicate(LocationOptions.AT_END);
      var myFrame = myPage.pageItems.item("image");
      myFrame.place(File(myImage[i].getAttribute("href").replace('file:///','')));
      app.pdfExportPreferences.pageRange = myPage.name;
      app.pdfExportPreferences.viewPDF  = false;
      myDoc.exportFile(ExportFormat.pdfType, File("E:/HariharaSudhan/XMDOM_TEST/PDF/" +(i+ 1)+".pdf"), undefined, undefined, undefined, undefined);
    myDoc.close(SaveOptions.NO);
    //===================== End ============================//
    So please kindly see the attached xml file, and please send me the solutions.
    Please this is my humble request.
    Thanks & Regards
    T.R.Harihara SudhaN

  • Strange behavior function Document.exportFile()

    My script uses the exportFile to get files PDF. Usually this is a fairly lengthy process.
    When you run the script sometimes disappear from the exported files attached pictures PDF. If at the time of export of the user presses any key on the keyboard is a strange case. From this point on the attached PDF-images disappear from the resulting exported PDF. The same thing occurs during the print to PostScript file.
    I wrote a little sketch showing the problem. You can download it here: http://zalil.ru/34525491
    Is not there a way to avoid this?

    Laubender wrote:
    @enbanat – what kind of method do you use to export to PDF?
    1. "exportFile()" //InDesign CS1 (?) and above
    or
    2. "asynchronousExportFile()" //InDesign CS5 and above
    Uwe, thanks for the idea! I will explore a method asynchronousExportFile.
    I use a very old script. Age of CS. It has been used for a long time and worked flawlessly. In versions of CS4+ began a strange error associated with typing on the keyboard while exports.
    Here is a small script written to demonstrate this.  He demands to him in the same folder was "PDF link.pdf". This file must be bigger than 1 MB.
    try {
              var scriptFolder = app.activeSctipt.parent;
    } catch (e) {
              var scriptFolder = (new File(e.fileName)).parent;
    var linkedFile = new File(scriptFolder.absoluteURI + '/PDF link.pdf');
    if (!linkedFile.exists) {
              alert('Error\nFile "PDF link.pdf" not found.');
              exit();
    if (linkedFile.length < 777777) {
              alert('Error\nFile "PDF link.pdf" too low. You need to use 1Mb PDF file.');
              exit();
    var exportFolder = new Folder(Folder.desktop + "/Extport Tests/" +
              (new Date()).toString().replace(/:/g, '-'));
    if (!exportFolder.create()) {
              alert('Error\nCan not create folder ' + File.decode(exportFolder));
              exit();
    if (Number(String(app.version).split('.')[0]) < 6) {
              alert('Start PDF export\n' +
                        'Please, type any text on you keyboard for test.\n' +
                        'Press ESC for exit.\n' +
                        'See test files in ' + File.decode(exportFolder));
    } else {
              // show dialog;
              var window = new Window('palette', 'test');
              window.alignChildren = 'left';
              window.add('statictext', undefined, 'PDF export started.');
              window.add('statictext', undefined, 'Please, type any text on you keyboard for test.');
              window.add('statictext', undefined, 'Press ESC for exit.');
              window.add('statictext', undefined, 'See test files in ' + File.decode(exportFolder));
    // make test document
    var document = app.documents.add();
    var page = document.pages[0];
    // do export
    app.pdfExportPreferences.pageRange = '1';
    var n = 0, errorsCounter = 0;
    while (true) {
              page.place(linkedFile);
              var file = new File(exportFolder.absoluteURI + '/' + ++n + '.pdf');
              document.exportFile(ExportFormat.PDF_TYPE, file, false);
              page.pageItems.everyItem().remove();
              window && window.show();
              $.sleep(111);
              if (file.length < 33333 && errorsCounter++) {
                        alert('Bingo!\nBroken file detected:\n' + file.fsName);
                        exportFolder.execute();
                        exit();

  • Help using tagged text in document in exported filename

    Hello, I am using the following script to export my Indesign documents as single page PDFs, and naming in a specific way:
    var pdfPreset = "<PDF_preset>";
    var exportPath = "<filepath>";
    var jobNumber = "XXXXXX_"
    for (aPage=0; aPage < app.activeDocument.pages.length; aPage++)
    app.pdfExportPreferences.pageRange = app.activeDocument.pages[aPage].name;
    app.activeDocument.exportFile (ExportFormat.PDF_TYPE, File(exportPath+"/"+jobNumber+pad(app.activeDocument.pages[aPage].name)+".pdf"), false, pdfPreset);
    function pad (n) {
        return ("00000"+n).slice(-3);
    This will output the filenames as XXXXXX_002-003, etc, where XXXXXX is the customers ID number.
    Instead of typing in each customers ID number in the script, I want to tag a text box within the document that contains only the customer's job number, then use the contents of that text box as the jobNumber variable.
    How can I do that?

    There are many ways of "tagging" information in an InDesign document. For what you're doing, I'd suggest a unique paragraph style used only for this purpose, then you can search for text in it and use the contents.
    Dave

  • Page Exporter Utility (PEU) 5 Script

    I love this script, It really has potential to shave valuable time off of our production (exporting Hundreds of pages manually to single files is tedious and time consuming). The problem I'm having is I'm hesitant to us it because it dosn't show warnings when there is a missing link or font. There's also no warning when it overwrites a file. My question is dose anyone know how to unsuppress the warnings? I've looked over the script and don't see anything that is actively suppressing them.
    Thanks
    Dan
    // PageExporterUtility5.0.js
    // An InDesign CS JavaScript
    // 08 NOV 2007
    // Copyright (C) 2007  Scott Zanelli. Lonelytree Software. (www.lonelytreesw.com)
    // Coming to you from Quincy, MA, USA
    // This program is free software; you can redistribute it and/or
    // modify it under the terms of the GNU General Public License
    // as published by the Free Software Foundation; either version 2
    // of the License, or (at your option) any later version.
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    // You should have received a copy of the GNU General Public License
    // along with this program; if not, write to the Free Software
    // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    var peuINFO = new Array();
    peuINFO["csVersion"] = parseInt(app.version);
    // Save the old interaction level
    if(peuINFO.csVersion == 3) { //CS1
        peuINFO["oldInteractionPref"] = app.userInteractionLevel;
        app.userInteractionLevel = UserInteractionLevels.interactWithAll;
    else { //CS2+
        peuINFO["oldInteractionPref"] = app.scriptPreferences.userInteractionLevel;
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    // See if a document is open. If not, exit
    if((peuINFO["numDocsToExport"] = app.documents.length) == 0){
        byeBye("Please open a document and try again.",true);
    // Global Variable Initializations
    var VERSION_NAME = "Page Exporter Utility 5.0"
    var pseudoSingleton = 0;
    var progCurrentPage = 0;// Used for progress bar
    var progTotalPages = 0; // Used for progress bar
    var commonBatchINFO = getNewTempENTRY(); // Used if "Set For All Batch Jobs" is selected
    commonBatchINFO["infoLoaded"] = false;
    peuInit(); // Initialize commonly needed info
    // Store information needed for batch processing (valid for single also)
    var printINFO = new Array();
    // Get all needed info by looping for each document being exported
    for(currentDoc = 0; currentDoc < peuINFO.numDocsToExport; currentDoc++) {
        // Get name of document and set it as the base name
        // minus the extention if it exists
        var tempENTRY = getNewTempENTRY(); // "Struct" for current document info
        tempENTRY.theDoc = app.documents[currentDoc]
        tempENTRY.singlePage = (tempENTRY.theDoc.documentPreferences.pagesPerDocument==1)?true:false;
        tempENTRY.getOut = true;
        var baseName = (tempENTRY.theDoc.name.split(".ind"))[0];
        // Display the dialog box and loop for correct info
        if((!commonBatchINFO.infoLoaded && peuINFO.batchSameForAll) || (!peuINFO.batchSameForAll) ){// get all info
            do{
                tempENTRY.getOut = true; // For handling input errors
                var mainDialog = createMainDialog(tempENTRY.theDoc.name, currentDoc+1, peuINFO.numDocsToExport);
                // Exit if cancel button chosen
                if(!mainDialog.show() ){
                    mainDialog.destroy();
                    byeBye("Exporting has canceled by user.",peuINFO.sayCancel);
                if(formatTypeRB.selectedButton == 4 - peuINFO.adjustForNoPS){
                    changePrefs();
                    tempENTRY.getOut = false;
                    continue;
                // Read info from dialog items and keep as defaults and place in tempENTRY
                peuINFO.defaultDir = outputDirs.selectedIndex;
                // The index of the selected directory is the same as the
                // index in the array of directories.
                tempENTRY.outDir = peuINFO.dirListArray[peuINFO.defaultDir];
                // Type of renaming to do
                tempENTRY.nameConvType = namingConvention.selectedButton
                // The base name to add page info to
                tempENTRY.baseName = removeColons(removeSpaces(newBaseName.editContents) );
                // The start [and end] page numbers
                var startEndPgs = startEndPgs.editContents;
                // Wether to do spreads or not
                peuINFO.doSpreadsON = (doSpreads.checkedState)?1:0;
                tempENTRY.doSpreadsON = peuINFO.doSpreadsON;
                // Wether to send entire file as one document
                peuINFO.doOneFile = (oneFile.checkedState)?1:0;
                tempENTRY.doOneFile = peuINFO.doOneFile;
                // Export format type
                tempENTRY.formatType = formatTypeRB.selectedButton + peuINFO.adjustForNoPS;
                // Set persistence during warnings
                peuINFO.editStartEndPgs = startEndPgs;
                baseName = tempENTRY.baseName;
                peuINFO.exportDefaultType = tempENTRY.formatType;
                // Determine if page replacement token exists when the page token option is used
                if(peuINFO.pageNamePlacement == 2){
                    var temp = tempENTRY.baseName.indexOf("<#>");
                    if(temp == -1){//Token isn't there
                        alert("There is no page item token (<#>) in the base name. Please add one or change the page naming placement preference.");
                        tempENlert.getOut = false;
                        pseudoSingleton--; // Allow prefs to be accessed again, but just once
                        continue;
                    else
                        pseudoSingleton++;
                else // Try to remove any <#>s as a precaution
                    tempENTRY.baseName = tempENTRY.baseName.replace(/<#>/g,"");   
                // Layer Versioning & Batch options
                if(currentDoc < 1){
                    peuINFO.layersON = (doLayers.checkedState)?1:0;
                    if(peuINFO.numDocsToExport > 1){
                        peuINFO.batchSameForAll = (commonBatch.checkedState)?1:0;
                        peuINFO.batchON = (doBatch.checkedState)?1:0;
                        if(!peuINFO.batchON)
                            peuINFO.numDocsToExport = 1;
                //Check if spreads chosen with 'Add ".L"' option as this isn't supported.
                if(peuINFO.doSpreadsON && tempENTRY.nameConvType == 1){
                    alert ("Spreads cannot be used with the 'Add \".L\"' option.\nThis combination is not supported. (1.1)");
                    tempENTRY.nameConvType = 0;
                    tempENTRY.getOut = false;
                    continue;
                else if(peuINFO.doSpreadsON && tempENTRY.nameConvType == 4){
                    alert ("Spreads cannot be used with the 'Numeric Override' option.\nThis combination is not supported. (1.2)");
                    tempENTRY.nameConvType = 0;
                    tempENTRY.getOut = false;
                    continue;
                // Check if "Send Entire File At Once" is selected with JPG or EPS
                if(peuINFO.doOneFile && tempENTRY.formatType > 1 ){
                    alert ("The 'Send Entire File At Once' option can only be used with PostScript or PDF formats. (1.3)");
                    tempENTRY.getOut = false;
                    continue;
                // Check if: batch printing and using the "Same for all jobs options" and a page range other than "All" was used
                if(peuINFO.doBatch && peuINFO.batchSameForAll && startEndPgs != "All"){
                    alert ("The 'Set For All Batch Jobs' option can only be used with a Page Range of 'All'. Page Range has been reset to 'All'. (1.4)");
                    startEndPgs = "All";
                // Create page info, skip if doing entire file as one
                var tempPageCount = 0;
                if(tempENTRY.doOneFile)
                    tempPageCount = 1;
                else{
                    // Get names of all the pages. Needed when pages are named using sectioning
                    tempENTRY = recordPgNames(tempENTRY);
                    // Check Page Validity and get Page counts of entered section(s)
                    var temp = checkPages(tempENTRY, startEndPgs);
                    tempENTRY = temp[0];
                    tempPageCount = temp[1];
                    temp = null; // Free it up
            } while(!tempENTRY.getOut);
            // Remove dialog from memory
            mainDialog.destroy();
            // Determine if tag will fit correctly
            tempENTRY.useTag = usePgInfoTag(tempENTRY.theDoc.viewPreferences.horizontalMeasurementUnits,tempENTRY.theDoc.documentPreferences.pageWidth);
                // Get the format info for this document
            switch(tempENTRY.formatType){
                case 0://PS
                tempENTRY.psINFO = getPSoptions(tempENTRY.theDoc.name.split(".ind")[0]);
                break;
                case 1://PDF
                tempENTRY.pdfPRESET = getPDFoptions(tempENTRY);
                break;
                case 2: // EPS Formatting
                tempENTRY.epsINFO = getEPSoptions(tempENTRY.theDoc.name.split(".ind")[0]);
                peuINFO.origSpread = app.epsExportPreferences.epsSpreads;// Used to reset to original state when done
                app.epsExportPreferences.epsSpreads = peuINFO.doSpreadsON;
                break;
                case 3: // JPEG Formatting
                tempENTRY.jpegINFO = getJPEGoptions(tempENTRY.theDoc.name.split(".ind")[0]);
                break;
            // If Specific Directory was chosen for the output directory, get it now
            if(peuINFO.defaultDir == 0){
                tempENTRY.outDir = getDirectory("Please select the output directory:",peuINFO.startingDirectory);
                if(tempENTRY.outDir != null)
                    tempENTRY.outDir += "/";
                else
                    byeBye("Exporting has been canceled by user.", peuINFO.sayCancel);
            // Set the common elements for all batch jobs if it was selected
            if(!commonBatchINFO.infoLoaded && peuINFO.batchSameForAll){
                commonBatchINFO.infoLoaded = true;
                commonBatchINFO.pageNamePlacement = tempENTRY.pageNamePlacement;
                commonBatchINFO.outDir = tempENTRY.outDir;
                commonBatchINFO.nameConvType = tempENTRY.nameConvType
                commonBatchINFO.doSpreadsON = tempENTRY.doSpreadsON;
                commonBatchINFO.doOneFile = tempENTRY.doOneFile;
                commonBatchINFO.formatType = tempENTRY.formatType;
                commonBatchINFO.psINFO = tempENTRY.psINFO;
                commonBatchINFO.pdfPRESET = tempENTRY.pdfPRESET
                commonBatchINFO.epsINFO = tempENTRY.epsINFO
                commonBatchINFO.jpegINFO = tempENTRY.jpegINFO;
        } // End each/first of batch
        else{ // Get the base name for other batch jobs
            do{
                tempENTRY.getOut = true;
                var nameDialog = app.dialogs.add({name:(VERSION_NAME + ": Base Name for \"" + tempENTRY.theDoc.name + "\"" + ((peuINFO.numDocsToExport==1)?"":" (" + (currentDoc+1) + " of " + peuINFO.numDocsToExport + " documents)") ), canCancel:true} );
                with (nameDialog){
                    with (dialogColumns.add() ){
                        with(dialogRows.add() ){
                        staticTexts.add({staticLabel:"Enter the Base Name for \"" + tempENTRY.theDoc.name + "\""} );
                        var newBaseName = textEditboxes.add({editContents:baseName, minWidth:135} );
                        with(dialogRows.add() )
                            staticTexts.add({staticLabel:"", minWidth:400} );
                if(!nameDialog.show() ){
                    nameDialog.destroy();
                    byeBye("User canceled export.",peuINFO.sayCancel);
                else{
                    tempENTRY.baseName = removeColons(removeSpaces(newBaseName.editContents) );
                    nameDialog.destroy();
                    // Determine if page replacement token exists when the page token option is used
                    if(peuINFO.pageNamePlacement == 2){
                        var temp = tempENTRY.baseName.indexOf("<#>");
                        if(temp == -1){//Token isn't there
                            alert("There is no page item token (<#>) in the base name. Please add one or click cancel in the next dialog box.");
                            tempENTRY.getOut = false;
                    else // Try to remove any <#>s as a precaution
                        tempENTRY.baseName = tempENTRY.baseName.replace(/<#>/g,"");   
            }while(!tempENTRY.getOut);
            // Get names of all the pages. Needed when pages are named using sectioning
            tempENTRY = recordPgNames(tempENTRY);
            // Set pgStart and pgEnd, forcing "All" pages to output
            tempENTRY = (checkPages(tempENTRY, "All"))[0];
            // The page count is all pages due to common batching
            tempPageCount = tempENTRY.theDoc.pages.length;
            // This info is common, get it from commonBatchINFO:
            tempENTRY.pageNamePlacement = commonBatchINFO.pageNamePlacement;
            tempENTRY.outDir = commonBatchINFO.outDir;
            tempENTRY.nameConvType = commonBatchINFO.nameConvType
            tempENTRY.doSpreadsON = commonBatchINFO.doSpreadsON;
            tempENTRY.doOneFile = commonBatchINFO.doOneFile;
            tempENTRY.formatType = commonBatchINFO.formatType;
            tempENTRY.psINFO = commonBatchINFO.psINFO;
            tempENTRY.pdfPRESET = commonBatchINFO.pdfPRESET
            tempENTRY.epsINFO = commonBatchINFO.epsINFO
            tempENTRY.jpegINFO = commonBatchINFO.jpegINFO;
        // Get any layering info
        if(peuINFO.layersON){
            tempENTRY.layerINFO = layerManager(tempENTRY.theDoc);
            if (tempENTRY.layerINFO == null) // Only one layer, turn it off for this doc
                tempENTRY.layersON = false;
            else
                tempENTRY.layersON = true;
        // Sum up pages for the grand total for use in progress bar
        var temp = 1;
        if(peuINFO.doProgressBar && tempENTRY.layersON){
            // Figure tally for progress bar to include versions
            for(i=0;i < tempENTRY.layerINFO.verControls.length; i++)
                if (tempENTRY.layerINFO.verControls[i] == 1)
                    temp++;
            if(!peuINFO.baseLaersAsVersion)
                temp--;
        progTotalPages += (tempPageCount*temp);
        // All info for this doc is finally gathered, add it to the main printINFO array
        printINFO.push(tempENTRY);
        // Only one chance to change prefs: trigger singleton
        pseudoSingleton++;
    }// end of main for loop
    savePrefs(); // Record any changes
    // Initiallize progress bar if available
    if(peuINFO.doProgressBar)
        app.createProgressBar("Exporting Pages...", 0, progTotalPages, true);
    // Export by looping through all open documents if using batch option, otherwise just the front document is exported
    for(currentDoc = 0; currentDoc < printINFO.length; currentDoc++){
        var currentINFO = printINFO[currentDoc];
        // Set message in progress bar if available
        if(peuINFO.doProgressBar){
                var progCancel = app.setProgress(currentINFO.theDoc.name);
                if(progCancel)
                    byeBye("User canceled export.",peuINFO.sayCancel);
        // Set format options here so it's done just once per document
        setExportOption(currentINFO);
        // "Do one file" or PS/PDF with one page:
        if (currentINFO.doOneFile || currentINFO.singlePage){
            // Remove page token if it was entered and this name positioning option is set
            currentINFO.baseName = currentINFO.baseName.replace(/<#>/g,"");
            if(currentINFO.layersON){
                var theLayers = currentINFO.theDoc.layers;
                var baseControls = currentINFO.layerINFO.baseControls;
                var versionControls = currentINFO.layerINFO.verControls;
                var lastVersion = -1;
                // Loop for versioning
                 for(v = 0; v < versionControls.length; v++){
                    if(!versionControls[v])
                        continue;
                    if(lastVersion != -1)// Turn the last layer back off
                        theLayers[lastVersion].visible = false;
                    lastVersion = v;
                    theLayers[v].visible = true;
                    currentINFO.outfileName = addPartToName(currentINFO.baseName, theLayers[v].name, peuINFO.layerBeforeON)
                    // Export this version
                    exportPage(currentINFO, PageRange.allPages);
                    // Advance progress bar if available
                    if(peuINFO.doProgressBar)
                        advanceBar();
                // If Base layer/s is/are to be output as a version, do it now
                if(peuINFO.baseLaersAsVersion){
                    lastVersion = -1;
                    // Turn off all versioning layers
                    for(v = 0; v < currentINFO.layerINFO.baseControls.length; v++){
                        if(currentINFO.layerINFO.baseControls[v])// its a base layer, keep track of last base version layer number
                            lastVersion = v;
                        else
                            theLayers[v].visible = false;
                    if (!lastVersion == -1){// Only export if there was a base version
                        currentINFO.outfileName = addPartToName(currentINFO.baseName, theLayers[lastVersion].name, peuINFO.layerBeforeON);
                        // Export the base layer(s)
                        exportPage(currentINFO, PageRange.allPages);
                        // Advance progress bar if available
                        if(peuINFO.doProgressBar)
                            advanceBar();
            else{ // No layer versioning, just export
                currentINFO.outfileName = currentINFO.baseName;
                // Export the base layer(s)
                exportPage(currentINFO, PageRange.allPages);
                // Advance progress bar if available
                if(peuINFO.doProgressBar)
                    advanceBar();
            if(!peuINFO.batchON)
                byeBye("Done exporting as a single file.",true);
        else{ // Do single pages/spreads
            if (!currentINFO.hasNonContig)
                // Pages are contiguous, can just export
                outputPages(currentINFO.pgStart, currentINFO.pgEnd, currentINFO);
            else{ // Export non-contiguous
                // Loop through array of page sections
                for (ii = 0; ii < currentINFO.nonContigPgs.length; ii++){
                    temp = currentINFO.nonContigPgs[ii];
                    // Here we handle the start/end pages for any non-contig that has "-"
                    if (temp.indexOf("-") != -1){
                        temp2 = temp.split("-");
                        outputPages(temp2[0],temp2[1], currentINFO);
                    else // The non-contiguous page is a single page
                        outputPages(temp, temp, currentINFO);
        // Set the spread settings back to what it was originally
        try{
            switch (currentINFO.formatType){
                case 0: // PostScript Formatting
                    theDoc.printPreferences.printSpreads = peuINFO.origSpread;
                    break;
                case 1: // PDF Formatting
                    currentINFO.pdfPRESET.exportReaderSpreads = peuINFO.origSpread;
                    break;
                case 2: // EPS Formatting
                    app.epsExportPreferences.epsSpreads = peuINFO.origSpread;
                    break;
                case 3: // JPEG Formatting
                    app.jpegExportPreferences.exportingSpread = peuINFO.origSpread;
                    break;
        catch(e){/*Just ignore it*/}
    byeBye("The requested pages are done being exported.",true); // Last line of script execution
    /*         Operational Functions           */
    * Handle exporting
    function outputPages(pgStart, pgEnd, currentINFO){
        var pgRange;
        var layerName = "";
        var numVersions;
        var currentPage;
        var lastVersion = -1;
        var numericallyLastPage;
        if (currentINFO.layersON){
            var theLayers = currentINFO.theDoc.layers;
            var baseControls = currentINFO.layerINFO.baseControls;
            var versionControls = currentINFO.layerINFO.verControls;
            numVersions = versionControls.length;
            // Compensate for base layers as a version
            if(peuINFO.baseLaersAsVersion)
                numVersions++;
        else
            numVersions = 1;
        for (v = 0; v < numVersions; v++){
            if(currentINFO.layersON){
                if(v == (numVersions - 1) && peuINFO.baseLaersAsVersion){
                    var currentLayer = -1;
                    // Base layer(s) are to be output as a version
                    // Turn off all versioning layers
                    for(slbm = 0; slbm < baseControls.length; slbm++){
                        if(baseControls[slbm])// its a base layer, use its name for page name
                            currentLayer = slbm;
                        else
                            theLayers[slbm].visible = false;
                    // Check if there was no base layer at all
                    if (currentLayer == -1)
                        layerName = "**NO_BASE**"
                    else
                        layerName = theLayers[currentLayer].name;
                else{
                    if(!versionControls[v])
                        continue;
                    if(lastVersion != -1)// Turn the last layer back off
                        theLayers[lastVersion].visible = false;
                    lastVersion = v;
                    theLayers[v].visible = true;
                    layerName = theLayers[v].name;
            if (currentINFO.nameConvType == 4){
                currentPage = pgStart;
                numericallyLastPage = pgEnd;
            else if (currentINFO.doSpreadsON){
                currentPage = pgStart - 1;
                numericallyLastPage = pgEnd;
            else {
                currentPage = getPageOffset(pgStart, currentINFO.pageNameArray , currentINFO.pageRangeArray);
                numericallyLastPage = getPageOffset(pgEnd, currentINFO.pageNameArray, currentINFO.pageRangeArray);
            if(layerName != "**NO_BASE**"){
                do{
                    currentINFO.outfileName = getPageName(currentPage, layerName, currentINFO);
                    if (currentINFO.doSpreadsON){
                        pgRange = currentINFO.pageRangeArray[getPageOffset(currentINFO.theDoc.spreads[currentPage].pages[0].name, currentINFO.pageNameArray, currentINFO.pageRangeArray)];
                    else if (currentINFO.nameConvType == 4)
                        pgRange = currentINFO.pageRangeArray[currentPage-1];
                    else
                        pgRange = currentINFO.pageRangeArray[currentPage];
                    // Do the actual export:
                    exportPage(currentINFO, pgRange);
                    // Update progress bar if available
                    if(peuINFO.doProgressBar)
                        advanceBar();
                    currentPage++;
                } while(currentPage <= numericallyLastPage);
    * Export the page
    function exportPage(currentINFO, pgRange){
        var outFile = currentINFO.outDir + currentINFO.outfileName;
        switch (currentINFO.formatType){
            case 0: // PostScript Formatting
                with(currentINFO.theDoc.printPreferences){
                    printFile = new File(outFile + ((currentINFO.psINFO.ext)?".ps":""));
                    pageRange = pgRange;
                // Needed to get around blank pages using separations
                try{
                    currentINFO.theDoc.print(false);
                catch(e){/*Just skip it*/}
                break;
            case 1: // PDF Formatting
                app.pdfExportPreferences.pageRange = pgRange;
                currentINFO.theDoc.exportFile(ExportFormat.pdfType, (new File(outFile + ".pdf")), false, currentINFO.pdfPRESET);
                break;
            case 2: // EPS Formatting
                app.epsExportPreferences.pageRange = pgRange;
                currentINFO.theDoc.exportFile(ExportFormat.epsType, (new File(outFile + ".eps")), false);
                break;
            case 3: // JPEG Formatting
                if(pgRange == PageRange.allPages){
                    app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportAll;
                else{
                    app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
                    app.jpegExportPreferences.pageString = pgRange;
                currentINFO.theDoc.exportFile(ExportFormat.jpg, (new File(outFile + ".jpg")), false);
                break;
    * Create a name for the page being exported
    function getPageName(currentPage, layerName, currentINFO){
        var pgRename = "";
        if (currentINFO.doSpreadsON)
            currentINFO["currentSpread"] = currentINFO.theDoc.spreads[currentPage].pages;
        switch (currentINFO.nameConvType){
            case 3: // Odd/Even pages/spreads = .LA.F/LA.B, LB.F/LB.B ...
                pgRename = makeLotName(currentPage+1, peuINFO.subType);
                break;
            case 2: // Odd/Even pages/spreads = .F/.B
                pgRename = ((currentPage+1)%2 == 0) ? "B" : "F";
                break;
            case 1: // Add ".L" to the page name
                pgRename = "L" + currentINFO.pageNameArray[currentPage];
                break;
            case 0: case 4:// As is or Numeric Override
                            // Optionally add "P" and any zeros if options chosen and is numerically named
                            // otherwise, just the "seperatorChar" is added to page name
                if (currentINFO.doSpreadsON){
                    // Loops through number of pages per spread
                    // and adds each page name to the final name (P08.P01)
                    for (j = 0; j < currentINFO.currentSpread.length; j++){
                        if(currentINFO.currentSpread[j].appliedSection.includeSectionPrefix)
                            var tempPage = currentINFO.pageRangeArray[getPageOffset(currentINFO.currentSpread[j].name, currentINFO.pageNameArray, currentINFO.pageRangeArray)];
                        else
                            var tempPage = currentINFO.pageNameArray[getPageOffset(currentINFO.currentSpread[j].name, currentINFO.pageNameArray, currentINFO.pageRangeArray)];
                        var tempPageNum = parseInt(tempPage,10);
                        /* If section name starts with a number, need to compare length of orig vs parsed
                         * to see if the page name is solely a number or a combo num + letter, etc.
                        if (! isNaN(tempPageNum) && ((""+tempPage).length == (""+tempPageNum).length )){
                            if (peuINFO.addZeroON)
                                tempPage = addLeadingZero(tempPageNum, currentINFO.theDoc.pages.length);
                            if (peuINFO.addPon)
                                tempPage = "P" + tempPage;
                        pgRename = (j==0) ? tempPage : pgRename + peuINFO.charList[peuINFO.seperatorChar] + tempPage;
                else {
                    // Create a new name for an individual page
                    if (currentINFO.nameConvType == 4)
                        pgRename = currentPage;
                    else
                        pgRename = currentINFO.pageNameArray[currentPage];
                    if (! isNaN(parseInt(pgRename,10)) && (""+pgRename).length == (""+parseInt(pgRename,10)).length) {
                        if (peuINFO.addZeroON)
                            pgRename = addLeadingZero(pgRename, currentINFO.theDoc.pages.length);
                        if (peuINFO.addPon)
                            pgRename = "P" + pgRename;
                break;
        if(currentINFO.layersON)
            pgRename = addPartToName(pgRename, layerName, peuINFO.layerBeforeON);
        // Add page name to base name based on option selected
        if(peuINFO.pageNamePlacement == 2)
            pgRename = removeColons(currentINFO.baseName.replace(/<#>/g,pgRename) );
        else
            pgRename = addPartToName(currentINFO.baseName, pgRename,peuINFO.pageNamePlacement);
        return pgRename;
    * Add a name part before or after a given base string
    function addPartToName(theBase, addThis, addBefore){
        //Remove any colons
        theBase = removeColons(theBase);
        addThis = removeColons(addThis);
        return (addBefore) ? (addThis + peuINFO.charList[peuINFO.seperatorChar] + theBase ):(theBase + peuINFO.charList[peuINFO.seperatorChar] + addThis);
    * Find the offset page number for a page by its name
    function getPageOffset(pgToFind, pageNameArray, pageRangeArray){
        var offset;
        for(offset = 0; offset<pageRangeArray.length;offset++){
            if((""+ pgToFind).toLowerCase() == (("" + pageNameArray[offset]).toLowerCase() ) || (""+ pgToFind).toLowerCase() == (("" + pageRangeArray[offset]).toLowerCase() ) )
                return offset;
        return -1;
    * Replace any colons with specialReplaceChar
    function removeColons(tempName){
        return tempName.replace(/:/g,peuINFO.charList[peuINFO.specialReplaceChar]);
    * Remove spaces from front and end of name
    function removeSpaces(theName){
        // Trim any leading or trailing spaces in base name
        var i,j;
        for(i = theName.length-1;i>0 && theName.charAt(i) == " ";i--);// Ignore any spaces on end of name
        for(j = 0; j<theName.length && theName.charAt(j) == " ";j++);// Ignore any spaces at front of name
        theName = theName.substring(j,i+1);
        return theName
    * Add leading zero(s)
    function addLeadingZero(tempPageNum, pageCount){
        if(peuINFO.zeroPadding == 0){
            // Normal padding
            if((tempPageNum < 10 && pageCount < 100) || (tempPageNum > 9 && pageCount > 99 && tempPageNum < 100))
                return addSingleZero(tempPageNum);
            else if(tempPageNum < 10 && pageCount > 99)
                return addDoubleZero(tempPageNum);
            else
                return ("" + tempPageNum);
        }else if(peuINFO.zeroPadding == 1){
            // Pad to 2 digits
            if(tempPageNum < 10)
                return addSingleZero(tempPageNum);
            else
                return ("" + tempPageNum);
        }else{
            // Pad to 3 digits
            if(tempPageNum < 10)
                return addDoubleZero(tempPageNum);
            else if(tempPageNum < 100)
                return addSingleZero(tempPageNum);
            else
                return ("" + tempPageNum);
    * Add leading zero helper for single
    function addSingleZero(pgNum){
        return ("0" + pgNum);
    * Add leading zero helper for double
    function addDoubleZero(pgNum){
        return ("00" + pgNum);
    * Create lot name from page number
    function makeLotName(thePage, subType){
        var iii = thePage;
        var curr = 0;
        var alphaBet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        var lotName = "L";
        if(subType == 0){
            while(iii>52){
                curr = Math.floor((iii-1)/52)-1;
                lotName += alphaBet[curr];
                if(curr >= 0)
                    iii -= 52*(1+curr);
                else
                    iii -= 52;
            lotName += alphaBet[Math.floor((iii-1)/2)%26];
        else
            for(iii=thePage; iii>0; iii-=52)
                lotName += alphaBet[Math.floor((iii-1)/2)%26];
        return lotName += (thePage & 0x1)?".F":".B";
    * Advance progress bar one unit
    function advanceBar(){
        var progCancel = app.setProgress(++progCurrentPage);
        if(progCancel)
            byeBye("User canceled export.",peuINFO.sayCancel);
    * Create an Empty tempENTRY "struct"
    function getNewTempENTRY(){
        var newTempENTRY = new Array();
        newTempENTRY["theDoc"] = null;
        newTempENTRY["singlePage"] = null;
        newTempENTRY["getOut"] = null;
        newTempENTRY["outDir"] = null;
        newTempENTRY["outfileName"] = "";
        newTempENTRY["nameConvType"] = null;
        newTempENTRY["baseName"] = null;
        newTempENTRY["doSpreadsON"] = null;
        newTempENTRY["doOneFile"] = null;
        newTempENTRY["formatType"] = null;
        newTempENTRY["layersON"] = null;
        newTempENTRY["hasNonContig"] = false;
        newTempENTRY["nonContigPgs"] = null;
        newTempENTRY["pageNameArray"] = new Array();
        newTempENTRY["pageRangeArray"] = new Array();
        newTempENTRY["psINFO"] = null;
        newTempENTRY["pdfPRESET"] = null;
        newTempENTRY["epsINFO"] = null;
        newTempENTRY["jpegINFO"] = null;
        newTempENTRY["layerINFO"] = null;
        newTempENTRY["useTag"] = null;
        newTempENTRY["pgStart"] = null;
        newTempENTRY["pgEnd"] = null;
        return newTempENTRY;
    * Record all the page/spread names
    function recordPgNames(tempENTRY){
            // Get names of all the pages. Needed when pages are named using sectioning
        for (i = 0; i < tempENTRY.theDoc.documentPreferences.pagesPerDocument; i++){
            var aPage = tempENTRY.theDoc.pages.item(i);
            tempENTRY.pageNameArray[i] = aPage.name;
            tempENTRY.pageRangeArray[i] = (aPage.appliedSection.includeSectionPrefix)? aPage.name : (aPage.appliedSection.name + aPage.name);
        return tempENTRY;
    * Set the export options
    function setExportOption(currentINFO){
            // Set any options here instead of with each page
        switch (currentINFO.formatType){
            case 0: // PostScript Formatting
                setPSoptions(currentINFO);
                break;
            case 1: // PDF Formatting
                // Nothing to do
                break;
            case 2: // EPS Formatting
                setEPSoptions(currentINFO.epsINFO);
                break;
            case 3: // JPEG Formatting
                setJPEGoptions(currentINFO.jpegINFO);
                break;
    * Get PostScript format options
    function getPSoptions(docName){
        var psOptions = new Array();
        psOptions["ignore"] = true;
        var tempGetOut, PSdlog, pgHeight, pgWidth;
        var changeAddPSextention, tempBaseName;
        var printPreset;
        do{
            tempGetOut = true;
            PSdlog = app.dialogs.add({name:"PostScript Options for \"" + docName + "\"", canCancel:true} );
            with (PSdlog)
                with (dialogColumns.add() ){
                    with (dialogRows.add() )
                        staticTexts.add({staticLabel:"Print Presets:"} );
                    printPreset = dropdowns.add({stringList:peuINFO.psPrinterNames , minWidth:236, selectedIndex:peuINFO.defaultPrintPreset} );
                    with (dialogRows.add() )
                        staticTexts.add({staticLabel:"Override PS Page Size (" + peuINFO.measureLableArray[peuINFO.measurementUnits] + ")"} );
                    with (borderPanels.add() )
                        with (dialogColumns.add() )
                            with (dialogRows.add() ){
                                staticTexts.add({staticLabel:"Width:", minWidth:45} );
                                pgWidth = textEditboxes.add({editContents:"0", minWidth:53} );
                                staticTexts.add({staticLabel:"Height:", minWidth:45} );
                                pgHeight = textEditboxes.add({editContents:"0", minWidth:54} );
                    with (dialogRows.add() ){
                        staticTexts.add({staticLabel:"Add \".ps\" to end of file name"} );
                        changeAddPSextention = dropdowns.add({stringList:["No","Yes"], selectedIndex:peuINFO.addPSextention} )
            if((PSdlog.show()) ){
                // Get the page height + width
                pgHeight = parseFloat(pgHeight.editContents);
                pgWidth = parseFloat(pgWidth.editContents);
                // Check entered H & W for error
                if(isNaN(pgHeight) || isNaN(pgWidth) || pgHeight < 0 || pgWidth < 0 ){
                    alert ("Both page height and width must be numeric and greater than zero (3.1).");
                    pgHeight = "0";
                    pgWidth  = "0";
                    tempGetOut = false;
                    continue;
                if(pgHeight > 0 && pgWidth > 0) // User changed size, use the new size
                    psOptions.ignore = false;
                psOptions["height"] = pgHeight + peuINFO.measureUnitArray[peuINFO.measurementUnits];
                psOptions["width"] = pgWidth + peuINFO.measureUnitArray[peuINFO.measurementUnits];
                psOptions["ext"] = changeAddPSextention.selectedIndex;
                peuINFO.addPSextention = psOptions["ext"];
                psOptions["preset"] = printPreset.selectedIndex
                peuINFO.defaultPrintPreset = psOptions.preset;
                savePrefs();
                PSdlog.destroy();
            else{
                PSdlog.destroy();
                byeBye("Exporting has been canceled by user.",peuINFO.sayCancel);
        } while(!tempGetOut);
        return psOptions;
    * Set Postscript options
    function setPSoptions(theINFO){
        with(currentINFO.theDoc.printPreferences){
            activePrinterPreset = peuINFO.csPSprinters[theINFO.psINFO.preset];
            peuINFO.origSpread = printSpreads; // Used to reset to original state when done
            printSpreads = theINFO.doSpreadsON;
            if(colorOutput != ColorOutputModes.separations && colorOutput != ColorOutputModes.inripSeparations)
                printBlankPages = true;
            if (theINFO.useTag)
                pageInformationMarks = true;
            else
                pageInformationMarks = false;
            if(!theINFO.psINFO.ignore){
                try{
                    paperSize = PaperSizes.custom;
                    paperHeight = theINFO.psINFO.height;
                    paperWidth = theINFO.psINFO.width;
                catch(Exception){
                    alert ("The current PPD doesn't support custom page sizes. The page size from the Print Preset will be used (3.2).");
    * Get PDF options
    function getPDFoptions(theINFO){
        var PDFdlog = app.dialogs.add({name:"PDF Options for \"" + theINFO.theDoc.name.split(".ind")[0] + "\"", canCancel:true} );
        var temp = new Array();
        for(i=0;i<app.pdfExportPresets.length;i++)
            temp.push(app.pdfExportPresets[i].name);
        // Test if default PDFpreset is greater # than actual list.
        // This occurs if one was deleted and the last preset in the list was the default
        if(peuINFO.defaultPDFpreset > temp.length-1)
            peuINFO.defaultPDFpreset = 0;
        with (PDFdlog)
            with (dialogColumns.add() ){
                with (dialogRows.add() )
                    staticTexts.add({staticLabel:"PDF Export Preset:"} );
                pdfPresets = dropdowns.add({stringList: temp, minWidth:50, selectedIndex:peuINFO.defaultPDFpreset} );
        if(PDFdlog.show() ){
            temp = app.pdfExportPresets[pdfPresets.selectedIndex];
            peuINFO.defaultPDFpreset = pdfPresets.selectedIndex;
            peuINFO.origSpread = temp.exportReaderSpreads;
            try{
                temp.exportReaderSpreads = theINFO.doSpreadsON;
                temp.pageInformationMarks = (theINFO.useTag && temp.cropMarks)?true:false;
            }catch(e){/*ignore it*/}
            PDFdlog.destroy();
            return temp;
        else{
            PDFdlog.destroy();
            byeBye("PDF exporting has been canceled by user.", peuINFO.sayCancel);
    * Get JPEG options
    function getJPEGoptions(docName){
        var temp = new Array();
        var JPEGdlog = app.dialogs.add({name:"JPEG Options for \"" + docName + "\"", canCancel:true} );
        with (JPEGdlog)
            with (dialogColumns.add() ){
                with (dialogRows.add() )
                    staticTexts.add({staticLabel:"Quality:"} );
                JPEGquality = dropdowns.add({stringList:(new Array("Low","Medium","High","Maximum")) , minWidth:50, selectedIndex:peuINFO.defaultJPEGquality} );
                with (dialogRows.add() )
                    staticTexts.add({staticLabel:"Encoding Type:"} );
                    JPEGrender = dropdowns.add({stringList:["Baseline","Progressive"] , minWidth:50, selectedIndex:peuINFO.defaultJPEGrender } );
        if(JPEGdlog.show() ){
            peuINFO.defaultJPEGquality = JPEGquality.selectedIndex;
            temp["qualityType"] = peuINFO.defaultJPEGquality;
            peuINFO.defaultJPEGrender = JPEGrender.selectedIndex;
            temp["renderType"] = peuINFO.defaultJPEGrender;
        else{
            JPEGdlog.destroy();
            byeBye("JPEG exporting has been canceled by user.",peuINFO.sayCancel);
        JPEGdlog.destroy();
        return temp;
    * Set JPEG options
    function setJPEGoptions(theINFO){
        with(app.jpegExportPreferences){
            peuINFO.origSpread = exportingSpread; // Used to reset to original state when done
            exportingSpread = currentINFO.doSpreadsON;
            exportingSelection = false; // Export the entire page
            if(peuINFO.csVersion > 3)
                jpegExportRange = ExportRangeOrAllPages.exportRange;
            switch (theINFO.qualityType){
                case 0:
                    jpegQuality = JPEGOptionsQuality.low;
                    break;
                case 1:
                    jpegQuality = JPEGOptionsQuality.medium;
                    break;
                case 2:
                    jpegQuality = JPEGOptionsQuality.high;
                    break;
                case 3:
                    jpegQuality = JPEGOptionsQuality.maximum;
                    break;
            jpegRenderingStyle = (theINFO.renderType)? JPEGOptionsFormat.baselineEncoding : JPEGOptionsFormat.progressiveEncoding;
    * Get EPS options
    function getEPSoptions(docName){
        var epsOptions = new Array();
        var epsDialog = app.dialogs.add({name:"EPS Options for \"" + docName + "\"", canCancel:true} );
        var oldBleed = peuINFO.bleed;
        with (epsDialog){
            // Left Column
            with (dialogColumns.add() ){
                with (dialogRows.add() )
                with (borderPanels.add() )
                    with (dialogColumns.add() ){
                        with (dialogRows.add() )
                            staticTexts.add({staticLabel:"Flattener Presets:"} );
                        changeFlattenerPreset = dropdowns.add({stringList:peuINFO.flattenerNames , minWidth:180, selectedIndex:peuINFO.defaultFlattenerPreset} );
                        with (dialogRows.add() )
                            changeIgnoreOverride = checkboxControls.add({staticLabel:"Ignore Overrides", checkedState:peuINFO.ignoreON} );
                        with (dialogRows.add() )
                            staticTexts.add({staticLabel:"Preview Type:"} );
                        changePreviewPreset = dropdowns.add({stringList:peuINFO.previewTypes , minWidth:180, selectedIndex:peuINFO.defaultPreview} );
                        with (dialogRows.add() ){
                            staticTexts.add({staticLabel:"Bleed:"} );
                            changeBleedVal = realEditboxes.add({editValue:peuINFO.bleed, minWidth:60} );
                            staticTexts.add({staticLabel:peuINFO.measureLableArray[peuINFO.measurementUnits]} );
                        with (dialogRows.add() )
                            staticTexts.add({staticLabel:"OPI Options:"} );
                        with (dialogRows.add() ){
                            staticTexts.add({staticLabel:"Omit:"} );
                            changeOpiEPS = checkboxControls.add({staticLabel:"EPS", checkedState:peuINFO.epsON} );
                            changeOpiPDF = checkboxControls.add({staticLabel:"PDF", checkedState:peuINFO.pdfON} );
                            changeOpiBitmap = checkboxControls.add({staticLabel:"Bitmapped", checkedState:peuINFO.bitmapON} );
            // Right column
            with (dialogColumns.add() ){
                with(borderPanels.add() ){
                    with(dialogColumns.add() ){
                        with (dialogRows.add() ){
                            staticTexts.add({staticLabel:"PostScript level:"} );
                            var changePSlevel = dropdowns.add({stringList:["2","3"] , minWidth:75, selectedIndex:peuINFO.psLevel} );
                        with (dialogRows.add() ){
                            staticTexts.add({staticLabel:"Color mode:"} );
                            if(peuINFO.csVersion == 3)
                                var changeColorMode = dropdowns.add({stringList:["Unchanged","Grayscale", "RGB", "CMYK"] , minWidth:100, selectedIndex:peuINFO.colorType } );
                            else
                                var changeColorMode = dropdowns.add({stringList:["Unchanged","Grayscale", "RGB", "CMYK","PostScript Color Management"] , minWidth:100, selectedIndex:peuINFO.colorType } );
                        with (dialogRows.add() ){
                            staticTexts.add({staticLabel:"Font embedding:"} );
                            var changeFontEmbedding = dropdowns.add({stringList:["None","Complete", "Subset"] , minWidth:100, selectedIndex:peuINFO.fontEmbed } );
                        with (dialogRows.add() ){
                            staticTexts.add({staticLabel:"Type of data to send:"} );
                            var changeDataToSend = dropdowns.add({stringList:["All","Proxy"] , minWidth:50, selectedIndex:peuINFO.dataSent } );
                        with (dialogRows.add() ){
                            staticTexts.add({staticLabel:"Data type:"} );
                            var changeDataType = dropdowns.add({stringList:["Binary","ASCII"] , minWidth:50, selectedIndex:peuINFO.dataType } );
                        with (dialogRows.add() ){
                            staticTexts.add({staticLabel:"Perform OPI replacement:"} );
                            var changeOPIreplace = dropdowns.add({stringList:["No","Yes"] , minWidth:50, selectedIndex:peuINFO.opiReplacement} );
        do{
            var getOut = true;
            if((epsDialog.show()) ){
                // Use these to update the prefs file
                peuINFO.defaultFlattenerPreset = changeFlattenerPreset.selectedIndex;
                peuINFO.ignoreON = (changeIgnoreOverride.checkedState)?1:0;
                peuINFO.defaultPreview = changePreviewPreset.selectedIndex;
                peuINFO.bleed = changeBleedVal.editContents;
                peuINFO.epsON = (changeOpiEPS.checkedState)?1:0;
                peuINFO.pdfON = (changeOpiPDF.checkedState)?1:0;
                peuINFO.bitmapON = (changeOpiBitmap.checkedState)?1:0;
                peuINFO.psLevel = changePSlevel.selectedIndex;
                peuINFO.colorType = changeColorMode.selectedIndex;
                peuINFO.fontEmbed = changeFontEmbedding.selectedIndex;
                peuINFO.dataSent = changeDataToSend.selectedIndex;
                peuINFO.dataType = changeDataType.selectedIndex;
                peuINFO.opiReplacement = changeOPIreplace.selectedIndex;
                // Check if bleed value is OK
                peuINFO.bleed = parseFloat(peuINFO.bleed)
                if (isNaN(peuINFO.bleed)){
                    alert("Bleed value must be a number (1.1).");
                    getOut = false;
                    peuINFO.bleed = oldBleed;
                else if (peuINFO.bleed < 0){
                    alert("Bleed value must be greater or equal to zero (1.2).");
                    getOut = false;
                    peuINFO.bleed = oldBleed;
                else {
                    // Check if bleed is too big
                    try {
                        app.epsExportPreferences.bleedBottom = "" + peuINFO.bleed + peuINFO.measureUnitArray[peuINFO.measurementUnits];
                    catch (Exception){
                        alert("The bleed value must be less than one of the following: 6 in | 152.4 mm | 432 pt | 33c9.384");
                        getOut = false;
                        peuINFO.bleed = oldBleed;
            else{
                epsDialog.destroy();
                byeBye("EPS Export canceled by user.", peuINFO.sayCancel);
        }while(!getOut);
            // These are used for exporting
            epsOptions["defaultFlattenerPreset"] = changeFlattenerPreset.selectedIndex;
            epsOptions["ignoreON"] = peuINFO.ignoreON;
            epsOptions["defaultPreview"] = changePreviewPreset.selectedIndex;
            epsOptions["bleed"] = peuINFO.bleed;
            epsOptions["epsON"] = peuINFO.epsON;
            epsOptions["pdfON"] = peuINFO.pdfON;
            epsOptions["bitmapON"] = peuINFO.bitmapON;
            epsOptions["psLevel"] = changePSlevel.selectedIndex;
            epsOptions["colorType"] = changeColorMode.selectedIndex;
            epsOptions["fontEmbed"] = changeFontEmbedding.selectedIndex;
            epsOptions["dataSent"] = changeDataToSend.selectedIndex;
            epsOptions["dataType"] = changeDataType.selectedIndex;
            epsOptions["opiReplacement"] = changeOPIreplace.selectedIndex;
            epsDialog.destroy();
            return epsOptions;
    *     Apply chosen settings to the EPS export prefs
    function setEPSoptions(theINFO){
        with(app.epsExportPreferences){
            appliedFlattererPreset = peuINFO.flattenerNames[theINFO.defaultFlattenerPreset];
            bleedBottom = "" + theINFO.bleed + peuINFO.measureUnitArray[peuINFO.measurementUnits];
            bleedInside = bleedBottom;
            bleedOutside = bleedBottom;
            bleedTop = bleedBottom;
            epsSpreads = currentINFO.doSpreadsON;
            ignoreSpreadOverrides = theINFO.ignoreON;
            switch (theINFO.dataType){
                case 0:
                    dataFormat = DataFormat.binary;
                    break;
                case 1:
                    dataFormat = DataFormat.ascii;
                    break;
            switch (theINFO.colorType){
                case 0:
                    epsColor = EPSColorSpace.unchangedColorSpace;
                    break;
                case 1:
                    epsColor = EPSColorSpace.gray;
                    break;
                case 2:
                    epsColor = EPSColorSpace.rgb;
                    break;
                case 3:
                    epsColor = EPSColorSpace.cmyk;
                    break;
                case 4:
                    epsColor = EPSColorSpace.postscriptColorManagement;
                    break;
            switch (theINFO.fontEmbed){
                case 0:
                    fontEmbedding = FontEmbedding.none;
                    break;
                case 1:
                    fontEmbedding = FontEmbedding.complete;
                    break;
                case 2:
                    fontEmbedding = FontEmbedding.subset;
                    break;
            switch (theINFO.dataSent){
                case 0:
                    imageData = EPSImageData.allImageData;
                    break;
                case 1:
                    imageData = EPSImageData.proxyImageData;
                    break;
            switch (theINFO.defaultPreview){
                case 0:
                    preview = PreviewTypes.none;
                    break;
                case 1:
                    preview = PreviewTypes.tiffPreview;
                    break;
                case 2:
                    preview = PreviewTypes.pictPreview;
                    break;
            switch (theINFO.psLevel){
                case 0:
                    postScriptLevel = PostScriptLevels.level2;
                    break;
                case 1:
                    postScriptLevel = PostScriptLevels.level3;
                    break;
            // Setting these three to false prevents a conflict error when trying to set the opiImageReplacement value
            omitBitmaps = false;
            omitEPS = false;
            omitPDF = false;
            if (theINFO.opiReplacement){
                opiImageReplacement = true;
            else {
                opiImageReplacement = false;
                omitBitmaps = theINFO.bitmapON;
                omitEPS = theINFO.epsON;
                omitPDF = theINFO.pdfON;
    * Build the main dialog box
    function createMainDialog (docName, thisNum, endNum){
        var theDialog = app.dialogs.add({name:(VERSION_NAME + ": Enter the options for \"" + docName + "\"" + ((endNum==1)?"":" (" + thisNum + " of " + endNum + " documents)") )
    , canCancel:true} );
        with (theDialog){
            // Left Column
            with (dialogColumns.add() ){
                with (dialogRows.add() )
                    staticTexts.add({staticLabel:"Page Naming Options"} );
                with(borderPanels.add() ){
                    with(dialogColumns.add() ){
                        // Radio butons for renaming convention
                        namingConvention = radiobuttonGroups.add();
                        with(namingConvention){
                            radiobuttonControls.add({staticLabel:"As Is", checkedState:(peuINFO.nameConvType == 0)} );
                            radiobuttonControls.add({staticLabel:"Add \".L\"", checkedState:(peuINFO.nameConvType == 1)} );
                            radiobuttonControls.add({staticLabel:"Odd/Even = \".F/.B\"", checkedState:(peuINFO.nameConvType == 2)} );
                            radiobuttonControls.add({staticLabel:"Odd/Even = \"LA.F/LA.B\"" , checkedState:(peuINFO.nameConvType == 3)});
                            radiobuttonControls.add({staticLabel:"Numeric Override" , checkedState:(peuINFO.nameConvType == 4)});
                    with (dialogRows.add() )
                        staticTexts.add({staticLabel:""} );
                        with(dialogRows.add() ){
                        staticTexts.add({staticLabel:"Base Name"} );
                        newBaseName = textEditboxes.add({editContents:baseName, minWidth:100} );
            // Middle Column
            with (dialogColumns.add() ){
                with (dialogRows.add() )
       

    RichardM0701, are you the same person as scottbentley?
    I fear your response doesn't make a lot of sense. The easiest way is to put your files into a book, which will not harm them. The easiest script is often no script at all.
    I don't understand your comment about separate text boxes, files contain text boxes and definitionally multiple files means multiple separate text boxes.
    I do not know what you are referring to with respect to the toc update, perhaps you could reference a particular command or script, or provide a screenshot.
    It sounds like now you are interested in updating multiple tables of contents in a single fell swoop -- this would appear to have nothing to do with the original question. If that's the case, please start a new thread.

  • Script to open INDD files, run script, and close

    Hello, I'm looking for a script that will open a folder of Indesign files, open each one, run a selected script, then close each file.
    RIght now I'm using the Batch convert script, to convert INDD to INDD and run the script in between (then I delete the extra INDD file). But I'm trying to eliminate the conversion element, just need the script part of it.
    Anyone have any help? Thanks.

    Here's my whole code if it helps. I'm wondering if the script is moving too fast. I think that the first files are still PDFing while the others are opening and closing. Could that be it? I'm not sure why else the for loop for the PDFing is only working on the first file.
    var myFolder = Folder.selectDialog("Select Input Folder");
    var myIndsnFiles = myFolder.getFiles("*.indd");
    var exportPath=Folder("/").selectDlg("Select PDF output folder:");
    var pdfPreset = "Press Quality";
    for(k=0; k<myIndsnFiles.length; k++)
        app.open(myIndsnFiles[k]);
        var jobNumber = "12345";
            for (aPage=0; aPage < app.activeDocument.pages.length; aPage++)
                app.pdfExportPreferences.pageRange = app.activeDocument.pages[aPage].name;
                app.activeDocument.exportFile (ExportFormat.PDF_TYPE, File(exportPath+"/"+jobNumber+"_"+pad(app.activeDocument.pages[aPage].name)+".pdf"), false, pdfPreset);
                function pad (n) {
                return ("00000"+n).slice(-3);
    app.activeDocument.close();

  • Output each page with a custom file name

    We have 150 photos to place in an Indesign file with Data Merge. Each page has: the photo, the name and surname.
    Is it possible the export these pages as separate files but named with the file name of the photo?
    gert

    Sure it's possible. Try this -- don't forget to adjsut the export path and PDF preset name.
    exportPath = "c:/temp";  // Adjust to fit!
    exportPreset = "My Favourite Preset"; // Adjust to fit!
    for (p=0; p < app.activeDocument.pages.length; p++)
      processPage(app.activeDocument.pages[p]);
    function processPage (a_page)
      var i, link;
      for (i=0; i<a_page.allGraphics.length; i++)
        if (a_page.allGraphics[i].itemLink.isValid)
          linkname = File(a_page.allGraphics[i].itemLink.filePath);
          app.pdfExportPreferences.pageRange = a_page.name;
          app.activeDocument.exportFile (ExportFormat.PDF_TYPE, File(exportPath+'/'+linkname.name.replace(/(\.[^.]+)$/, '.pdf')), false, app.pdfExportPresets.item(exportPreset));
          return;

  • [JS CS3 WIN] ExportEachPageAsPDF

    Hello,
    I have found this script. Now I want to modify the filename section.
    //ExportEachPageAsPDF.js  
    //Exports each page of an InDesign CS document as a separate PDF to  
    //a selected folder using the selected PDF export settings.  
    //Display a "choose folder" dialog box.  
    if(app.documents.length != 0){  
        var myFolder = Folder.selectDialog ("Choose a Folder");  
        if(myFolder != null){  
            myExportPages(myFolder);  
    else{  
        alert("Please open a document and try again.");  
    function myExportPages(myFolder){  
        var myPageName, myFilePath, myFile;  
        var myDocument = app.activeDocument;  
        var myDocumentName = myDocument.name;  
        var myPDFPresets = app.pdfExportPresets;
        var myPDFPresetNames = new Array;
        for (i = 0; i < myPDFPresets.length; i++)
            myPDFPresetNames.push(myPDFPresets[i].name); 
        var myDialog = app.dialogs.add();  
        with(myDialog.dialogColumns.add()){ 
            with(dialogRows.add()){   
                with(dialogColumns.add()) {
                    staticTexts.add({staticLabel:"Base name:", minWidth:130});  
                with(dialogColumns.add()) {
                    var myBaseNameField = textEditboxes.add({editContents:myDocumentName,   minWidth:160});  
            with(dialogRows.add()){ 
                with(dialogColumns.add()){ 
                    staticTexts.add({staticLabel:"PDF preset: ", minWidth:130}); 
                with(dialogColumns.add()){ 
                    var myPDFPresetsDropdown = dropdowns.add({stringList:myPDFPresetNames,  selectedIndex:0}); 
        var myResult = myDialog.show({name:"ExportPages"});  
        if(myResult == true){  
            var myBaseName = myBaseNameField.editContents;  
            var myPDFPresetName = myPDFPresetNames[myPDFPresetsDropdown.selectedIndex];
            //Remove the dialog box from memory.  
            myDialog.destroy();  
            for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){  
                myPageName = myDocument.pages.item(myCounter).name;  
                app.pdfExportPreferences.pageRange = myPageName; 
    //Generate a filename. /////////////////////////////
              app.findTextPreferences.appliedParagraphStyle = "picture_description"; 
              app.findTextPreferences.findWhat = '';
             myStory = myDocument.stories;
              myFound = myStory.findText();
           // alert(myFinds[0].contents);
                myFilePath = myFolder + "/" + myFound[0].contents + ".pdf";  
                myFile = new File(myFilePath);  
                myDocument.exportFile(ExportFormat.pdfType,   myFile, false, myPDFPresets.item(myPDFPresetName)); 
        else{  
            myDialog.destroy();  
    On every page there is only 1 paragraph styled with the paragraphstyle "picture_description".
    I want to use the content of this paragraph for the filename for each page.
    please, can someone help me?
    Best regards
    Christoph

    Hi Christoph,
    Here's a script for you:
    http://www.nobrainer.dk/assets/Uploads/Scripts/share/exportPDFofPage-nameByParaStyle.jsx
    You should notice that there is no looking out for errors and other fancy stuff, so your document must have one line marked with the parastyle "picture_description", on each page that should be exported. Also there can be no illigal letters for a filename in the marked text.
    However you should easily be able to make corrections to the script as needed.
    Thomas B. Nielsen
    http://www.nobrainer.dk

  • PDF- Filename automated from labelscript (after data merge)

    Hello,
    first of all I'm quite new in javascripting... but some simular scripts I have found on the internet could provide a solution for my problem.
    What I've done is the following:  I've used Data Merge and created a 200-paged file with 1 label on each page. Each label has a labelnumber.
    What I could do is export the file - split it up in 200 different pages - rename each file to the specific labelname. Seems a lot of work and this job I need to repeat about once a month.
    I looked for a solution and came to these discussion: http://forums.adobe.com/thread/289666http://      http://forums.adobe.com/message/3178412#3178412
    What I want to create is a script that I can run every month after I have updated my 200 labels and overrides all the pdf-files of the old labels.
    With the different scripts I have found I constructed the code below.
    The script works, it prints to multiple pdf's which have the correct labelnames, export is according to the requested presets,  but the CONTENT of each label is the content of the FIRST label (first page).
    I have tried a lot of thing (trail&error) but as I said, I'm quite new to this matter...
    So.... I can use some help or advice on this one.
    Thanks in advance,
    Dheart
    function getLABEL_A(page) {
              for (var  currentTextFrameIndex=0;currentTextFrameIndex<page.textFrames.length; ++currentTextFrameIndex) { // Iterates over frames
                   if (page.textFrames[currentTextFrameIndex].label=="LABEL_A") // if label is LABEL_A..
                        return page.textFrames[currentTextFrameIndex].contents; // ..returns text frame contents
              return null; // if not found, returns null
    var LABEL_A;
         var pagesList=app.activeDocument.pages;
         for (var currentPageIndex=0;currentPageIndex<pagesList.length;++currentPageIndex) { // Iterates over pages list
              currentPage=pagesList[currentPageIndex];
              LABEL_A=getLABEL_A(currentPage);
              if (LABEL_A!=null) { // If we have a LABEL_A - PDF file name-
                    var export_preset = app.pdfExportPresets.item("[Smallest File Size]");
                   app.activeDocument.exportFile(ExportFormat.pdfType,"F:/.../"+LABEL_A+".PDF",false,export_ preset); //.. and save the file
              } else {
                   alert("Page number "+currentPageIndex+" NO LABEL_A");
                   alert(LABEL_A);

    Thx for the reply, indeed this is a solution for consecutive numbering, however, the numbering is following another 'system' and in this case the numbering is given randomly.
    Anyway, trying a lot of things,  gave me a working script!!!
    The script exports a multipaged indesign file to single-paged pdf files. The namegiving of the pdf-files is automated and follows a labelscript (textlabel) on each page.
    function getLABEL(page) {
              for (var  currentTextFrameIndex=0;currentTextFrameIndex<page.textFrames.length; ++currentTextFrameIndex) { // Iterates over frames
                   if (page.textFrames[currentTextFrameIndex].label=="LABEL") // if label is LABEL..
                        return page.textFrames[currentTextFrameIndex].contents; // ..returns text frame contents
              return null; // if not found, returns null
    var LABEL;
         var currentPage;
         var pagesList=app.activeDocument.pages;
         for (var currentPageIndex=0;currentPageIndex<pagesList.length;++currentPageIndex) { // Iterates over pages list
              currentPage=pagesList[currentPageIndex];
              LABEL=getLABEL(currentPage);
              if (LABEL!=null) { // If we have a LABEL PDF -file name-
                  app.pdfExportPreferences.pageRange=String(currentPageIndex+1); // set up the export range..
                    var export_preset = app.pdfExportPresets.item("[High Quality Print]");
                     app.activeDocument.exportFile(ExportFormat.pdfType,"F:// fill in destination"+LABEL+".PDF",false,export_preset); //.. and save the file
              } else {
                   alert("Page number "+currentPageIndex+" without LABEL box");
                   alert(LABEL);

  • Save each page as PDF naming mod

    I had an issue I needed help with a while back, now I need to mod the script.
    Here's the original post
    Peter Kahrel, ""Save each page as PDF" naming mod?" #1, 16 Jan 2008 8:00 am
    I have a 456 page document that was made from a data merge. It has a background image, a foreground image and a job number/description.
    I need to save each page out as a jpg and name the file with the contents of the "jobnumber" text box. Previously Peter Kahrel helped me out tremendously with a little function that looked at the job number (which was always PNXX-xxxx) and swapped it out with the real job number.
    Now the contents of the jobnumber field isn't structured, i.e., "AvocadoSwirl_V", or "BurntSienna_G".
    Is there a way to set a script label for the "jobnumber" text box and just name the output file whatever is in there?
    Here is the existing script:
    var destinationFolder = Folder.selectDialog ("Choose a Folder");
    var myPDFExportPreset = app.pdfExportPresets.item("WebVidOverlay");
    doc = app.activeDocument;
    doc.sections.everyItem().includeSectionPrefix = false;
    app.findTextPreferences = null;
    app.findTextPreferences.findWhat = 'pnxx^9^9^9^9';
    found = doc.findText();
    for (i = 0; i < found.length; i++ )
    f = File (destinationFolder + "/" + found[i].contents + '.pdf');
    app.pdfExportPreferences.pageRange = found[i].parentTextFrames[0].parent.name;
    doc.exportFile (ExportFormat.pdfType, f, false, myPDFExportPreset);
    As always, Thanks a million,
    Randy

    >Does that sound do-able?
    Most things are doable, provided that your information is precise: first you say that pages may or may not have a text frame labelled "jobnumber" and that that frame may or may not have text in it (your post can be read like that anyway). Now you say that every page has a text frame labelled "jobnumber" and that that frame can be filled with either of three text strings. Or maybe all three strings? You say
    >then I should be able save each file with the names "Avocado.jpg", "Burnt Sienna.jpg" and "pnga-0431.jpg" respectively.
    Or do you mean "save each file with the names "Avocado.jpg", "Burnt Sienna.jpg" _OR_ "pnga-0431.jpg" respectively."? The way you phrased it, it looks as if you want to save three files from a page. But your example shows that you meant "or", not "and".
    But anyway, the last two lines of your example appear to make clear what you want. The attached script exports each page of the active document to JPG, using the contents of the text frame labelled "jobnumber" on that page. The script assumes that each page has such a text frame and that there is something in it, and that whatever is in it provides a legal file name. It doesn't do any error checking/catching at all.
    Peter
    app.jpegExportPreferences.resolution = 300;
    app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
    app.activeDocument.sections.everyItem().includeSectionPrefix = false;
    path = app.activeDocument.filePath + '/';
    p = app.activeDocument.pages.everyItem().getElements();
    for (i = 0; i < p.length; i++)
      jpg_name = p[i].textFrames.item ('jobnumber').contents + '.jpg';
      app.jpegExportPreferences.pageString = p[i].name;
      app.activeDocument.exportFile (ExportFormat.jpg, File (path + jpg_name));

  • Script for Exporting 2 Pgs into 1 PDF???

    Hello, I was wondering if anyone can help me. I know there is a script that can export each page of Indesign file as a separate PDF, but is there a script out there to export every two pages of Indesign file.
    Basically what I need to do is create 300 customized documents (based on personal company information) and Export them to a PDF so that I may e-mail one to each company. The document must be two pages, the first page has the personalized (merged) information, but the second page will be exactly the same on all of them.
    Can you tell me how I can do this in Indesign, or if not Indesign, Acrobat? I ran a test with the Data Merge system in Indesign. (I created a .CSV file with 2 columns; Company Name and Company Product and took 5 five companies from the master list to test.)
    After the merge, all the fields populated correctly but I wound up with a 10 page .INDD document. (the odd number pages are the ones with all the "merged" personal info, while all the even number pages exactly the same) What I need now is every 2 pages to be exported as 1 PDF file.
    Is there is an easier way to do this? And if not in Indesign, is there an easy way to extract 2 pages at a time in Acrobat?
    Thank you very much for any help, much appreciated,
    Kevin

    Hi Kevin,<br />Here is another version.<br />copy/paste into a text editor then save as a .jsx and place it in the script folder.<br />The only thing you have to modify is the name of your pdf preset. I thought about a dialog where tou could have switched frome one preset to another easily. But it may much more efficient to just modify the name of the preset. If you want you an also make a copy with another PDF preset then rename it.<br /><br />ad = app.activeDocument;<br />pg=ad.pages;<br />var docpath = ad.filePath;<br />var docname = ad.name;<br />var nb = (Math.round(Number(pg.length/2)))<br />for(i=0; i<nb;i++)<br /><br />{<br />]var pgrgstart = (pg[(2*i)].name);<br /><br />]if(pg[(2*i+1)]==-1)<br /><br />]{<br /><br />]]var pgrgend = pgrgstart;<br /><br />]}<br /><br />]else<br /><br />]{<br /><br />]]var pgrgend = pg[(2*i+1)].name;<br /><br />]}<br /><br />]app.pdfExportPreferences.pageRange = pgrgstart+"-"+pgrgend; <br /><br />]var myPDFExportPreset = app.pdfExportPresets.item("your PDF preset"); <br /><br />b //enter the name of your PDF preset instead of your PDF preset<br /><br />]ad.exportFile(ExportFormat.pdfType, File(docpath+"/"+docname.split(".indd")[0]+"_"+"pg_"+i+"_to_"+(i+1)+".pdf"), false, myPDFExportPreset); <br /><br />}<br /><br />alert("done");

Maybe you are looking for

  • Windows 8.1 & server2012R2 both crash or freeze on this machine

    Hi there I have this weird problem with this machine. An assus laptop, i5 4Gb ram with a wifi card from intel "Intel(R) Centrino(R) Advanced-N 6250 AGN" For work i had installed in it server2012R2 cause i needed a server on the go for testing purpose

  • Can I make a web link for Imported PDF forms?

    I imported a PDF form onto formscentral.  When I click the distribute tab I do not get the same options as if I created the form on formscentral.  Can I create a web link for my imported PDF form?

  • Exchange rate in service entry sheet

    Hi, Could someone tell me how the exchange rate gets determined in service entry sheet. I am facing a problem while doing ML81N. While doing so when I click on condition type, I see the exchange rate as INR to USD = 0.080, while for all the other ite

  • Is the wifi receiver of an Airport express stronger than IPhone?

    Hi I am about to purchase an airport in order to extend my wifi connection. But first I would like to check the strength of the wifi signal I'm going to receive in the location of the future AX. But how is the wifi received in the AX ? Stronger than

  • IPad 3 crashed while updating to 6.1....

    It's frozen with the Apple logo and empty bar below it. I can't turn it off.  What do I do now??? Please help??? This is the first time I've had this problem with updating. I've had an iPhone 4 since they came out. Got my iPad 3 when they came out (A