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

Cannot Open .indd template file

New Here ,
Jul 26, 2011 Jul 26, 2011

Copy link to clipboard

Copied

Hi,

I have some javascript code that I am porting from CS3 to CS5.

The code was working well on a Windows Server as CS3.

I have ported this to run fine on my local Mac machine on CS5.

As soon as I try to run this on a Mac Server running CS5 I get issues.

Here is the original code snippet.

template = File("/myDirectory/sample_template.indd");

document = app.open(template, true);

The file exists and template.exists is combing back as 'true'.

The error logging coming back is this:

Error: Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE., Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE.

I have tried the following code variations with the following results in red.

document = app.open(template);
Error: Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE., Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE.

document = app.open(template, OpenOptions.OPEN_ORIGINAL);
Error: defaultValue is undefined, defaultValue is undefined

document = app.open(template, OpenOptions.openOriginal);
Error: defaultValue is undefined, defaultValue is undefined

document = app.open(template, OpenOptions.openCopy);
Error: defaultValue is undefined, defaultValue is undefined


I am running this as CS5 (app.scriptPreferences.version = 7;)

Any ideas why app.open() is failing?

Carlos

TOPICS
Scripting

Views

2.7K

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

LEGEND , Jul 26, 2011 Jul 26, 2011

The arguments to app.open() are different under InDesign server. See: http://jongware.mit.edu/idcs5serv_html_3.0.3d/idservcs5/pc_Application.html#open.

Unsurprisingly, the showingWindow option is omitted, because InDesign Server never shows windows.

Votes

Translate

Translate
Contributor ,
Jul 26, 2011 Jul 26, 2011

Copy link to clipboard

Copied

Hi

You should not omit ShowingWindow in CS5 when use OpenOptions.

"document = app.open(template)" must be used default value to options, why Error?

CS3

app.open(from, [showingWindow])

document = app.open(template);

document = app.open(template, true);

CS5

app.open(from, [showingWindow], [openOption])

document = app.open(template);

document = app.open(template, true);

document = app.open(template, true, OpenOptions.OPEN_ORIGINAL);

document = app.open(template, true, OpenOptions.OPEN_COPY);

Did you try .indt (InDesign Template File)?
Thankyou
mg.

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
LEGEND ,
Jul 26, 2011 Jul 26, 2011

Copy link to clipboard

Copied

The arguments to app.open() are different under InDesign server. See: http://jongware.mit.edu/idcs5serv_html_3.0.3d/idservcs5/pc_Application.html#open.

Unsurprisingly, the showingWindow option is omitted, because InDesign Server never shows windows.

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
New Here ,
Jul 28, 2011 Jul 28, 2011

Copy link to clipboard

Copied

So the general solution which works for me is to check for Server vs Desktop

and use the appropriate parameter list. Something like this:

   if (isInDesignServer == true)
    {
        document = app.open(template, OpenOptions.OPEN_COPY);
    }
    else
    {

        var showWindow = false;
        document =  app.open(template,  showWindow);
    }

thanks guys.

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
LEGEND ,
Jul 28, 2011 Jul 28, 2011

Copy link to clipboard

Copied

It seems like there should be a better way but I don't see one.

I suppose while this could conceivably be a design error, trying

to fix it in the next version doesn't seem like a good idea either,

so there's really nothing we could ask Adobe to do to improve the

situation, right?

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 ,
Jul 28, 2011 Jul 28, 2011

Copy link to clipboard

Copied

What does app.version return on ID Server?

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
LEGEND ,
Jul 28, 2011 Jul 28, 2011

Copy link to clipboard

Copied

It returns "7.0.4.553" -- what were you expecting?

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 ,
Jul 28, 2011 Jul 28, 2011

Copy link to clipboard

Copied

Ah yuck. Well, something like "7.0.4.553 Server". Mind, it has always been advertised as "The application version (string)", not "number" or something.

Okay, then use hasOwnProperty on the Application object? There must be something that Server has and Desktop not -- or the reverse. Would app.hasOwnProperty("activeDocument") do something useful?

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
New Here ,
Jul 28, 2011 Jul 28, 2011

Copy link to clipboard

Copied

Are we now looking for a way to see if the version running is Server or Desktop?

If so, I use this test:

isServer = (app.fullName.toString().indexOf("Server") > -1);

If not, ignore this message.

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
LEGEND ,
Jul 28, 2011 Jul 28, 2011

Copy link to clipboard

Copied

LATEST

Like swingcarlos, I'm a bit confused what problem you're trying to solve, Jongware. He's already got a way to tell.

Though I would probably use application.hasOwnProperty("serverSettings"), but it probably doesn't matter much.

What would be nice would be an open() method with compatible type signatures on both. But it seems clear we're not going to have that.

(There's also app.serverTest(), but I don't know what that does... Ah well...)

Oh, and in case you're curious about app.fullName:

app.fullName
Result: /Applications/Adobe%20InDesign%20CS5.5%20Server/InDesignServer.app

decodeURI(app.fullName)
Result: /Applications/Adobe InDesign CS5.5 Server/InDesignServer.app

app.version
Result: 7.5.0.142

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