Highlighted

Save a copy programmatically

Adobe Community Professional ,
Jan 15, 2020

Copy link to clipboard

Copied

Hi All,

 

I have a document open in FrameMaker. I want to save a copy of the document, while leaving the current document open. So, instead of Save As, I want to do Save a Copy. Has anyone done this with the FDK or ExtendScript and will share some code.

 

I see some FDK options that may relate to this: FS_RetainNameStripe, FS_SaveAsModeName, FS_SaveMode. I can play around with these but was hoping someone already figured this out. Thanks in advance.

 

-Rick

TOPICS
Scripting

Views

1.0K

Likes

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

Save a copy programmatically

Adobe Community Professional ,
Jan 15, 2020

Copy link to clipboard

Copied

Hi All,

 

I have a document open in FrameMaker. I want to save a copy of the document, while leaving the current document open. So, instead of Save As, I want to do Save a Copy. Has anyone done this with the FDK or ExtendScript and will share some code.

 

I see some FDK options that may relate to this: FS_RetainNameStripe, FS_SaveAsModeName, FS_SaveMode. I can play around with these but was hoping someone already figured this out. Thanks in advance.

 

-Rick

TOPICS
Scripting

Views

1.0K

Likes

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
Jan 15, 2020 0
Mentor ,
Jan 16, 2020

Copy link to clipboard

Copied

Hi Rick,

 

Is this possible in the UI? I don't think it is, and therefore suspect that the API has no direct route. But I could be wrong. Have you considered creating a new doc from the original doc, using it as a template? I think you can do it with this parameter and the Open() method:

 

Constants.FS_NewDoc

 

Then you could save it and you would have a copy. But maybe this won't work if the template doc is already open.

 

Also, I'm not clear why a Save As and then reopen the original doc is not an option.

 

Hope this helps.

 

Russ

Likes

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
Reply
Loading...
Jan 16, 2020 0
Adobe Community Professional ,
Jan 16, 2020

Copy link to clipboard

Copied

Thanks for the reply Russ. Here is my thinking based on a project I am working on.

 

I have an XML document open in FrameMaker that the user may have made changes to.

They want to run a script that is going to save and transform the document and produce some output.

However, they may not want the changes to the currently open XML file saved.

 

So, I thought if I could save a copy of the current document, it could kick off my transform with the copy while leaving the current document open and "dirty" in case they don't want to save the changes.

 

I am probably making things more complicated than they should be, but to be able to programmatically Save A Copy without saving the current document might be useful.

 

Likes

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
Reply
Loading...
Jan 16, 2020 0
Mentor ,
Jan 16, 2020

Copy link to clipboard

Copied

Interesting challenge! So my idea is useless, because the copy on disk is useless. The only thought that quickly comes to mind is to have a template doc, where you copy the main doc content into it and then do a Save As with the template. This could be done with a hidden doc, as you well know. That's the best I can come up with at the moment.

 

Russ

Likes

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
Reply
Loading...
Jan 16, 2020 0
Enthusiast ,
Jan 16, 2020

Copy link to clipboard

Copied

Hi Rick,

if this copy is in the same folder, I would just make a simple copy.

var goDoc = app.ActiveDoc;
var sFile = goDoc.Name.split("\\").pop()
var sPath = goDoc.Name.split("\\");
sPath.pop();
var sNewFile = sPath.join("\\") + "\\" +"~~" + sFile;   // or just a different appendix
var oFile = new File(goDoc.Name);
oFile.copy(sNewFile);

 

If it should be stored in a different folder, then open this new file with FrameMaker, save it in a different folder and delete the "~~"-file.

Likes

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
Reply
Loading...
Jan 16, 2020 0
Adobe Community Professional ,
Jan 16, 2020

Copy link to clipboard

Copied

Except that I want the new copy to have the current content of the active file, not the last saved content.

Likes

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
Reply
Loading...
Jan 16, 2020 0