A function to run on every page after creation.

The function takes one argument, the newly generated page. Functions will typically create objects with this page as their parent.

See simple_header_footer for a ready-made simple overlay function.

alias of Callable[[Page], None]

class neoscore.core.page_supplier.PageSupplier[source]

Bases: object

A supplier and generator-on-demand of document Page objects.

This acts like a list of Page objects which generates them as needed. Externally, it can be used mostly as a list. If an index is requested for which no page yet exists, that page will be generated, as well as any missing pages between the previous last page and the one requested. Consequently, keep in mind that innocent looking operations such as page_suppler[100000] are actually expensive operations, as they implicitly generate thousands of Page objects.

The contents of the PageSupplier should be treated as immutable. Attempts to modify the pages it contains will likely result in unexpected behavior.

This is an internal class meant to be created by the global Document for its pages property.

__init__(document: Document, overlay_func: Optional[PageOverlayFunc] = None)[source]
  • document – The global document using this object.

  • overlay_func – A function to call with every page when generated. This can be used to create headers and footers.

property document: Document
property overlay_func: Optional[PageOverlayFunc]

A function to call on every page generation.

This function is called with every generated page at the time of generation. If the value is changed it will only affect pages generated after the change.