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

Script to change imported graphics to embedded

New Here ,
Jun 02, 2022 Jun 02, 2022

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?

TOPICS
Scripting
1.4K
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 ,
Jun 02, 2022 Jun 02, 2022
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 ,
Jun 02, 2022 Jun 02, 2022

I can't help with the script, but there is a brute force method that is slightly easier than finding each graphic.

 

  1. Open the Insets pod (View > Panels > Insets).
  2. Change the filter to All Documents (funnel icon on the right side of the pod).
  3. Select an imported image, then from the toolbar click Import New (leftmost icon). The Import window is displayed.
  4. Select Copy Into Document and click Replace.

 

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.

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 ,
Jun 02, 2022 Jun 02, 2022

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

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
Mentor ,
Jun 03, 2022 Jun 03, 2022

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

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 ,
Jun 03, 2022 Jun 03, 2022

Let me try it and report back. Thanks Russ.

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 ,
Jun 03, 2022 Jun 03, 2022

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 = "";
    }
}
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
New Here ,
Jun 06, 2022 Jun 06, 2022

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.

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 ,
Jun 07, 2022 Jun 07, 2022

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 ();
    }
}
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
New Here ,
Jun 07, 2022 Jun 07, 2022

Thank you for this script. This really helps.

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 ,
Jun 07, 2022 Jun 07, 2022

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.

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 ,
Jun 07, 2022 Jun 07, 2022

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.

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 ,
Jun 07, 2022 Jun 07, 2022
LATEST

I use this script every time I release a document to keep the original source, images, etc. intact. 

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 ,
Jun 03, 2022 Jun 03, 2022

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;
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
Mentor ,
Jun 03, 2022 Jun 03, 2022

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.

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
New Here ,
Jun 06, 2022 Jun 06, 2022

Hi Russ,

 

Would your plugin provided the functionality I asked about above, converting multiple linked graphics in a document to embedded?

 

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
Mentor ,
Jun 06, 2022 Jun 06, 2022

No, it does not... mainly because it is an uncommon use case.

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 ,
Jun 03, 2022 Jun 03, 2022

So is the original object path\name preserved on either original copy-into-file or conversion from by-ref to c-i-f?

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 ,
Jun 06, 2022 Jun 06, 2022

No. Once it is converted to By Copy, you lose any reference to the original file name/path.

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 ,
Jun 06, 2022 Jun 06, 2022

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).

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 ,
Jun 06, 2022 Jun 06, 2022

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>
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 ,
Jun 06, 2022 Jun 06, 2022

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"?

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 ,
Jun 03, 2022 Jun 03, 2022

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


Bjørn Smalbro - FrameMaker.dk
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
Mentor ,
Jun 03, 2022 Jun 03, 2022

Well, not to show off, but that plugin I mentioned above basically gives you a version of that. And a lot more. 🙂

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 ,
Jun 03, 2022 Jun 03, 2022

It does indeed. Excellent plugin!


Bjørn Smalbro - FrameMaker.dk
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