Question
Acrobat TrimBox math results in unexpected value
Using JavaScript in Acrobat to modify MediaBox size,
the result is not the expected value (
for (var i=0; i<this.numPages; i++) {
var ar = this.getPageBox("Media", i);
console.println("Before: page " + (i+1))
console.println("MediaBox = " + this.getPageBox("Media"));
// increase dimension of MediaBox by 36 points by moving from 0,0 to -36,-36, and then increasing box width and height.
ar[0] = ar[0] - 36
ar[1] = ar[1] + 72
ar[2] = ar[2] + 72
ar[3] = ar[3] - 36
this.setPageBoxes("Media", i, i, ar);
console.println("After: page " + (i+1))
console.println("MediaBox = " + this.getPageBox("Media"));
}The resultant before/after values reveal:
- Before: page 1
MediaBox = 0,504,504,0 - After: page 1
MediaBox = -35.99998474121094,576,576,-35.99998474121094 true
The zeros should have become -36, but didn't. Why?
Also, any attempt I try to round the values using math.rounding(x) just fails, though I"m still hammering on/learning through.
Ideas on calculation issue?