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

Script to change imported graphics to embedded

New Here ,
Jun 02, 2022 Jun 02, 2022

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?

TOPICS
Scripting

Views

364

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
community guidelines
Community Expert ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

Votes

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
community guidelines
Community Expert ,
Jun 02, 2022 Jun 02, 2022

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.

 

  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.

Votes

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
community guidelines
Community Expert ,
Jun 02, 2022 Jun 02, 2022

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

Votes

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

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

Votes

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
community guidelines
Community Expert ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

Let me try it and report back. Thanks Russ.

Votes

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
community guidelines
Community Expert ,
Jun 03, 2022 Jun 03, 2022

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 = "";
    }
}

Votes

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

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.

Votes

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
community guidelines
Community Expert ,
Jun 07, 2022 Jun 07, 2022

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 ();
    }
}

Votes

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
community guidelines
New Here ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

Thank you for this script. This really helps.

Votes

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
community guidelines
Community Expert ,
Jun 07, 2022 Jun 07, 2022

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.

Votes

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
community guidelines
Community Expert ,
Jun 07, 2022 Jun 07, 2022

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.

Votes

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
community guidelines
Community Expert ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines
Community Expert ,
Jun 03, 2022 Jun 03, 2022

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;

Votes

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

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.

Votes

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

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?

 

Votes

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

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Community Expert ,
Jun 03, 2022 Jun 03, 2022

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?

Votes

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
community guidelines
Community Expert ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Community Expert ,
Jun 06, 2022 Jun 06, 2022

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

Votes

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
community guidelines
Community Expert ,
Jun 06, 2022 Jun 06, 2022

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>

Votes

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
community guidelines
Community Expert ,
Jun 06, 2022 Jun 06, 2022

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

Votes

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
community guidelines
Community Expert ,
Jun 03, 2022 Jun 03, 2022

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

Votes

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

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

Votes

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
community guidelines
Community Expert ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

It does indeed. Excellent plugin!

Votes

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
community guidelines