Copy link to clipboard
Copied
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
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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”.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Yes correct, is there way I can identify where Text variable ("File Name") is applied?
Copy link to clipboard
Copied
What do you mean "where"?
Locations in the text?
But I have no idea how to do it in plugin.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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