Press Ctrl + J and enter the following script into the console, then press Ctrl + A, then Ctrl + Enter
// Function to convert integer numbers to Roman Numerals
function convertToRoman(num) {
if (typeof num !== 'number' || num < 1) return "";
var digits = String(+num).split(""),
key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",
"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC",
"","I","II","III","IV","V","VI","VII","VIII","IX"],
roman = "",
i = 3;
while (i--) {
roman = (key[+digits.pop() + (i * 10)] || "") + roman;
}
return Array(+digits.join("") + 1).join("M") + roman;
}
// Main execution loop
try {
var totalPages = this.numPages;
for (var i = 0; i < totalPages; i++) {
// Human page number calculation
var romanString = convertToRoman(i + 1);
// Convert to lowercase ("page i"). For uppercase ("Page I"), delete .toLowerCase()
romanString = romanString.toLowerCase();
// Assemble final text string
var pageNumText = "Page " + romanString;
// Stamp the text using Acrobat's Watermark feature
this.addWatermarkFromText({
cText: pageNumText,
nTextAlign: app.constants.align.right,
nHorizAlign: app.constants.align.right, // Anchor to the right edge
nVertAlign: app.constants.align.bottom, // Anchor to the bottom edge
nHorizValue: -18, // Corrected: 0.25" inward from right margin
nVertValue: 9, // Corrected: 0.25" upward from bottom margin
cFont: "Arial",
nFontSize: 11,
bOnTop: true,
nStart: i,
nEnd: i
});
}
app.alert("Bottom-right page numbers added successfully!", 3);
} catch(e) {
app.alert("An error occurred: " + e.message, 1);
}