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

FrameMaker 11: Is there a way to scale imported graphics automatically to fit the column?

Community Beginner ,
Jan 22, 2024 Jan 22, 2024

Copy link to clipboard

Copied

FrameMaker 11 and DITA. We have a DITA document with some graphics imported by reference wider than a column. Is there a way to scale the image automatically to fit the column/anchored frame instead of cropping it when opening the document, f.ex in read/write rules?

 

Any help appreciated.

Views

129

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 Beginner ,
Jan 22, 2024 Jan 22, 2024

Copy link to clipboard

Copied

The images are in EPS format.

 

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
Explorer ,
Jan 22, 2024 Jan 22, 2024

Copy link to clipboard

Copied

Hi, Tuula268312076vq3

This script fits an image to an anchored frame within a selection.

Do not select all to avoid unexpected results.

I hope it helps you.

 

var doc = app.ActiveDoc;
var tr = doc.TextSelection;
var cmd1 = app.GetNamedCommand ("AlignGfxTBCenter");
var cmd2 = app.GetNamedCommand ("AlignGfxLRCenter");
// Get anchor frame from selection
var textItems = doc.GetTextForRange (tr, Constants.FTI_FrameAnchor);
for (var i=0;i<textItems.length;i++){
    var aFrame = textItems[i].obj;
    var graphic = aFrame.FirstGraphicInFrame;
    var verticalRatio = aFrame.Height / graphic.Height;
    var HorizontalRatio = aFrame.Width / graphic.Width;
    var applicableRatio = verticalRatio > HorizontalRatio ? HorizontalRatio : verticalRatio;
    graphic.Height = graphic.Height * applicableRatio;
    graphic.Width = graphic.Width * applicableRatio;
    // Align image to center of anchor frame
    graphic.GraphicIsSelected = true;
    Fcodes ([cmd1.Fcode]);
    Fcodes ([cmd2.Fcode]);
}

 

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 ,
Jan 23, 2024 Jan 23, 2024

Copy link to clipboard

Copied

This is a useful script. One suggestion is to avoid Fcodes for centering and set the properties LocX and LocY properties directly. You should be able to use this:

graphic.LocX = (aFrame.Width - graphic.Width) / 2;
graphic.LocY = (aFrame.Height - aFrame.Height) / 2;

And of course, you can expand this to work on all of the graphics in the document at once. You can also have a script triggered automatically when the document is opened.

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
Explorer ,
Jan 23, 2024 Jan 23, 2024

Copy link to clipboard

Copied

LATEST

Thank you for your wonderful suggestion.

I modified the script and it became about 2.9x faster.

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