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

[FM11] Print Image Link and Index Markers with specific Character Style

Participant ,
Oct 02, 2012 Oct 02, 2012

Copy link to clipboard

Copied

Hello,

I'm new with scripting for Framemaker. I want to export FM docs to RTF so I can import these into InDesign. For the placed images I want to insert a text line that is showing the image link (reference). Besides that I want to show the Index Markers at the mark insertion position with a different Character Style. Can someone help me with that?

Regards, Sjoerd

TOPICS
Scripting

Views

1.3K

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

correct answers 1 Correct answer

Advocate , Oct 03, 2012 Oct 03, 2012

Hello Sjoerd,

One note about your method to retrieve all linked graphics: this will also process the graphics that might be linked into the master and reference pages. Just to be safe against unwanted side effects you should restrict your list of graphics to the ones in the main flow of your document.

About the tLoc: you are really looking for the anchor of the anchored frame that contains graphic. It is a little confusing that FM calls both the anchored frame and the imported graphic by the same

...

Votes

Translate

Translate
Participant ,
Oct 03, 2012 Oct 03, 2012

Copy link to clipboard

Copied

For the images I come with this script:

var doc= app.ActiveDoc;

ListGraphics(doc);

function ListGraphics(doc)

{

     var graphic = doc.FirstGraphicInDoc;

     while (graphic) {

         if (graphic.type == Constants.FO_Inset) {

             alert(graphic.InsetFile);

             var tLoc= new TextLoc(); //create the text location object

             tLoc // tLoc has to be the where to graphic is located in the flow

             doc.AddText (tLoc, graphic.InsetFile);

             }

         graphic = graphic.NextGraphicInDoc;

      }

}

How do I define tLoc as the location of the graphic so I can insert the path as a line of text near the graphic?

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
Advocate ,
Oct 03, 2012 Oct 03, 2012

Copy link to clipboard

Copied

Hello Sjoerd,

One note about your method to retrieve all linked graphics: this will also process the graphics that might be linked into the master and reference pages. Just to be safe against unwanted side effects you should restrict your list of graphics to the ones in the main flow of your document.

About the tLoc: you are really looking for the anchor of the anchored frame that contains graphic. It is a little confusing that FM calls both the anchored frame and the imported graphic by the same name. Even if you add an anchored frame to the text to put an equation or a text box in your document, the anchored frame will show up in the linked list of graphics in the document. If you do have an anchored frame containing an imported graphic file, you have a list of graphic objects inside the anchored frame, which itself appears in the list of graphic objects of the document.

This function should do what you want to do:

function ListGraphics(doc)

{

          var aframe = doc.FirstGraphicInDoc;

     while (aframe.ObjectValid()) {

         if (aframe.constructor.name == "AFrame") {

                                        graphic = aframe.FirstGraphicInFrame;

             if ( graphic.type == Constants.FO_Inset )

                                             doc.AddText ( aframe.TextLoc, graphic.InsetFile );

                          }

         aframe = aframe.NextGraphicInDoc;

     }

}

I assume you will also want to remove the anchored frames (the imported image files) from the text. This can be done in the same routine, but you must first catch the following element in the linked list of graphics in the doc before you can delete the current one. Otherwise you will only remove the first and end up with an invalid object. The easiest and safest method to do this is to create an array of elements to be deleted. After ending the while loop, you delete those objects. The full code looks like this:

function ListGraphics(doc)

{

          var toDelete = [];

          var aframe = doc.FirstGraphicInDoc;

     while (aframe.ObjectValid()) {

         if (aframe.constructor.name == "AFrame") {

                                        graphic = aframe.FirstGraphicInFrame;

                                        if ( graphic.type == Constants.FO_Inset ) {

                                                       doc.AddText ( aframe.TextLoc, graphic.InsetFile );

                                                       toDelete.push ( aframe );

                                        }

                         }

       aframe = aframe.NextGraphicInDoc;

  }

 

          for ( i = 0; i < toDelete.length; i++ ) {

                         toDelete.Delete();

   } 

}

This works on a small test file I created. If you need more support, feel free to contact me: jang at jang dot nl

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
Participant ,
Oct 03, 2012 Oct 03, 2012

Copy link to clipboard

Copied

This is a perfect solution! Thank you Jang.

Do you also have a solution for my second question about the Index Markers?

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
Advocate ,
Oct 03, 2012 Oct 03, 2012

Copy link to clipboard

Copied

Hi Sjoerd,

The markers are not as complicated as the graphics, so you should be able to manage that, using the same logic of finding and processing all markers before starting to delete all of them.

But I am thinking that pushing content out to RTF so that it can be imported into InDesign seems like a roundabout way of doing what you need to do. Is the content structured FM or unstructured ?

From your name I am guessing you are Dutch. Depending on where you are located I might be able to visit and discuss this with a slightly larger scope in mind. Just drop me a line and I'll see what I can do.

Jang

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
Participant ,
Oct 03, 2012 Oct 03, 2012

Copy link to clipboard

Copied

LATEST

Thank you Jang, this is very helpful.

From your name I am guessing you are Dutch. Depending on where you are located I might be able to visit and discuss this with a slightly larger scope in mind. Just drop me a line and I'll see what I can do.

Yes, you're right, I'm Dutch and I am located in Amsterdam.

Your question about why I need to export it to RTF is because we need to import it in our CMS which only supports this format. The publish engine of the CMS is InDesign Server. That's why I want these requested text lines are available in the content of the CMS. When publishing, InDesign converts these lines back to embedded images and index markers.

This is the script for so far:

var doc= app.ActiveDoc;

var myParagraphFormat = doc.NewNamedObject (Constants.FO_PgfFmt, "Beeld");

var myCharacterFormat = doc.NewNamedObject (Constants.FO_CharFmt, "Index");

myParagraphFormat.Color = Constants.FV_COLOR_MAGENTA;

myCharacterFormat.Color = Constants.FV_COLOR_GREEN;

ListMarkers(doc);

ListGraphics(doc);

function ListMarkers(doc)

{

        var myMarker = doc.FirstMarkerInDoc;

    while (myMarker.ObjectValid()) {

       doc.AddText(myMarker.TextLoc, myMarker.MarkerText);

       myMarker= myMarker.NextMarkerInDoc;

  }

}

function ListGraphics(doc)

{

          var toDelete = [];

          var aframe = doc.FirstGraphicInDoc;

     while (aframe.ObjectValid()) {

         if (aframe.constructor.name == "AFrame") {

                                        graphic = aframe.FirstGraphicInFrame;

                                        if ( graphic.type == Constants.FO_Inset ) {

                                                       doc.AddText ( aframe.TextLoc, graphic.InsetFile );

                                                       toDelete.push ( aframe );

                                        }

                         }

       aframe = aframe.NextGraphicInDoc;

  }

          for ( i = 0; i < toDelete.length; i++ ) {

                         toDelete.Delete();

   }

}

Besides I created a character and a paragraph format, I wan't to apply these formats to both of the added texts. How can I apply these formats?

And the 'myParagraphFormat.Color = Constants.FV_COLOR_MAGENTA' is not working!?

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