Place page number in a Pages document using AppleScript How do I get the page number of each page and place it on the actual page using AppleScript?

I know how to place text in a placeholder text box, but I cannot figure out how to get the page number in AppleScript.
The pages are stored in ‘pages’. You can iterate over this with ‘repeat’.

tell application "Pages"
    activate
    tell document "Untitled.pages"
        repeat with i from 1 to number of pages
            set thispage to item i of pages
            (* do something
            -- variable i is the page number
            -- variable thispage is the page itself
            *)
        end repeat
    end tell
end tell