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.
Kind regards,
Daniel
Code: Select all
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)});
}