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

Automatically place image in slug when creating new file

Explorer ,
Jul 18, 2022 Jul 18, 2022

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
734
Translate
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 Expert , Jul 18, 2022 Jul 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.ac
...
Translate
Adobe Employee ,
Jul 18, 2022 Jul 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-informati... 

I am leaving this discussion open for expert suggestions.

 

Regards

Rishabh

Translate
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

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 😄 

Translate
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

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.

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

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

 

Screen Shot 29.pngexpand image

 

Translate
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

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

Thanks so much!

Translate
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

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!

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

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.pngexpand image

Translate
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

Incredible thank you so much! works perfectly.

Appreciate all the help! 

Translate
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
LATEST

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

Translate
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