Problem with setPageBoxes() when working with ArtBox
- January 16, 2025
- 1 reply
- 1821 views
Hello,
I have been working on a script that would change the ArtBox of the page but it does not seems to be working. Here is a sample script:
for (var o = 0; o<this.numPages; o++) {
var crBox = this.getPageBox('Bleed',o);
var trBox = this.getPageBox('Trim',o);
var rightBleed = [trBox[0], crBox[1], crBox[2], crBox[3]];
var leftBleed = [crBox[0], crBox[1], trBox[2], crBox[3]];
if ( o % 2 == 0 ) {
this.setPageBoxes({
cBox: 'Art',
nStart: o,
rBox: rightBleed
});
}
else {
this.setPageBoxes({
cBox: 'Art',
nStart: o,
rBox: leftBleed
});
}
}The idea goes like this; for every odd page, set the ArtBox to BleedBox except the left side (use TrimBox instead). For even pages flip the sides. But it does nothing in return.
Strangely, if I replace the ArtBox with MediaBox like this:
for (var o = 0; o<this.numPages; o++) {
var crBox = this.getPageBox('Bleed',o);
var trBox = this.getPageBox('Trim',o);
var rightBleed = [trBox[0], crBox[1], crBox[2], crBox[3]];
var leftBleed = [crBox[0], crBox[1], trBox[2], crBox[3]];
if ( o % 2 == 0 ) {
this.setPageBoxes({
cBox: 'Media',
nStart: o,
rBox: rightBleed
});
}
else {
this.setPageBoxes({
cBox: 'Media',
nStart: o,
rBox: leftBleed
});
}
}it suddenly works just fine. Any other change Crop, Bleed or Trim does not work either.
Can anyone provide an insight into this?
Why ArtBox? Well I have discovered that watermarks are dependant on it and ignore any other page box. At least that is the result of my testing.
I have created a test file for testing as well as a simple script that adds the same function with a menu item (under Edit) to run it (can't upload .js so I just change the extension to .txt).
Please, let me know if you know how to make it working. I am a beginner in javascript, so any advice or insight is appreciated.
Best Regards,
David

