Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Automatically place custom stamp - guided action

New Here ,
Feb 05, 2025 Feb 05, 2025

Greetings! So basically I would like to automate a manual process I sometimes do hundreds of times a day. I have to manually place a stamp onto PDF's, so I wanted to create a guided action that automatically places it in the top right corner of a page. My javascript skills are lacking, and below is my code in the guided action. I can't figure out the placement as this just puts it in the bottom, and it also only selects the most recent stamp I used. Would anyone know how to update the code to place a specific custom stamp in the top right of a page? Here is my code:

var stampName = "jp#test_stamp";

var pageWidth = this.getPageBox("Crop", 0)[2];

var pageHeight = this.getPageBox("Crop", 0)[3];

var stampWidth = 200; var stampHeight = 100;

var x = pageWidth / 2 - stampWidth / 2;

var y = pageHeight / 2 - stampHeight / 2;

 

this.addAnnot({

   page: 0,

   type: "Stamp",

   rect: [x, y, x + stampWidth, y + stampHeight],

   name: stampName

});

TOPICS
JavaScript , Modern Acrobat , PDF
132
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2025 Feb 05, 2025
LATEST

pageHeight should be var pageHeight = this.getPageBox("Crop", 0)[1]; (Crop box coordinates start on the left and go clockwise, annotation rect coordinates start on the left and go counter clockwise, so the tops and bottoms are reversed).

 

this.addAnnot({

   page: 0,

   type: "Stamp",

   rect: [pageWidth-stampWidth, pageHeight-stampHeight, pageWidth, pageHeight],

   AP: stampName

});

 

FYI, if the AP does not start with #, you will have problems applying the stamp after the first application.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines