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

Text Variable(File Name) not getting original file name when opening document as copy

Explorer ,
Feb 09, 2024 Feb 09, 2024

Hello All,

I have a InDesign file which has text variable (File Name) inserted in text frame. I open indesign file as a copy of original file like below.

 

ErrorCode cmdErrCode = Utils<IDocumentCommands>()->Open(&tempCopyInDesignFileRef, inDesignIDFile, K2::kSuppressUI, IOpenFileCmdData::kOpenCopy, IOpenFileCmdData::kNotUseLockFile, kFalse);

 

Issue is when I try to get text from text frame where text variable(File Name) is set. It gives me text like “Untitled-XX” instead of original file name. 

 

Is there way I can get original file name? Please suggest.

 

Thank You

Chetan S

TOPICS
SDK
388
Translate
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

Adobe Employee , Mar 07, 2024 Mar 07, 2024

Because you opened a copy of the document(IOpenFileCmdData::kOpenCopy) and not the original(IOpenFileCmdData::kOpenOriginal), opened document is only in memory and not saved yet, hence its returning  default document name(Untitled-x) instead of the original document name, which is the expected behaviour. If you need to retrieve the original document name, change the open flags to IOpenFileCmdData::kOpenOriginal

Translate
Community Expert ,
Feb 10, 2024 Feb 10, 2024

Text variable "File Name" is linked - and automatically updated - to the CURRENT document - how can you expect it to be linked with the old file?

 

Translate
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 ,
Feb 10, 2024 Feb 10, 2024

I know even less about plugins than about JS - but isn't: 

&tempCopyInDesignFileRef

a reference to your original file?

 

Can't you get the name from it?

 

Translate
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
Explorer ,
Feb 10, 2024 Feb 10, 2024

2nd parameter is original IDFile

 

I am opening InDesing document and parsing its object to process. there is text frame which contains Text variable "File Name", so for that text frame I should get name of original file but I am getting “Untitled-1”.

Translate
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 ,
Feb 10, 2024 Feb 10, 2024

No, you are working on a completely NEW document - that is just a copy of the original file - all variables that are defined in the document - are pointing to the document they are in - not some old document. 

 

It's like you would expect that after creating new, blank document and doing drag&drop from another document - that values of the VARIABLES will still point to the other document.

 

Those are text VARIABLES - not constants, they change and show current information. 

 

If you add variable that shows current page - and you move it to a different page - which page number would you expect to see? 

 

Translate
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
Explorer ,
Feb 10, 2024 Feb 10, 2024

Yes correct, is there way I can identify where Text variable ("File Name") is applied?

Translate
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 ,
Feb 10, 2024 Feb 10, 2024

What do you mean "where"? 

 

Locations in the text? 

 

https://community.adobe.com/t5/indesign-discussions/script-to-find-variable-text-and-convert-to-text...

 

But I have no idea how to do it in plugin.

 

Translate
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 ,
Feb 10, 2024 Feb 10, 2024

If you want to retain name of the original / source document - you need to define this variable differently - as a "static" text - not as a variable linked to the name of the file.

 

Translate
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 ,
Feb 10, 2024 Feb 10, 2024

@Chetan S

 

Correct me if I'm wrong - you are good with C/C++ and someone asked you to write a plugin - but you don't use InDesign daily?

 

Translate
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
Explorer ,
Feb 11, 2024 Feb 11, 2024

yes I have written plugin in in C/C++,  I am duplicating(creating copy) InDesign file and cant use original file as I am modifying it. 

Translate
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
Adobe Employee ,
Mar 07, 2024 Mar 07, 2024
LATEST

Because you opened a copy of the document(IOpenFileCmdData::kOpenCopy) and not the original(IOpenFileCmdData::kOpenOriginal), opened document is only in memory and not saved yet, hence its returning  default document name(Untitled-x) instead of the original document name, which is the expected behaviour. If you need to retrieve the original document name, change the open flags to IOpenFileCmdData::kOpenOriginal

Translate
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