Search code examples
pythonadobe-indesign

How to add special characters while scripting InDesign with Python


How to add InDesign special characters like auto-page-numbers to textframes when using Python for scripting InDesign? With JS you could do:

aTextFrame.contents = SpecialCharacters.autoPageNumber

Solution

  • The constant for special character auto page number marker is

    idAutoPageNumber = 1396797550 # from enum idSpecialCharacters
    

    See doc_reference for complete Python Scripting object definitions for InDesign

    To add the special character to a textframe:

    aTextFrame.contents = idAutoPageNumber