Skip to main content
Known Participant
March 23, 2022
Question

Document.save() for old documents created in 2019 not works in InDesign Server CC2021

  • March 23, 2022
  • 3 replies
  • 796 views

Hi All,

 

In our workflow we had some old documents created in year 2019.

Now when we opened those documents in 'InDesign Server CC 2021' and try to save the document with code

var objFile = File(strDocPath);
if(objFile.exists) {
    objDoc = app.open(strDocPath);

}

 

if(objDoc)
{
      if(!objDoc.saved) {
        objDoc.save(File(strDocPath));
      }
}
 
then it set the document size as 0 (zero).
 
Does anyone experienced such thing.
 
Let me know what could be the reason of it.
 
InDesign Server Version CC 2021 (16.4)
Mac OSX 10.14.6, Intel based.
 
Regards,
Alam
 
 

 

Regards,

Alam

This topic has been closed for replies.

3 replies

Community Expert
March 24, 2022

What do you mean exactly by docId  ?

Wouldn't that be a value you could also apply to the saved duplicate of the document?

( Here I assume, that you perhaps identify a document by the value of a label you set with insertLabel("key string","value string") . )

 

Regards,
Uwe Laubender

( ACP )

Alam5EC6Author
Known Participant
March 24, 2022

objDoc = app.open(docPath);

docId = objDoc.id

 

Regards,

Alam

Community Expert
March 24, 2022

Hm. By far this is not a unique id.

Close a document, open it again and you'll see a new number for the same document.

 

Regards,
Uwe Laubender

( ACP )

 

 

Community Expert
March 24, 2022

Hi Alam,

if both files of Mark's solution are ok with you, you could remove the old one and rename the new one.

It's a workaround, yes. But what would you like to do?

 

Perhaps you could open a copy of the file and work with that?

 

var newDocument = app.open( strDocPath , OpenOptions.OPEN_COPY  );
newDocument.save( File(strDocPath));

 

Don't know if that will change something for you.

Have not InDesign Server installed.

 

Regards,
Uwe Laubender

( ACP )

Alam5EC6Author
Known Participant
March 24, 2022

Hi Uwe,

 

I am doing following with open file

if(objDoc)
{
        if(!objDoc.saved)
              objDoc.save(File(strDocPath));
 
    // setUnitToMillim
   // generateFontReport
// return docId to java BE to execute other scripts for further workflow and other scripts expect docId instead of document path
 
Regards,
Alam
}

 

Regards,

Alam

m1b
Community Expert
Community Expert
March 23, 2022

@Alam5EC6 wrote:
then it set the document size as 0 (zero).

 

Yikes! So it basically destroys the file?! I'm not experienced with Indesign Server, but while we wait for an expert, you could try changing the line

objDoc.save(File(strDocPath));

to

objDoc.save(File(strDocPath.replace(/\.indd/, '_test.indd')));

This will just save the .indd document with "_test" suffix, just to see if the test file also is zero size.

- Mark

Alam5EC6Author
Known Participant
March 24, 2022

Hi Mark

 

After following your steps I see two files in my working folder one with originol name and other with _test name.

But I need one file in my working folder.

 

Do you have any other solution?

 

Regards,

Alam

m1b
Community Expert
Community Expert
March 24, 2022

Hi @Alam5EC6, sorry I wasn't offering a solution—that was just a test to see if the 2nd file (the one with _test) had zero size. In other words does the problem you are having go away if you save into a new file vs saving into the same file? Can you check and let us know?

Because I have no idea what's happening for you I am trying to help you troubleshoot. That's all. Let me know the result.

- Mark