2 Replies Latest reply on Oct 20, 2013 1:04 AM by mrslother

    Is it too late to modify preview thumbnails once beforeSave event fires?

    mrslother

      My goal:

      I need to show non-printing layers in my .indd files' preview thumbnails. We produce print jobs which will have post processing applied to them (thermography and cutouts glued to the printed cardstock). Our .indd files have layers containing these post production images so that we can determine proper alignment and spacing for the end product.

      These are graphics are placed in non-printing layers so that they do not print. However InDesign generates preview thumbnails which do not contain these non-printing images. This is a problem for us because we can not tell the nuanced difference between similar indd files soley by their preview images.

      Therefore my goal is to somehow include these non-printing layers in the image preview thumbnail.

       

      What I have done thus far:

      I have a startup script which registers for the beforeSave and afterSave events. Before the same it marks all the non-printing layers are printable (printable property = true). Then the afterSave event undoes this by setting those layers back to non-printable. I track which layer was originally non-printing by adding a moniker to the layer's name.

       

      What is not working:

      When I run a script that marks the layers as printable, saves then undoes the printable changes everything works perfectly. The preview thumbnail is exactly what I want.

      However, when I run it as a startup script registering for the beforeSave/afterSave events this fails:

      • Success: The beforeSave does correctly update the printable property then modifies the layer's name. This is as expected and working well.
      • Success:The afterSave does correctly reset the printable property and modified the layer's name. This is as expected and working well.
      • Failure: The file's preview thumbnail does not reflect the printable=true peroperty of the affected layers.

       

      My Question:

      From what I outline above it looks as if the preview image is determined before the beforeSave event fires.

      Question 1: Is this true?

      Question 2: How can I affect the layers' printable properties once a save occurs?

       

      As a last resort I could intercept any CTRL+S keystroke or the File-->Save menu option and call my original script (as I describe above). I would like to avoid that as it is fragile and less elegant.

       

      Follow question: Can anyone show me what the actual work flows are for these events? For example what does InDesign do during its save function and at what points does it trigger beforeSave and afterSave events?

        • 1. Re: Is it too late to modify preview thumbnails once beforeSave event fires?
          mrslother Level 1

          I also tried a different approach which worked:

          Added two event listeners to the "Save" MenuAction object. One for "beforeInvoke" and one for "afterInvoke". This worked and I now have correctly rendered preview thumbnails. However .....

           

          ....when the afterInvoke event fires and I update the layers to reflect their non-printing state and change their names back to normal this is reflected as if I have made alterations. Therefore the file is left in a "dirty" state thus wanting to be saved (the document's title has an * indicating changes were made). The document's "modified" property is read only so I can not forcibly change it. I can change set the Document.properties['modified'] to false without error, but either it does not take or it is instantly reset.

           

          This is a problem because when I exit the app it sees that there have been changes since the last save. Therefore it wants to save the doc. Saying "yes" to save the doc means that the "save" function is called but not from the Save menu. Therefore my MenuAction handers are not invoked. My beforeSave/afterSave handlers are but this does not function as I would expect (see my original post).

           

          Can someone please help with this? Maybe some kind soul from Adobe who understands the event firing workflow??

          • 2. Re: Is it too late to modify preview thumbnails once beforeSave event fires?
            mrslother Level 1

            Follow up:

             

            I believe that I have solved the problem. Wow, Adobe, you could have done better than this.

             

            My solution is during the "beforeSave" event, create a new textframe object. Fill it with meaningless text. Postition it somewhere predominently on the first page where it will be visible. Then remove the textframe.

             

            That apparently is enough for ID to rerender the preview thumbnail image. So my entire solution:

             

            • In a beforeSave event
              • modify my "nonprinting" layers to print.
              • next, create textframe, add some text, position it into the middle of the page, then remove it
            • In an afterSave event
              • change the modified layers back to "nonprinting"

             

            As silly and hacky as it seems to me, it appears to be working on ID CS6 for Windows.