Copy link to clipboard
Copied
A few years ago, someone in this community sent me a script that allowed me to convert the imported grapics in a FrameMaker document to embedded. There were actually two scripts, one that selected each graphic one at a time and gave you the option to emded, and one that embedded all imported graphics in one step. Unfortunately, these scripts have been lost. Does anyone know where I can find a script to do this, or the steps to create this script?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I can't help with the script, but there is a brute force method that is slightly easier than finding each graphic.
You'll have to do it for each image, but at least you don't have to find each graphic in the document and go through the whole find it/import it/resize it dance.
Copy link to clipboard
Copied
I don't remember writing a script like this because most of the time, people want to do the opposite: convert imported by copy to imported by reference. I could look at writing a script like this for you that would basically automate the steps that Lin outlined. Please contact me offlist: rick at frameexpert dot com
Copy link to clipboard
Copied
Rick, if I recall, it is just a single call to set InsetFile to an empty string for each graphic. No need to reimport, etc. If I recall.
Russ
Copy link to clipboard
Copied
Let me try it and report back. Thanks Russ.
Copy link to clipboard
Copied
Russ, you are right! Such a simple solution that I never thought to try. Thank you.
#target framemaker
var doc, graphic;
doc = app.ActiveDoc;
graphic = doc.FirstSelectedGraphicInDoc;
if (graphic.constructor.name === "Inset") {
if (graphic.InsetFile !== "") {
graphic.InsetFile = "";
}
}
Copy link to clipboard
Copied
Is it possible to modify that script to convert all graphics in a documet to embedded? The document I am working on has hundreds of postage stamp sized graphics that need to be converted from linked to embedded.
Copy link to clipboard
Copied
Here is a script that will convert all of the imported graphics in a document to By Copy. Be careful because there is no undo.
#target framemaker
main ();
function main () {
var doc;
doc = app.ActiveDoc;
if (doc.ObjectValid () === 1) {
processDoc (doc);
}
}
function processDoc (doc) {
var graphic;
// Turn off the displaying property to speed the script and prevent flicker.
if (app.Displaying === 1) {
app.Displaying = 0;
}
// Loop through the imported graphics.
graphic = doc.FirstSelectedGraphicInDoc;
while (graphic.ObjectValid () === 1) {
if (graphic.constructor.name === "Inset") {
if (graphic.InsetFile !== "") {
graphic.InsetFile = "";
}
}
graphic = graphic.NextGraphicInDoc;
}
if (app.Displaying === 0) {
app.Displaying = 1;
doc.Redisplay ();
}
}
Copy link to clipboard
Copied
Thank you for this script. This really helps.
Copy link to clipboard
Copied
Keep in mind that any apparent need for copy-in objects (vs. import-by-ref) needs a ponder as to why. It creates material support problems for future stewards of the document.
When I last had a need (over decade ago now), it was for sending out for translation, and the solution was scripts to gather all the imports into the doc's local ./images/ dir, and make a copy of the .book & .fm file with all refs refactored to point there, but left as import-by-ref. A zip of the whole thing was sent out.
Copy link to clipboard
Copied
Good point Bob. That was one of the purposes of my ArchiveES script: to collect all of the documents and images and text insets used in a particular book to a single folder (and subfolders). The folder could then be zipped and sent out and all of the links would be intact.
Copy link to clipboard
Copied
I use this script every time I release a document to keep the original source, images, etc. intact.
Copy link to clipboard
Copied
Somewhat surprisingly (at least to me, anyway), I am able to go in the other direction too. After I set the InsetFile property to an empty string, I can reset it to the path to the original graphic, and it converts back to Import by Reference.
#target framemaker
var doc, graphic, file;
file = new File ("C:\\Users\\rick\\Documents\\Convert to HTML5\\Output\\topics\\media\\image2.png");
doc = app.ActiveDoc;
graphic = doc.FirstSelectedGraphicInDoc;
graphic.InsetFile = file.fsName;
Copy link to clipboard
Copied
Yeah. It surprised me too originally, that something in scripting could be so much simpler than the UI. Usually the other way around. The great part about it is that you don't have to fuss with any other graphic properties... it stays looking exactly the same during either conversion.
I made abundant use of this little gem in my WS Utilities plugin.
Copy link to clipboard
Copied
Hi Russ,
Would your plugin provided the functionality I asked about above, converting multiple linked graphics in a document to embedded?
Copy link to clipboard
Copied
No, it does not... mainly because it is an uncommon use case.
Copy link to clipboard
Copied
So is the original object path\name preserved on either original copy-into-file or conversion from by-ref to c-i-f?
Copy link to clipboard
Copied
No. Once it is converted to By Copy, you lose any reference to the original file name/path.
Copy link to clipboard
Copied
Rick: Once it is converted to By Copy, you lose any reference to the original file name/path.
Thanks. That's what I thought, and why copy-in objects are a potential disaster for document stewardship (even just sending out for translation).
Copy link to clipboard
Copied
The smart way to do it would be to store the original data somewhere, perhaps in a simple XML file:
<settings>
<image aframe-id="123456" path="C:\MyImages\widget.png" doc="C:\Docs\MyManual.fm"/>
</settings>
Copy link to clipboard
Copied
It is a pity that the object Inset (e.g. referenced or copied graphic) does not have a UserString property. Would allow to store the InsetFile from the imported by reference to the UserString of the copied graphic - but this is not possible...
On the other hand, what is the property UserString good for the object "app"?
Copy link to clipboard
Copied
One of my favourite pet peeves here. Please upvote my suggestion of adding a browse button to the Object Properties Panel when viewing a graphic which has been imported by copy.
https://tracker.adobe.com/#/view/FRMAKER-11783
Copy link to clipboard
Copied
Well, not to show off, but that plugin I mentioned above basically gives you a version of that. And a lot more. 🙂
Copy link to clipboard
Copied
It does indeed. Excellent plugin!