Skip to main content
Participant
March 9, 2025
Answered

Roman Numeral page numbering in Adobe Acrobat Pro

  • March 9, 2025
  • 2 replies
  • 1724 views

I am trying to page number a document with front matter in Roman Numerals. I thought the issue would be using two number types but I can't even get past the step to use Roman Numerals as the format.  I tried in adobe for google drive, the desktop version, and the web version. I saw there was an issue in 2017. Could it be true that this still has not been figured out? Any help or referrals to something that actually works would be great!

Correct answer ajgarbo

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);
}

2 replies

ajgarbo
ajgarboCorrect answer
Participant
June 2, 2026

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);
}

try67
Community Expert
Community Expert
March 9, 2025

Are you referring to page labels (ie. what you see under each thumbnail in the Pages panel) or actual text on the page itself?

Participant
March 10, 2025

actual text. I read you have to change the labels first, which I did. But that did not translate into roman numerals showing up as a choice for formatting a roman numeral on the actual page.

try67
Community Expert
Community Expert
March 10, 2025

The two things are not related. You can add page labels using Roman numerals, but there isn't a similar option in the Add Header & Footer command. However, you can do it using a script, like this (paid-for) one I've developed:

https://www.try67.com/tool/acrobat-reader-advanced-add-header-footer-text