dynamic stamp: how create dependent on count different colored background by javasript

Hi there,

thanks to your guides
http://acrobatusers.com/tutorials/cus...
http://acrobatusers.com/tutorials/pri...
i managed to create my first own dynamic stamp.
So this is what i have.

What i`d like to have i the following thing:
I want my stamp to count from 1 to 24 filling its two fields maybe with a number - but much more important - with colored background.

e.g.:
first stamping should return a stamp with the number 1 in it and with two colored fields. One with the color red, the other yellow
second stamping should return a stamp with the number 2 in it and one field colored red, the other green...

so this is what i`d like to get. As i am a really noob in javascript and programming stuff i ask you for your help!
Is there someone able to show me a way or maybe able to give me some advice where to look for it?

Thanks in advance
Christoph


Christoph Fessler


2 Answers

You can use a Global variable to do that. Enter something like this in your stamp script:

if (global.stampCounter == null) {
global.stampCounter = 1;
} else global.stampCounter++;

Then you change the properties of the fields in the stamp based on its value:

if (global.stampCounter==1) {
// set the fields' colors accordingly

} if (global.stampCounter==2) {
// set the fields' colors accordingly

} // etc.

You didn't say what should happen when it reaches 24, though...

-------------------------------------
Visit my custom-made PDF scripts website: http://try67.blogspot.com
Contact me personally: try6767@gmail.com


Gilad D (try67)   

You probably want the counter to reinitialize on each document? I'd suggest using a document variable for the counter. Like this.

var oDoc = event.source.source;
if(typeof(oDoc.stampCounter) == "undefined")
oDoc.stampCounter = 0;

oDoc.stampCounter++;

With this code the increment is stored on the document being stamped. It resets each time you open a new PDF, or when you close and reopen the current PDF.

You'll find everything you ever wanted to know about PDF stamps in the "All about PDF Stamps" book link below.

Thom Parker
The source for PDF Scripting Info pdfscripting.com
All About PDF Stamps in Acrobat and Paperless Workflows - THE BOOK!!

The Acrobat JavaScript Reference, Use it Early and Often

The most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Having trouble, Why Doesn't my Script Work


Thom Parker   


Please specify a reason: