10 Replies Latest reply on Jul 29, 2010 12:14 AM by Creaticious

    Edit document without open?

    Creaticious

      Hi all,

       

      is it possible to edit a document without open it?

       

      thx

        • 1. Re: Edit document without open?
          [Jongware] Most Valuable Participant

          Is it possible to eat a cookie without opening the jar?

           

          It's not possible at all -- there is no program in the world that can edit a document without opening it first. Even when it only appends data at the end, it still has to open the file first. (I suspect you could make a copy, edit that, then save over the original -- but that's hardly a fair solution, is it?)

           

           

          If you constrain yourself to InDesign, your question could be rephrased to: Is it possible to edit a document with any other program than InDesign. Theoretically: yes. However, that other program would need to (a) understand to read the binary format of InDesign, (b) able to make rational changes to it (adjusting paragraph composition in exactly the same way InDesign does, for example), and (c) write out the same file format, again in binary encoding.

          • 2. Re: Edit document without open?
            Creaticious Level 1

            Ok, maybe i should refine my question: there is a method called app.open([filename],[show])

             

            Now my question is, can i edit the document when the parameter [show] is false? Because I only

            want to change some links of many documents...

            • 3. Re: Edit document without open?
              [Jongware] Most Valuable Participant

              Ah, that makes more sense

               

              You are correct -- this is under Application:

               

              any open (from: varies[, showingWindow: bool=true][, openOption: OpenOptions=OpenOptions.DEFAULT_VALUE])
              Opens the specified document, book, or library.

              ParameterTypeDescription
              fromArray of Files
              File
              The file path(s) to the document, book, or library. Can accept: File or Array of Files.
              showingWindowboolIf true, opens the document in a window. If false, the document is opened but is not displayed in a window. (Optional) (default: true)
              openOptionOpenOptions:
              OpenOptions.DEFAULT_VALUE
              OpenOptions.OPEN_ORIGINAL
              OpenOptions.OPEN_COPY

               

               

              and I have used, on occasion, this way of "opening" documents w/o showing the window, because it appears to be much faster than 'normally' opening it. The only drawback, as far as I know, is that you need a solid javascript, with lots of error handling. If the script stops, you will have a document in your Window menu but (if I recall correctly) you cannot select it to 'open' so you can close it.

              • 4. Re: Edit document without open?
                Creaticious Level 1

                Ok, thats fine...my little problem now is that i have the following code:

                 

                var BookContents = app.activeBook.bookContents;


                 

                for (var x = 0; x <= BookContents.count(); x++) {


                 

                     var file = new File("/Volumes"+BookContents[x].filePath);


                 

                     alert(file.exists); << This returns true


                 

                     var doc = app.open(file, false);


                 

                     alert(app.activeDocument()); << This returns null !!!!

                     alert(app.documents[0]); << Also returns null !!!!

                 

                As u can see i want to iterate over bookcontents, open every doc an change some links.

                Now i cant get the doc because this is null....

                 

                Maybe you have an idea?

                • 5. Re: Edit document without open?
                  Peter Kahrel Adobe Community Professional & MVP

                  > alert(app.activeDocument()); << This returns null !!!!

                   

                  Of course, because there is no active document.

                   

                  > alert(app.documents[0]); << Also returns null !!!!

                   

                  That's strange, if there's a document that statement should return null. A better test is to do app.documents.length or app.ducuments[0].name. That's because app.documents[0] will (should, anyway) return "[object Document]" even when there aren't any documents open.

                   

                  As to the problem that Jongware mentioned that you might get stuck with some documents, do this:

                  app.documents.everyItem().close (SaveOptions.no);

                  which closes all documents without saving.

                   

                  Peter

                  • 6. Re: Edit document without open?
                    [Jongware] Most Valuable Participant

                    (Additionally,

                     

                    for (var x = 0; x <= BookContents.count(); x++)

                     

                    ought to be

                     

                    for (var x = 0; x < BookContents.count(); x++)

                     

                    -- It should work though, I use this construction all the time to process documents by the Book.)

                    • 7. Re: Edit document without open?
                      Creaticious Level 1

                      Ok, thats right. But i still cant open a document. The app.open() method does simply nothing...no error, no opened doc...i cant get it...

                      • 8. Re: Edit document without open?
                        Peter Kahrel Adobe Community Professional & MVP

                        filePath returns the folder that the file is in without the file's name. You should use fullName, which is the file's path with its name.

                         

                        Peter

                        • 9. Re: Edit document without open?
                          [Jongware] Most Valuable Participant

                          Heh heh -- I missed that!

                          • 10. Re: Edit document without open?
                            Creaticious Level 1

                            Yes! That was the real problem!

                             

                            Thank you very much!