Disclaimer: I don't know how to code. I am just smashing my head against a brick wall until it works.
The following code places the "Approved" stamp on all opened documents. The stamp is placed in the bottom right-hand corner as seen by the user (Rotated User Space). The stamp is placed on the first Page of the document. It does not matter if the page is rotated or not.
I hope this helps somebody in the future.
var d = app.activeDocs;
for (var i = 0; i < d.length; i++)
{
var point = (0.352778);
var nStampWidth = (86.52/point);
var nStampHeight = (22.72/point);
// Define the stamp location in Rotated Space
var rctCropRot = d[i].getPageBox("Crop",0);
// Define Stamp Location in rotated Space,
var nStampLeft = (rctCropRot[2] - nStampWidth);
var nStampTop = (rctCropRot[3] + nStampHeight);
var nStampRight = (rctCropRot[2]);
var nStampBottom = (rctCropRot[3]);
var rctAnnotRot = [nStampLeft, nStampTop, nStampRight, nStampBottom];
// Convert the annot position into Default space
var mxFromRot = (new Matrix2D).fromRotated(d[i],0);
var rctAnnotDflt = mxFromRot.transform(rctAnnotRot);
d[i].addAnnot({type:"Stamp",page:0,AP:"Approved", rect:rctAnnotDflt, rotate:d[i].getPageRotation(0)});
}
//set up a trusted function (app.activeDocs can only be run from privileged context)
var ApproveAll = app.trustedFunction( function() {
app.beginPriv();
// get an array of all active documents
var d = app.activeDocs;
for (var i = 0; i < d.length; i++)
{
var point = (0.352778);
// define Stamp Width and Height in mm
var nStampWidth = (86.52/point);
var nStampHeight = (22.72/point);
// get the sice of the Crop-Box = what the user sees
var rctCropRot = d[i].getPageBox("Crop",0);
// Define Stamp Location in rotated Space (what the user sees),
var nStampLeft = (rctCropRot[2] - nStampWidth);
var nStampTop = (rctCropRot[3] + nStampHeight);
var nStampRight = (rctCropRot[2]);
var nStampBottom = (rctCropRot[3]);
var rctAnnotRot = [nStampLeft, nStampTop, nStampRight, nStampBottom];
// Convert the annot position into Default space
var mxFromRot = (new Matrix2D).fromRotated(d[i],0);
var rctAnnotDflt = mxFromRot.transform(rctAnnotRot);
//place the Approved stamp
d[i].addAnnot({type:"Stamp",page:0,AP:"Approved", rect:rctAnnotDflt, rotate:d[i].getPageRotation(0)});
}
app.endPriv();
});
// add js-Button
app.addToolButton({
cName: "ApproveAll",
cLabel: "ApproveAll",
cExec: "ApproveAll()",
cTooltext: "Approve_All_Documents",
cEnable: true,
nPos: 0
});
What parameters do you use for the Resize Pages operation?
Could it that after your resize - the coordinates you are specifying fall outside of the remaining crop box area?