code: def recorder(elpos):
      """Callback function invoked during story.place().
      This function generates / collects all TOC items and updates the value of
      CURRENT_ID - which is used to update the footer line of each page.
      """
      global TOC, CURRENT_ID
      if not elpos.open_close & 1:  # only consider "open" items
          return
      level = elpos.heading
      y0 = elpos.rect[1]  # top of written rectangle (use for TOC)
      if level > 0:  # this is a header (h1 - h6)
          pno = elpos.page + 1  # the page number
          TOC.append(
              (
                  level,
                  elpos.text,
                  elpos.page + 1,
                  y0,
              )
          )
          return
  
      CURRENT_ID = (
          elpos.id if elpos.id else ""
      )  # update for footer line
      return
  
file_path: pymudf/docs/samples/code-printer.py
imports: import io
  import os
  import time
  import fitz
label_desc: Use image node_id 1 for calling a global function with example usage: recorder(elpos) without return types