• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Missing graphics - how to skip in Open

Community Expert ,
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

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.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.

TOPICS
Scripting

Views

782

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 04, 2015 Mar 04, 2015

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

Votes

Translate

Translate
Mentor ,
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

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();

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

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.propVal.ival=false;

    i=GetPropIndex(openProps,Constants.FS_MakeVisible);

    openProps.propVal.ival=false;

    i=GetPropIndex(openProps,Constants.FS_FileIsOldVersion);

    openProps.propVal.ival=Constants.FV_DoOK;

    i=GetPropIndex(openProps,Constants.FS_FileIsInUse);

    openProps.propVal.ival=Constants.FV_ResetLockAndContinue;

    i=GetPropIndex(openProps,Constants.FS_FontChangedMetric);

    openProps.propVal.ival=Constants.FV_DoOK;

    i=GetPropIndex(openProps,Constants.FS_FontNotFoundInCatalog);

    openProps.propVal.ival=Constants.FV_DoOK;

    i=GetPropIndex(openProps,Constants.FS_FontNotFoundInDoc);

    openProps.propVal.ival=Constants.FV_DoOK;

    i=GetPropIndex(openProps,Constants.FS_RefFileNotFound);

    openProps.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.

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

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();

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2015 Mar 06, 2015

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines