0

InDesign script to replace all fonts in a document

I used the above script to change fonts in multiple documents, only to find out that it doesn't also change the fonts in the Master Pages, which I need it to do. Is there a way to edit the script or create a new one that will also change the fonts in the master pages and not just the main document?

2 Answers 2

1

I took the script provided in your linked thread and researched a bit and found the way to do it through script.

See the original script with my addition below:

// Replace fonts in current INDD doc according to a set list
// Each line in theFontReplacements: 'Existing Font', 'Existing Style', 'New Font', 'New Style',
// Styles are optional - leave blank ('') if unwanted

var mydoc = app.activeDocument;

var theFontReplacements = [
  'Minion Pro','Regular','Calibri','Regular',
  'Trade Gothic LT Std','Regular','Calibri','Regular',
  'Trade Gothic LT Std','Bold No. 2','Calibri','Bold',
  'Trade Gothic LT Std','Oblique','Calibri','Italic',
];

for (i = 0; i < (theFontReplacements.length/4); i++) {

  //*****
  app.findChangeTextOptions.includeMasterPages = true; //change master pages too (reference http://jongware.mit.edu/idcs6js/pc_FindChangeTextOption.html)
  //*****
  app.findTextPreferences = NothingEnum.nothing;
  app.changeTextPreferences = NothingEnum.nothing;
  app.findTextPreferences.appliedFont = theFontReplacements[i*4];
  if (theFontReplacements[(i*4)+1] != ''){
    app.findTextPreferences.fontStyle = theFontReplacements[(i*4)+1];
  };
  app.changeTextPreferences.appliedFont  = theFontReplacements[(i*4)+2];
  if (theFontReplacements[(i*4)+3] != ''){
    app.changeTextPreferences.fontStyle  = theFontReplacements[(i*4)+3];
  };
  mydoc.changeText();

};

Just add the line I "highlighted" (app.findChangeTextOptions.includeMasterPages = true;) to the script and you are good to go.

You can check the reference I added for other options you can use, like change hidden or locked layers.

Good luck!

-1

You must check the Include Master Pages icon at the Find/Change window to allow changes in master pages

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.