Skip to main content
dublove
Legend
July 29, 2025
Answered

How do I adjust the image to fit the entire page, including bleed?

  • July 29, 2025
  • 2 replies
  • 326 views

It seems that exceeding the geometricBounds has no effect.
I tested this:

var sel = app.documents[0].selection;
var pb = sel[j].parentPage.bounds;
sel[j].geometricBounds = [-10, -10, pb[2], pb[3]]


and found it to be very wrong.

Correct answer brian_p_dts

In addition to Rob's note, it could be that your document offset is not exactly 0 or your units are off. You can do something like this instead (from chat gpt... seems good)

 

// Resize selected rectangle to page size including bleed
if (app.documents.length > 0 && app.selection.length === 1 && app.selection[0] instanceof Rectangle) {
var doc = app.activeDocument;
var page = app.selection[0].parentPage;

if (page == null) {
alert("The selected rectangle is not on a page.");
} else {
// Get bleed values from document
var bleed = doc.documentPreferences;
var bleedTop = bleed.documentBleedTopOffset;
var bleedBottom = bleed.documentBleedBottomOffset;
var bleedInside = bleed.documentBleedInsideOrLeftOffset;
var bleedOutside = bleed.documentBleedOutsideOrRightOffset;

// Get page bounds [y1, x1, y2, x2] in points
var pageBounds = page.bounds;

// Calculate new bounds including bleed
var newY1 = pageBounds[0] - bleedTop;
var newX1 = pageBounds[1] - bleedInside;
var newY2 = pageBounds[2] + bleedBottom;
var newX2 = pageBounds[3] + bleedOutside;

// Resize the selected rectangle
var rect = app.selection[0];
rect.geometricBounds = [newY1, newX1, newY2, newX2];
}
} else {
alert("Please select a single rectangle on a page.");
}

2 replies

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
July 29, 2025

In addition to Rob's note, it could be that your document offset is not exactly 0 or your units are off. You can do something like this instead (from chat gpt... seems good)

 

// Resize selected rectangle to page size including bleed
if (app.documents.length > 0 && app.selection.length === 1 && app.selection[0] instanceof Rectangle) {
var doc = app.activeDocument;
var page = app.selection[0].parentPage;

if (page == null) {
alert("The selected rectangle is not on a page.");
} else {
// Get bleed values from document
var bleed = doc.documentPreferences;
var bleedTop = bleed.documentBleedTopOffset;
var bleedBottom = bleed.documentBleedBottomOffset;
var bleedInside = bleed.documentBleedInsideOrLeftOffset;
var bleedOutside = bleed.documentBleedOutsideOrRightOffset;

// Get page bounds [y1, x1, y2, x2] in points
var pageBounds = page.bounds;

// Calculate new bounds including bleed
var newY1 = pageBounds[0] - bleedTop;
var newX1 = pageBounds[1] - bleedInside;
var newY2 = pageBounds[2] + bleedBottom;
var newX2 = pageBounds[3] + bleedOutside;

// Resize the selected rectangle
var rect = app.selection[0];
rect.geometricBounds = [newY1, newX1, newY2, newX2];
}
} else {
alert("Please select a single rectangle on a page.");
}

dublove
dubloveAuthor
Legend
July 30, 2025

Hi brian_p_dts.
There is a lot of useful information here. I will study it.

Thank you very much.

rob day
Community Expert
Community Expert
July 29, 2025

the geometricBounds has no effect.

 

What  is [j] ?