Skip to main content
Known Participant
August 19, 2021
Répondu

Add bleed input to a slug

Hi all you big brains.

I know nothing about scripting but I've managed to amend a script an old work collegue did for me many moons ago. I need to be able to add the bleed amounts to the relevant parts of a slug made from a table:

I have text variables for the Ref (file name), Mod dates, Mod by and have a script for the width and height inputs:

 

// WORKING ON CURRENT DOCUMENT
var myDocument = app.activeDocument;

// INITIAL SETTINGS
myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
myDocument.zeroPoint=[0,0];
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;

// WORKING WITH ACTIVE PAGE
var currentPage = myDocument.layoutWindows[0].activePage;
var width, height; // SOME VARIABLES

// GETTING THE PAGE SIZES
width = currentPage.bounds[3] - currentPage.bounds[1];
height = currentPage.bounds[2] - currentPage.bounds[0];

// ROUND THE NUMBERS
var widthRounded = width.toFixed(2);
var heightRounded = height.toFixed(2);

var realHeight = heightRounded*10;
var realWidth = widthRounded*10;

var ShowType;

// WORKING WITH TABLES ON THE ACTIVE PAGE
var myTables = app.layoutWindows[0].activePage.textFrames.everyItem().tables;

// show row and column of selected cell
//alert(app.selection[0].parentRow.index+"\n"+app.selection[0].parentColumn.index);

// CHECK IF THERE IS THE SLUG IN THE DOCUMENT
if(myTables.length>0)
{
ShowType = "ORG-GARTNER";
// PLACE THE SIZES IN THE SLUG
myTables[0].cells[12].contents = (""+realWidth);
myTables[0].cells[13].contents = (""+realHeight);
}

 

 

If anyone could tell me what to add and where, I would be extremely grateful and send you a virtual donut.

Ce sujet a été fermé aux réponses.
Meilleure réponse par Mike Bro

Sorry my man,

In the template, the page size of the document is set up as 400mm x 250mm, but the script makes the slug entry 4000 x 2500 because the code above that has *10 multiplies by 10.

The new part you added for bleed enters the numbers at s/s so instead of saying 100mm bleed, it will enter the number as 10. I wondered if there was a way of applying that *10 to the bleed output to make the correct size show.

Hope that makes sense

Many thanks

Maybz


Hi @Mayberry_Maybz,

 

Give this a try....

// WORKING ON CURRENT DOCUMENT
var myDocument = app.activeDocument;

// INITIAL SETTINGS
myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
myDocument.zeroPoint=[0,0];
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;

// WORKING WITH ACTIVE PAGE
var currentPage = myDocument.layoutWindows[0].activePage;
var width, height; // SOME VARIABLES

// GETTING THE PAGE SIZES
width = currentPage.bounds[3] - currentPage.bounds[1];
height = currentPage.bounds[2] - currentPage.bounds[0];

// ROUND THE NUMBERS
var widthRounded = width.toFixed(2);
var heightRounded = height.toFixed(2);

var realHeight = heightRounded*10;
var realWidth = widthRounded*10;

var myLeftBleed = myDocument.documentPreferences.documentBleedInsideOrLeftOffset*10;
var myRightBleed = myDocument.documentPreferences.documentBleedOutsideOrRightOffset*10;
var myTopBleed = myDocument.documentPreferences.documentBleedTopOffset*10;
var myBottomBleed = myDocument.documentPreferences.documentBleedBottomOffset*10;

var ShowType;

// WORKING WITH TABLES ON THE ACTIVE PAGE
var myTables = app.layoutWindows[0].activePage.textFrames.everyItem().tables;

// show row and column of selected cell
//alert(app.selection[0].parentRow.index+"\n"+app.selection[0].parentColumn.index);

// CHECK IF THERE IS THE SLUG IN THE DOCUMENT
if(myTables.length>0)
{
ShowType = "ORG-GARTNER";
// PLACE THE SIZES IN THE SLUG
myTables[0].cells[12].contents = ("" + realWidth);
myTables[0].cells[13].contents = ("" + realHeight);

// PLACE THE BLEED SIZES IN THE SLUG
myTables[0].cells[15].contents = ("Left: " + myLeftBleed);
myTables[0].cells[16].contents = ("Right: " + myRightBleed);
myTables[0].cells[17].contents = ("Top: " + myTopBleed);
myTables[0].cells[18].contents = ("Bottom: " + myBottomBleed);
}

Regards,

Mike

1 commentaire

Legend
August 20, 2021

Hello @Mayberry_Maybz

 

Can you post a InDesign document that only contains the slug made from the table for testing purposes?

I just want to make sure I'm getting the correlating bleed settings into the correct cells.

 

Regards,

MIke

Known Participant
August 20, 2021

Hi Mike,

Thanks for the reply.

Here is the InDesign doc. Appreciate the help.

Legend
August 20, 2021

Hello @Mayberry_Maybz 

 

Here you go...enjoy!!

 

 

// WORKING ON CURRENT DOCUMENT
var myDocument = app.activeDocument;

// INITIAL SETTINGS
myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
myDocument.zeroPoint=[0,0];
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;

// WORKING WITH ACTIVE PAGE
var currentPage = myDocument.layoutWindows[0].activePage;
var width, height; // SOME VARIABLES

// GETTING THE PAGE SIZES
width = currentPage.bounds[3] - currentPage.bounds[1];
height = currentPage.bounds[2] - currentPage.bounds[0];

// ROUND THE NUMBERS
var widthRounded = width.toFixed(2);
var heightRounded = height.toFixed(2);

var realHeight = heightRounded*10;
var realWidth = widthRounded*10;

var myLeftBleed = myDocument.documentPreferences.documentBleedInsideOrLeftOffset;
var myRightBleed = myDocument.documentPreferences.documentBleedOutsideOrRightOffset;
var myTopBleed = myDocument.documentPreferences.documentBleedTopOffset;
var myBottomBleed = myDocument.documentPreferences.documentBleedBottomOffset;

var ShowType;

// WORKING WITH TABLES ON THE ACTIVE PAGE
var myTables = app.layoutWindows[0].activePage.textFrames.everyItem().tables;

// show row and column of selected cell
//alert(app.selection[0].parentRow.index+"\n"+app.selection[0].parentColumn.index);

// CHECK IF THERE IS THE SLUG IN THE DOCUMENT
if(myTables.length>0)
{
ShowType = "ORG-GARTNER";
// PLACE THE SIZES IN THE SLUG
myTables[0].cells[12].contents = ("" + realWidth);
myTables[0].cells[13].contents = ("" + realHeight);
// PLACE THE BLEED SIZES IN THE SLUG
myTables[0].cells[15].contents = ("Left: " + myLeftBleed);
myTables[0].cells[16].contents = ("Right: " + myRightBleed);
myTables[0].cells[17].contents = ("Top: " + myTopBleed);
myTables[0].cells[18].contents = ("Bottom: " + myBottomBleed);
}

 

 

Oh yeah, I like chocolate glazed....

 

Regards,

Mike