8 Replies Latest reply on Mar 6, 2015 6:44 AM by K.Daube

    Missing graphics - how to skip in Open

    K.Daube Level 1

      In my test script to cope with the various open errors I have this definition for the OpenParms:

        i = GetPropIndex(params, Constants.FS_RefFileNotFound);  // Document imports another file that isn’t available.
        params[i].propVal.ival = Constants.FV_AllowAllRefFilesUnFindable;  
      
      
      

      When opening a book with files creating various errors, I get a dialog at the file which has missing graphics

      «Cannot display some imported graphics. The image will appear as gray boxes»

      Isn't this covered by the above OpenParm ?

      The whole test with files is in my dropbox.

        • 1. Re: Missing graphics - how to skip in Open
          Russ Ward Level 4

          Klaus,

           

          Unfortunately, some of these dialogs appear no matter what. Rick Quatro knows how to get rid of them using the FDK... perhaps he has an adaptation for ExtendScript. I'll wait to see if he is lurking about to provide an answer before going any further.

           

          Russ

          • 2. Re: Missing graphics - how to skip in Open
            frameexpert Level 4

            Below my signature are a set of functions that I use to get a document. I call getDocument, which first does a check to see if the document is already open (docIsOpen function); if it is, it returns it. If it isn't, it calls the openDoc function. Here is a sample call:

             

            var oDoc = getDocument (filename);
            if (oDoc.doc.ObjectValid ()) {
                // Call the function to process the document.
                processDoc (oDoc.doc);
                // If the document was opened by the script, save it and close it.
                if (oDoc.docIsOpen === false) {
                    oDoc.doc.SimpleSave (filename,false);
                    oDoc.doc.Close (true);
                }
            }
            

             

            The important thing to notice is that getDocument does not return a FrameMaker document directly; it returns a JavaScript object with two members. The first (doc) is the FrameMaker document object and the second (docIsOpen) is a boolean (true or false) value that says if the document was already open. If a document was already open, then I don't want my script to save and close the document when it is done. Please let me know if you have any questions or comments.

            - Rick

             

            function getDocument (filename) {
                
                // See if the document is already open.
                var oDoc = docIsOpen (filename);
                if (oDoc.doc) {
                    return oDoc;
                } else {
                    // The document is not already open, so open it.
                    return openDoc (filename);
                }
            }
            
            function docIsOpen (filename) {
                
                // Make a File object from the file name.
                var oFile = File (filename);
                // Uppercase the filename for easy comparison.
                var sFile = oFile.fullName.toUpperCase ();
                // Make an object to return.
                var oDoc = {doc: 0, docIsOpen: false};
            
                // Loop through the open documents in the session.
                var doc = app.FirstOpenDoc;
                while (doc.id) {
                    // Compare the document’s name with the one we are looking for.
                    if (File (doc.Name).fullName.toUpperCase () === sFile) {
                        // The document we are looking for is open.
                        // Add it to the object and return it.
                        oDoc.doc = doc;
                        oDoc.docIsOpen = true;
                        return oDoc;
                    }
                    doc = doc.NextOpenDocInSession;
                }
                return oDoc; // Document is not open; return the “empty” object.
            }
            
            function openDoc (filename) {
                
                var i = 0, doc = 0;
            
                // Make an object to return.
                var oDoc = {doc: 0, docIsOpen: false};
            
                // Get default property list for opening documents.
                var openProps = GetOpenDefaultParams ();
                // Get a property list to return any error messages.
                var retParm = new PropVals();
            
                // Set specific open property values to open the document.
                i=GetPropIndex(openProps,Constants.FS_AlertUserAboutFailure);
                openProps[i].propVal.ival=false;
                i=GetPropIndex(openProps,Constants.FS_MakeVisible);
                openProps[i].propVal.ival=false;
                i=GetPropIndex(openProps,Constants.FS_FileIsOldVersion);
                openProps[i].propVal.ival=Constants.FV_DoOK;
                i=GetPropIndex(openProps,Constants.FS_FileIsInUse);
                openProps[i].propVal.ival=Constants.FV_ResetLockAndContinue;
                i=GetPropIndex(openProps,Constants.FS_FontChangedMetric);
                openProps[i].propVal.ival=Constants.FV_DoOK;
                i=GetPropIndex(openProps,Constants.FS_FontNotFoundInCatalog);
                openProps[i].propVal.ival=Constants.FV_DoOK;
                i=GetPropIndex(openProps,Constants.FS_FontNotFoundInDoc);
                openProps[i].propVal.ival=Constants.FV_DoOK;
                i=GetPropIndex(openProps,Constants.FS_RefFileNotFound);
                openProps[i].propVal.ival=Constants.FV_AllowAllRefFilesUnFindable;
            
                // Attempt to open the document.
                doc = Open (filename,openProps,retParm);
            
                if (doc.ObjectValid () === 0) {
                    // If the document can't be open, print the errors to the Console.
                    PrintOpenStatus (retParm);
                }
            
                oDoc.doc = doc;
                return oDoc; // Return the document object.
            }
            
            • 3. Re: Missing graphics - how to skip in Open
              frameexpert Level 4

              Klaus, To answer your specific question, look at lines 51 and 52 in my code. This is what suppresses the Missing Graphics alert. -Rick

              • 4. Re: Missing graphics - how to skip in Open
                frameexpert Level 4

                I should have read the question more carefully. The message you refer to can't be suppressed as far as I know. It seems to appear once after you start FrameMaker and open a document that has missing graphics. I have even had this message pop up after opening up a document invisibly with a script. I am sorry about that. But the code I posted should be useful to someone anyway. -Rick

                • 5. Re: Missing graphics - how to skip in Open
                  Russ Ward Level 4

                  Rick, you posted the following on the Framedev forum back in 2010. Is there no ES equivalent?

                   

                  <snip>

                   

                  I finally found out how to do this. Compile the following code and register the DLL in the [APIClients] section of your maker.ini. It will "look" for the "Cannot display some imported graphics. The images will appear as gray boxes" message and suppress it. I tested it with FrameMaker 8 and above, and it works.

                   

                  Please let me know if you have any questions or comments. Thanks.

                   

                  Rick Quatro

                   

                  #include "fapi.h"

                  #include "fdetypes.h"

                  #include "futils.h"

                   

                  VoidT F_ApiInitialize(IntT init)

                  {

                  if (init == FA_Init_First)

                  {

                  F_ApiNotification(FA_Note_Alert, True);

                  F_ApiBailOut();

                  }

                  }

                   

                  VoidT F_ApiNotify(IntT notification, F_ObjHandleT docId, StringT filename, IntT iparm)

                  {

                  F_ObjHandleT alertId;

                  IntT uniq;

                   

                  switch (notification)

                  {

                  case FA_Note_Alert:

                   

                  // Get the id of the alert.

                  alertId = F_ApiGetId(0, FV_SessionId, FP_ActiveAlert);

                  uniq = F_ApiGetInt(FV_SessionId, alertId, FP_Unique);

                   

                  // If the alert is "Cannot display some imported graphics...", supppress it.

                  if ((uniq == 40086) || (uniq == 40090))

                  {

                  F_ApiReturnValue(FR_YesOperation);

                  }

                   

                  break;

                   

                  default:

                  break;

                  }

                  F_ApiBailOut();

                  }

                  • 6. Re: Missing graphics - how to skip in Open
                    frameexpert Level 4

                    Russ, You have a good memory. After thinking about it, I remembered this issue came up regarding the "Apply Master Pages" warning that happened when programmatically updating a book. Someone from Adobe gave me the code below and, as I recall, it worked. Let me see if I can adapt it in ExtendScript. -Rick

                     

                    #include "fapi.h"
                    #include "fdetypes.h"
                    #include "futils.h"
                    
                    VoidT F_ApiInitialize(IntT init)
                    {
                        if (init == FA_Init_First)
                        {
                            F_ApiNotification(FA_Note_Alert, True);
                            F_ApiBailOut();
                        }
                    }
                    
                    VoidT F_ApiNotify(IntT notification, F_ObjHandleT docId, StringT filename, IntT iparm)
                    {
                        F_ObjHandleT alertId;
                        IntT uniq;
                    
                        switch (notification)
                          {
                          case FA_Note_Alert:
                    
                            // Get the id of the alert.
                            alertId = F_ApiGetId(0, FV_SessionId, FP_ActiveAlert);
                            uniq = F_ApiGetInt(FV_SessionId, alertId, FP_Unique);
                    
                            // If the alert is "Cannot display some imported graphics...", supppress it.
                            // Also, "All master pages will be reapplied...."
                            if ((uniq == 40086) || (uniq == 40090) || (uniq == 46001))
                            {
                                F_ApiReturnValue(FR_YesOperation);
                            }
                    
                            break;
                    
                          default:
                            break;
                          }
                        F_ApiBailOut();
                    }
                    
                    • 7. Re: Missing graphics - how to skip in Open
                      frameexpert Level 4

                      Oops, it looks like we have overlapping posts and found the same code! I will send Klaus the dll offlist. Thanks! -Rick

                      • 8. Re: Missing graphics - how to skip in Open
                        K.Daube Level 1

                        frameexpert wrote:

                         

                        Klaus, To answer your specific question, look at lines 51 and 52 in my code. This is what suppresses the Missing Graphics alert

                        Rick this is fine. The thing was to replace the Constants.FV_DoCancel with false .

                        And of course the message "Can not display some graphics ..." will appear later when the user makes this doc active. But that's OK for me, as it does not interupt the script.