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

Framemaker15-how to change logo on the reference page

Community Beginner ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Hello forum.

i am a new user of framemaker since may2017. I have little skill  with VBA and javascript but not professionnal  .

with my new job i receive every month documentantion from manufacturer and we custumize them.

So each month we copy the manufacturer file with new template and import them in our books.

but before importing i have to swap the manufacturer logo of the book by my compagny logo and some more minor modifications.

as this task is repetitive i think i could do it with extendscript

i send a zip file on adobe cloud with  a sample framemaker book i made and the script i wrote during the last 2 weeks with tips i found on internet.

the script open all files in a folder  and that all. i didin't find anything about how to change logo on the reference page

FOR THE MAIN PROBLEM i need your help to swap the logo. i put in the zip file à new sample logo for the test.

if you have 5 minutes more but not necessary if your time is precious you can answer to the 3 minor questions about access and modification to the copyrignt and how to change a variable (see inside the script).

As you can see english is not my native language i hope you will understand my problem.

best regards from France

click below for the zip file with the sample book , script and fake logo

Fichiers partagés - Acrobat.com

TOPICS
Scripting

Views

663

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

Community Beginner , Jan 23, 2018 Jan 23, 2018

Hello Forum.

You can find hereafter the code that i made with your help .

(Sorry  i don't know how to insert code in code frame).

var aFrame = null;
var MM = 65536 * 2.834645669; // VAR to convert in milimetres
var doc = app.ActiveDoc;

var insetPath= "C:\\Nouveau template\\Logo_AF_3cm.png";

firstRef = doc.FirstRefPageInDoc;
doc.CurrentPage = firstRef;
NettoieFrame(doc);
ImportLogoAF(doc);
// 23jan18 updateManuelNbrVAR(doc);
// On revient sur la premiere page (Body Page)
// Come back to the first body page
 

...

Votes

Translate

Translate
Community Expert ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Is the logo inside of a named unanchored frame on the reference page? You can access these frames by name. For example,

var doc = app.ActiveDoc;

var refFrame = doc.GetNamedUnanchoredFrame ("Single Line");

alert (refFrame.ObjectValid ());

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 Beginner ,
Jul 24, 2017 Jul 24, 2017

Copy link to clipboard

Copied

Tank you for your help.

with the following code :

var refFrame = doc.GetNamedUnanchoredFrame ("Logo");

the alert message send 1 seems to be "OK"

so now how to swap and copy Inside not by reference  the logo (insert for framemaker) by mine.

(see zip file on adobe cloud).

best regards

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 ,
Jul 24, 2017 Jul 24, 2017

Copy link to clipboard

Copied

You need to figure out how to import an image into your document and move it to that frame. To import an image, you use the Import method on a Doc object. To move an image, you set its FrameParent property to the target frame. I don't have time to code this for you, but this should get you started.

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 ,
Jul 25, 2017 Jul 25, 2017

Copy link to clipboard

Copied

Your refFrame points to the frame on the reference page. The logo in the frame is a graphic object, which you can change to point to another file. Assuming the graphic is the only object in the reference frame, this will make the change for you.

var oGraphic = refFrame.FirstGraphicInFrame;

oGraphic.InsetFIle = "[reference to new logo file]" ;

Note that this does not change the image on the screen immediately. When saving and reopening the file, the change is there. Also note that the frame is not going to be resized and the new logo is supposed to have the same dimensions and DPI. If dimensions are different, you need to adapt the frame size or the graphic file DPI in your code. That is something you need to figure out using the Scripting Guide.

4everJang

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 Beginner ,
Jan 23, 2018 Jan 23, 2018

Copy link to clipboard

Copied

LATEST

Hello Forum.

You can find hereafter the code that i made with your help .

(Sorry  i don't know how to insert code in code frame).

var aFrame = null;
var MM = 65536 * 2.834645669; // VAR to convert in milimetres
var doc = app.ActiveDoc;

var insetPath= "C:\\Nouveau template\\Logo_AF_3cm.png";

firstRef = doc.FirstRefPageInDoc;
doc.CurrentPage = firstRef;
NettoieFrame(doc);
ImportLogoAF(doc);
// 23jan18 updateManuelNbrVAR(doc);
// On revient sur la premiere page (Body Page)
// Come back to the first body page
    firstRef = doc.FirstBodyPageInDoc ;
    doc.CurrentPage = firstRef;
   

function ImportLogoAF(DZGdoc){
var refFrame = DZGdoc.GetNamedUnanchoredFrame ("Logo");   
// On crée une nouvelle page reference-
// New ref page insert after  the last ref page
var NwPageRef= DZGdoc.NewNamedObject(Constants.FO_RefPage, "Swap_Logo1");
//$.writeln ("NwPageRef.id1=" +NwPageRef.id);
var page = DZGdoc.LastRefPageInDoc; 

//On crée une nouvelle unanchored frame-
// New unanchored frame inserted
aFrame = DZGdoc.NewUnanchoredFrame (page.PageFrame); 
aFrame.Width = 50 * MM;
aFrame.Height = 50 * MM; 

//On crée un nouveau  textframe dans l'unchoredframe-
//New textframe inserted in the unanchored frame
var textFrame = DZGdoc.NewGraphicObject(Constants.FO_TextFrame, aFrame); 
  
    if(textFrame.ObjectValid()) 
    { 
      
        //Position and size the text frame to fit the anchored frame
        
        textFrame.LocX = (2 * 65536); 
        textFrame.LocY = (2 * 65536); 
        textFrame.Width = 40 * MM; 
        textFrame.Height = 40* MM; 
    } 
 
    //get the first paragraph in the new frame and   set up a text location for the import 
    var pgf = textFrame.FirstPgf; 
    var textLoc = new TextLoc(pgf, 0); 
 
    //set up the prop vals structures and do the import. 
   var props = new PropVals(); 
  
   props = GetImportDefaultParams(); 
   var index = GetPropIndex(props, Constants.FS_HowToImport); 
   if(index > -1) props[index].propVal.ival = Constants.FV_DoByCopy; //import by copy 

    var returnParms = new PropVals(); 
    // on importe le nouveau logo dans la textframe -
    // Logo imported in the texframe
    DZGdoc.Import (textLoc, insetPath, props, returnParms); 
   
    // on selectionne le logo et on le deplace-
    //Logo selected and moved to the LOGO frame
    var oGraphic = textFrame.FirstAFrame;
    var oGraphic = oGraphic.FirstGraphicInFrame;
    oGraphic.FrameParent = refFrame;

// on recadre le logo dans le nouvel emplacement-
// Logo fit to the new place
    oGraphic.LocX=43.28*MM;
    oGraphic.LocY=1*MM;
    oGraphic.InsetDpi = 150;
  
   
//On supprime les emplacements provisoires   -
//Temporary frame deleted
    aFrame.Delete();
    oGraphic.GraphicIsSelected=true;
    aFrame.Delete();
    var RefPageToDelete=DZGdoc.GetNamedObject(Constants.FO_RefPage, "Swap_Logo1");
    RefPageToDelete.Delete();
 
// On revient sur la premiere page (Body Page) 
//-Come back to the body page
    firstRef = DZGdoc.FirstBodyPageInDoc ;
    DZGdoc.CurrentPage = firstRef;
 
// Fin de l'import du Logo  -END
}  
   
   
 

function NettoieFrame (DZGdoc2) { 
//Suppression du  logo
// Celui ci est composé d'une multitude d'objets  graphics comme des elipses, Groups,polygon
// This function cleans the logo frame
var DZG_Frame = DZGdoc2.GetNamedUnanchoredFrame ("Logo");
  var graphic, frames = [], objType; 
  
     graphic = DZG_Frame.FirstGraphicInFrame; 
     while (graphic.ObjectValid () === 1) { 
            objType = graphic.constructor.name;
            $.writeln ("objtype="+objType);
            if (objType === "Arc" ||
                  objType === "Ellipse" || objType === "Group" ||
                  objType === "Inset" || objType === "Line" ||
                  objType === "Math" || objType === "Polygon" ||
                  objType === "Polyline" || objType === "Rectangle" ||
                  objType === "RoundRect") {
             frames.push (graphic);          
                }else if (objType === "TextFrame"){
                      
                        // Delete the first paragraph in the text frame. 
                        graphic.FirstPgf.Delete (); 
                        //Add the new text. 
                        var textLoc = new TextLoc (graphic.FirstPgf, 0); 
                        doc.AddText (textLoc, "THIS MANUAL");

                    }
          
            
         graphic = graphic.NextGraphicInFrame; 
     } 
      
     deleteFrames( frames); 

  
function deleteFrames (frames) { 
   $.writeln ("Nb frame to delete="+frames.length);
     for (var i = 0; i < frames.length; i += 1) { 
         frames.Delete (); 
     } 

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