8 Replies Latest reply on Mar 10, 2010 2:32 AM by Harbs.

    CS4 jsx app.place leaving object problem

    smitty265 Level 1

      Hi,

       

      I have a jsx script that I am developing for InDesign CS4. The script acquires an xml string, then after doing some manipulation on it, saves it to a UTF-8 file. After saving the file, the script does an app.place() using the file it saved. The file is brought onto the place brush and it works great up to that point. It places very nicely into the document, with a mouse click, after the snippet is imported. The problem is that after the place, when I try to save, via manually doing File --> Save, to an indd file, I get a message "Failure in saving. Object is invalid". Sometimes I receive more than one. If I try to close the tab and elect not to save instead , I receive the message(s) "Failed to purge records for ducument. Object is invalid".

       

      If I reopen CS4 afterward and do a File -> Place and select the file saved by the script in the prior session, it not only places fine but then also allows me to save, cancel, etc. after the place; it works perfectly.

       

      I'm pretty confused here. Is there some housekeeping I should be doing in the script after the place command or something?

       

      Any help appreciated.

       

      Thanks,

       

      David

        • 1. Re: CS4 jsx app.place leaving object problem
          smitty265 Level 1

          I forgot to mention that the format of the xml string / file is idms.

           

          Thanks,

           

          David

          • 2. Re: CS4 jsx app.place leaving object problem
            [Jongware] Most Valuable Participant

            (idms? what's that?)

             

            You shouldn't need to do any clean-up. As far as I can see, the preprocessing happens in Javascript, and all InDesign itself does is place the resulting file. Even the UTF8 part should not be a problem -- that is, Javascript has no problems at all with that, and InDesign should either reject it as a valid format, or read and place without parsing the UTF8 characters, or read and place entirely correct. (My limited experience with UTF8 in InDesign showing here ...)

             

            As your Javascript creates a new file to be placed, you can try the following:

             

            1. have your javascript preprocess the input and create the new file. Save that somewhere (but I assume the script already does that at present).

            2. Quit InDesign. Yup -- let's make sure nothing remains in memory.

            3. Restart InDesign, create a new blank file and import your processed file.

            4. Try to save it.

             

            Does that cause the same error? If so, it's #1. that causes some memory pollution, and you'll have to review your script. If not, your processed file may be malformed in some way that InDesign can't detect and can't handle. In that case, you should try to open it with a UTF8-aware text editor to make sure the UTF8 is okay.

            If it is ... we'll have to think of something else.

             

            [Ed.] I might as well add that the InDesign/Javascript interface is not as trustworthy as one may expect. I once tried reading in a data file of several MBs, and rather than a warning "Out of memory", InDesign simply crashed and burned. Whittling down the data file, one MB at a time, showed there was some upper limit which ID can handle, where above it would die without warning.

            • 3. Re: CS4 jsx app.place leaving object problem
              Harbs. Level 6

              (idms? what's that?)

               

              Snippet.

               

              Harbs

              • 4. Re: CS4 jsx app.place leaving object problem
                Harbs. Level 6

                You probably messed up the structure of the snippet file...

                 

                Do you get the same results when you place the file manually?

                 

                Harbs

                • 5. Re: CS4 jsx app.place leaving object problem
                  smitty265 Level 1

                  Hi,

                   

                  That's the odd part; I can start a new session and manually place the file with no problem. File -> Place, then selecting the file, works great. It's only app.place() that has issues with it. Is it possible that when you go through the menu item it is more forgiving on certain structural items than when you load the snippet onto the place brush via the API? It appears to place fine initially with either manner. It's only when you go to save / cancel after using the scripted version that there are issues.

                   

                  Thanks,

                   

                  David

                   

                  -


                  "Harbs." <forums@adobe.com> wrote:

                  You probably messed up the structure of the snippet file...

                   

                  Do you get the same results when you place the file manually?

                   

                  Harbs

                  >

                  • 6. Re: CS4 jsx app.place leaving object problem
                    Harbs. Level 6

                    I've never seen anything like this.

                     

                    You're going to have to give us more to go on than this. Maybe post 

                    some sample code which illustrates the problem...

                     

                    Harbs

                    • 7. Re: CS4 jsx app.place leaving object problem
                      smitty265 Level 1

                      Hi,

                       

                      Thanks for your pointers. Here's what I've discovered by doing some additional controlled experimentation based on your recommendations:

                       

                      First, to explain it in more detail end to end, the basic flow of things is that a .jsx launches a Flex-based window via an swf referenced in the .jsx. The Flex window, via Actionscript, invokes an xml rpc call on a server and gets handed back xml that is an indesign snippet. The actionscipt, through ExternalInterface, hands the XML string into the .jsx that saves it to the temp file and does the place via app.place().

                       

                      Now, what I've observed in more structured testing, is that the Flex window having been opened seems to impair the ability to place an idms snippet without residual corruption. I had misplaced my suspicion on the app.place command itself.

                       

                      For example, I go through the process of jsx -> Flex -> jsx and create the temporary idms file, then place it, try to save / cancel and get the error message(s). If I next close InDesign, then reopen it, I can do File->Place of the temporary file from the previous test and it will save / cancel without issue. There is no problem with the idms formatting apparently.

                       

                      If, however, when I reopen InDesign, I open the Flex window, but don't do anything within it, and I then do File -> Place from the menu, it has the same difficulty with save / cancel.

                       

                      I can also use a jsx and place the file from the previous session without issue, provided that the Flex window hasn't been opened, i.e.:


                      var fileName = "c:\\data\\temp_1268139578078.idms";
                      main();
                      function main(){
                          app.place(fileName);
                      }

                       

                      This works fine all the way through Save / Cancel (unless I've opened the Flex window).

                       

                      If I open and close the Flex window, the issue subsequently manifests itself, so it's not just occuring with it actively open. Having opened it at all seems to corrupt something.

                       

                      Also, reflecting on something else; earlier in the development cycle, in the jsx, after having the Flex window open, I was not able to use XML object parsing successfully (it just didn't find things), but similarly, if I created a focused jsx that took in the XML without the Flex window opening, the ExtendScript XML parsing functioned properly.

                       

                      So, I'm concluding that, in my setup, the Flex window is causing some level of memory corruption that is impairing certain functionality?

                       

                      I am relatively new to both Flex and InDesign and I am going to doublecheck with the someone who has configured the Flex / InDesign set up a number of times to make sure that there isn't something I have locally misconfigured (I consider it likely that I do). The Flex window was developed by someone previously and I am just lightly extending it. If there isn't something locally wrong in my setup that is causing the issue, I guess I'll have to try to determine why the swf is leaving corruption behind. The Flex window is not modal, and its intent is to be able to sit open and provide ongoing functionality during application usage. The examples I've found on the internet have tended to be modal in nature and the Flex window handle was set to null upon the user returning control to a jsx in those examples.

                       

                      Thanks so much for your ongoing pointers on this. Anything else you think I should suspect besides either something I've set up incorrectly in the Flex project (compilation settings, etc.) or something in the coding of the Actionscript or in the ExtendScript / ActionScript integration?

                       

                      Thanks,

                       

                      David

                      • 8. Re: CS4 jsx app.place leaving object problem
                        Harbs. Level 6

                        Hmm.

                         

                        This sounds like an interesting problem, but I have no clue where the 

                        issue might be. PatchPanel is Labs technology, so there's a lot of 

                        weird things that can happen with a PatchPanel panel.

                         

                        I suggest you post your question on the PatchPanel forum with as much 

                        detail as you can. Bernd Paradies is usually very good at helping 

                        pinpoint issues with PatchPanel...

                         

                        Harbs