Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Odd Request: Hexadecimal Page Numbers

Return to Member Forum

  • Author
    Posts
    • #71008
      John Snape
      Participant

      I’ve been requested to lay out a document of 300+ pages, but with hexadecimal page numbers. It is a book about assembly language programming, and to get the student used to hexadecimal, they want the page numbers in base-16. It would be a pain in the neck to type all of them manually. The only thing I can think of is to learn scripting and create a script to run after the document is finished to convert the regular page numbers to hexadecimal.

      Anyone have any suggestions, or do I need to learn javascript for this?

      Thank you!

    • #71009
      David Blatner
      Keymaster

      I would suggest doing it as a bunch of threaded frames from one page to the next, kind of like this:
      https://creativepro.com/making-numbered-tickets.php

    • #71014

      What a cool idea for a programmer’s book! Can’t resist — here is a ready-made script! (Enjoy disassembling it. Javascript itself is not very hard, but you got to make it interact just right with InDesign.)

      For this to work, you have to assign a label to the text frame(s) that contain the Auto Page Number code on your Master Pages; select the FRAME, then use the Script Label panel (or the Layers panel in newer versions of InDesign) and assign the label “pn” — for ‘page number’. Then run the following script!

      It will try to locate the labelled text frames for each page, override them when found, and change all Current Page Number markers into the correct, uppercased, hexadecimal form.

      //DESCRIPTION:Change page numbers to Hex!
      // A Jongware script 13-Oct-2014
      app.findTextPreferences = null;
      app.findTextPreferences.findWhat = "^N";  // Current Page Number
      doc = app.activeDocument;
      for (p=0; p<doc.pages.length; p++)
      {
        a_page = doc.pages[p];
        pagenum = a_page.documentOffset - a_page.appliedSection.pageStart.documentOffset + a_page.appliedSection.pageNumberStart;
        // who is your master then?
        m = a_page.appliedMaster;
        if (m && m.isValid)
        {
          for (f=a_page.masterPageItems.length-1; f>=0; f--)
          {
            if (a_page.masterPageItems[f].label == 'pn')
            {
              // we got one. Override it..
              tf = a_page.masterPageItems[f].override (a_page);
              // .. and change page number code ..
              pgcode = tf.findText(true);
              for (i=0; i<pgcode.length; i++)
              {
                pgcode[i].contents = (pagenum).toString(16).toUpperCase();
              }
            }
          }
        }
      }
      
    • #71019
      John Snape
      Participant

      Wow! That worked exactly the way I needed it to!

      Thank you, Jongware!!!

    • #71041
      Eugene Tyson
      Member

      Excellent work! Amazing!

Viewing 4 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads