These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Batch Stamping of PDFs

jock
Registered: Mar 26 2008
Posts: 4

In need of a little help. Need a short javascript code chunk to past a custom stamp on the first page of each selected PDF. Want the Stamp to appear in the upper-left hand corner of the page. I have been working with the sample code. For some reason I been unable to change the stamp being applied in the following code:

/* Insert Stamp */

// Get the crop box of the first page

var aCrop = this.getPageBox()

var semiWidth = aCrop[2]/2;

var semiHeight = aCrop[1]/2;

// Get the center of the crop box.

var x = semiWidth;

var y = semiHeight;

// Make the width of the stamp roughly .67% of the cropped page width, and

// make the height of the stamp 25% of the stamp's width

semiWidth = 0.67*semiWidth;

// Make width .67 of width of page

semiHeight = 0.25*semiWidth; // Make height .25 of semiWidth

var Rect = new Array (x-semiWidth,y-semiHeight,x+semiWidth,y+semiHeight);
// The matrix m transforms from rotated to default user space

var m = (new Matrix2D).fromRotated(this,0)

// Transform Rect from rotated to default user space

Rect = m.transform(Rect)

// Now add our annotation using the Rect array for the rect property

var annot = this.addAnnot

({

page: 0,

type: "Stamp",

name: "myStamp",

rect: Rect,

contents: "This document has been approved.",

AP: "Void"

});

My Product Information:
Acrobat Pro 8.1.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You cannot apply a custom stamp annotation with JavaScript, at least you can't do it automatically in a batch process. You can hit the menu item for the custom stamp, but this won't work for a batch process.

You're only easy option is to add a watermark, which looks like a custom stamp, but isn't on an annotation.

But if you want this image to be on a floating window, like the stamp annot, then you could use a button field. Button fields can load an image and be placed by JavaScript in a batch process.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jock
Registered: Mar 26 2008
Posts: 4
Call me Ismaile (Moby Dick) but I have been able to make this work within our workflow. The problem I am having it making the following code use a different stamp:

({

page: 0,

type: "Stamp",

name: "myStamp",

rect: Rect,

contents: "This document has been approved.",

AP: "Void"

});
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The Acrobat JavaScript Reference lists about 12 different appearances that can be applied to a stamp annotation, "Void" isn't one of them. Anything other than the listed appearances will draw an "X" on the stamp. Try putting one of the listed appearances into the "AP" paramerter and you'll see a nice stamp graphic.

In your original question you say that you want to place a custom stamp with JavaScript. Believe me, a lot of people would like this feature. But unfortunately, you can only use one of the listed appearances for the stamp. Using a custom stamp isn't possible with JavaScript.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script