2 Replies Latest reply on Dec 31, 2014 6:07 AM by winterm

    [JS] Open document without showing window

    winterm Level 4

      Hi there, wise scripters,

       

      Win7 64-bit, CS6, ID8.0.2

       

      I need to open indd doc, process some code, close file. Everything works fine.

      However, the 'open' method has a parameter [showingWindow], right?

      To speed things up a bit, I try to turn off displaying document's window by using the 'false' argument while opening the file, like this:

       

      var file = File.openDialog(); 

      app.open(file, false);

       

      ... and can't get it to work. File just won't open then.

       

      Found a few posts where people say it's working just fine for them.

      What I am missing / doing wrong?

       

      Thank You!

       

      P.S. Funny thing is, a couple of years ago, playing with 'save', 'save as', and 'save a copy' options, I had achieved this effect unintentionally, in some quite different way I can't recall now...

        • 1. Re: [JS] Open document without showing window
          Chinnadk Level 4

          var file = File.openDialog();

          app.open(file, false);

           

          These lines are working fine for me.

          Check the target application in ExtendScript it should be 'Adobe Indesign CS6'

          • 2. Re: Re: [JS] Open document without showing window
            winterm Level 4

            Hi,

            Well, I see now, my problem is a bit different...

             

            This is initial basic working code sample:

            var file = File.openDialog();
            app.open(file);
            app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
            app.pdfExportPreferences.viewPDF = false;
            app.activeDocument.exportFile(ExportFormat.pdfType, File("C:/Folder/Test.pdf"), false, "myPDFpreset");
            app.activeDocument.close(SaveOptions.NO);
            alert("Done");
            

             

            Now I realized I can't simply add 'false' argument to app.open(file, false) - script throws an error 'No documents are open'.

             

            And this works as expected (not showing window):

            var file = File.openDialog();
            var myDoc = app.open(file, false);
            app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
            app.pdfExportPreferences.viewPDF = false;
            myDoc.exportFile(ExportFormat.pdfType, File("C:/Folder/Test.pdf"), false, "myPDFpreset");
            myDoc.close(SaveOptions.NO);
            alert("Done");
            

             

            So I would need to modify the main code - that's too bad... I was hoping to use this in a much more complex script, with a lot of lines, doing a big bunch of things...

            However, thank You for your response and have a nice party tonight