Automatically place image in slug when creating new file

Explorer ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

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!

TOPICS
How to , Scripting

Views

192

Likes

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

Adobe Community Professional , Jul 18, 2022 Jul 18, 2022

Hi @Aidan5E2A , 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.
...

Likes

Translate

Translate
Adobe Employee ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Hi @Aidan5E2A ,

 

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-informati... 

I am leaving this discussion open for expert suggestions.

 

Regards

Rishabh

Likes

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 ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

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 😄 

Likes

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
Adobe Employee ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

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.

Likes

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
Adobe Community Professional ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

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.

Likes

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
Adobe Community Professional ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Hi @Aidan5E2A , 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

 

Screen Shot 29.png

 

Likes

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 ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

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

Thanks so much!

Likes

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 ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Ive got it working with file selection enabled

var fp = File.openDialog("Select the slug file", "");

But I cant get it to find the file automatically

If my path is (im on a mac): 
/Volumes/Server1/Folder1/LOGOS/BRANDING.pdf
How would the line 4 look if thats the logo I wanted to use?
I appreciate the help - this is exactly what ive been wanting! Thanks so much!

Likes

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
Adobe Community Professional ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

You could get the path to a file with this—it displays an alert with the path and writes it into ExtendScript’s or Visual Studio’s console:

 

 

var fp = File.openDialog("Select the slug file", "");
alert(fp);
$.writeln(fp)

 

 

Make sure you enclose the path in quotes, this would be:

 

 

var fp = "~/Documents/Slug/Logo.psd"

 

 

Screen Shot 31.png

Likes

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 ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Incredible thank you so much! works perfectly.

Appreciate all the help! 

Likes

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
Adobe Employee ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

LATEST

Glad to hear that! Feel free to reach out if you need any further assistance.

Likes

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