Skip to main content
kama999
New Participant
March 22, 2016
Question

dynamic stamp with an incremental number

  • March 22, 2016
  • 4 replies
  • 17040 views

How to create a dynamic stamp with an incremental number every time I stamp in the PDF. This will be used by only one person and installed on a single computer. Thanks for your help in advance.

This topic has been closed for replies.

4 replies

Thom Parker
Adobe Expert
December 21, 2017

A global variable works, but I think a better option is to store the number value in "doc.info", so that last increment is persistent with the document. Meaning the stamp will always start off at the last increment, even when Acrobat is closed and reopened. It also makes it easy for you to set/change the increment by simply editing the values on the "Custom" tab of the Document Properties dialog.

The stamp script should be something like this:

event.value = ++event.source.source.info.myInc;

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
New Participant
January 21, 2021

That seems to almost work. My problem is,that the stamp increases its value not only when stamping, but every time I even just hover the mouse over the stamp tool. Any way to prevent that? I need to only increment when actually stamping.

try67
Adobe Expert
January 22, 2021

I use the script of Thom Parker as given in the post I replied to. I use it in a form field inside a dynamic stamp. Every time I hover  the mouse over the stamp (as in screenshot below), the counter increases. The workaround is to open the stamps palette and select the stamp from there: This avoids parasitic counter increases. I use Adobe Acrobat Pro DC Version 2020.013.20074.

 

 


Add this line before the current code instead:

if (event.source && event.source.forReal && event.source.stampName == "XXX")

 

Replace XXX with the stamp's AP value, which you can find by applying it to the page, selecting it with the mouse and then running this code from the JS Console:

this.selectedAnnots[0].AP

New Participant
December 21, 2017

I just made a github of an auto-incrementing stamp set that should work:

GitHub - q335r49/AcrobatIncrementStamp: Auto-incrementing stamp for Acrobat

New Participant
June 13, 2022

That works perfect if I use always the sane pdf file.
Is it possible that the stamp keeps in mind the last Number and when I open another pdf file it counts the "reminded" number and increments 1.
Thanks
Gerhard

Bernd Alheit
Adobe Expert
June 13, 2022

Use a global variable for the number.

Karl Heinz  Kremer
Adobe Expert
March 22, 2016

Take a look here for some more information about this subject: Auto Increment Exhibit Stamps - saving metadata to Stamp file (JavaScript)

try67
Adobe Expert
March 22, 2016

You would need to set up a persistent global variable that keeps track of how many times the stamp was applied and increments its value after each time.