Skip to main content
Inspiring
July 18, 2022
Answered

Automatically place image in slug when creating new file

  • July 18, 2022
  • 3 replies
  • 1066 views

Hello, 

 

Im looking for a script or something similar that will:
When the script runs - Add specified amount of slug and place specified image (could be linked from a file path) into a specified area of the slug (could be top bottom right left ect ect).

Ive now figured out I can have images in the slug, which is greatmfor branding. But I can be using up to 20 indesign files a day, and even though it doesnt take too long to do... it adds up very quickly. A script bound to a shortcut would work magic.

Cheers for any help in advance!

This topic has been closed for replies.
Correct answer rob day

Hi @Aidan_C , I’m not sure if this would always work—you set the bottom slug size and the path to the file in the first two lines. You could also uncomment the line that asks you to choose a file if you don’t want to hardwire the path:

 

// the bottom slug amount in inches
bs = 1;
//path to the file
var fp = Folder.desktop + "/Logo.psd"
//or a selection dialog
//var fp = File.openDialog("Select the slug file", "");


app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES;
var d = app.activeDocument;
d.zeroPoint = [0, 0];
d.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
d.documentPreferences.slugBottomOffset = bs;
var bb = d.documentPreferences.documentBleedBottomOffset;
var h = d.documentPreferences.pageHeight + bb;
var mp = app.documents[0].masterSpreads.everyItem().pages.everyItem().getElements();

var lgo, b, sc, pf;
for (var i = 0; i < mp.length; i++){
    lgo = mp[i].place(File(fp), [0, h]);
    pf = lgo[0].parent
    b = lgo[0].geometricBounds
    sc = ((bs-bb)/(b[2]-b[0]))*100;
    pf.absoluteHorizontalScale = sc;
    pf.absoluteVerticalScale = sc;
    pf.move( [ 0 , h ]); 
};  

 

Places the file in the lower left slug on all of the Masters

 

 

3 replies

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
July 18, 2022

Hi @Aidan_C , I’m not sure if this would always work—you set the bottom slug size and the path to the file in the first two lines. You could also uncomment the line that asks you to choose a file if you don’t want to hardwire the path:

 

// the bottom slug amount in inches
bs = 1;
//path to the file
var fp = Folder.desktop + "/Logo.psd"
//or a selection dialog
//var fp = File.openDialog("Select the slug file", "");


app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES;
var d = app.activeDocument;
d.zeroPoint = [0, 0];
d.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
d.documentPreferences.slugBottomOffset = bs;
var bb = d.documentPreferences.documentBleedBottomOffset;
var h = d.documentPreferences.pageHeight + bb;
var mp = app.documents[0].masterSpreads.everyItem().pages.everyItem().getElements();

var lgo, b, sc, pf;
for (var i = 0; i < mp.length; i++){
    lgo = mp[i].place(File(fp), [0, h]);
    pf = lgo[0].parent
    b = lgo[0].geometricBounds
    sc = ((bs-bb)/(b[2]-b[0]))*100;
    pf.absoluteHorizontalScale = sc;
    pf.absoluteVerticalScale = sc;
    pf.move( [ 0 , h ]); 
};  

 

Places the file in the lower left slug on all of the Masters

 

 

Aidan_CAuthor
Inspiring
July 19, 2022

Wow that looks amazing, ill have a go with it and let you know!

Thanks so much!

Peter Spier
Community Expert
Community Expert
July 18, 2022

I'm not a scripter, but if you are dealing with standard (repeating) size documents over and over you can make templates for those sizes that include slugs and images.

Back when I did a lot of advertising work I made templates for all common size ads I dealt with.

Rishabh_Tiwari
Community Manager
Community Manager
July 18, 2022

Hi @Aidan_C ,

 

Thanks for reaching out. I couldn't find a post with the specific script however I found a similar discussion on how to achieve this without script which you can refer to here https://community.adobe.com/t5/indesign-discussions/add-logo-watermark-to-print-marks-page-information/td-p/13071880 

I am leaving this discussion open for expert suggestions.

 

Regards

Rishabh

Aidan_CAuthor
Inspiring
July 18, 2022

Thanks for the response Rishabh, thats actually my post from earlier asking how to add the logo to start with. I made a new thread specifically asking if there is a script - would save so much time. Appreciate the help though, fingers crossed there is a wizard out there that can help 😄 

Rishabh_Tiwari
Community Manager
Community Manager
July 18, 2022

Oh! I am so sorry, somehow I missed that you're the author of that thread, I shared it as I found that thread relatable. Having said that, since a script is needed for this use case so I am leaving this discussion open for other scripting experts in this community.