neoscore.core.document

class neoscore.core.document.Document[source]

Bases: object

The document root object.

This object should not be created directly by users - it is instantiated by neoscore.setup, which creates a global instance of this class which can be then accessed as neoscore.document.

__init__(paper: Paper, overlay_func: Optional[Callable[[Page], None]] = None)[source]
Parameters
  • paper – The paper to use in the document.

  • overlay_func – An optional function to run on each generated page.

property paper: Paper

The paper type of the document

property pages: PageSupplier

The document’s pages.

Pages are created on-demand by accessing this property.

This property can be treated like a managed list:

>>> from neoscore.core import neoscore; neoscore.setup()
>>> len(neoscore.document.pages)             # No pages exist yet
0
>>> first_page = neoscore.document.pages[0]  # Get the first page
>>> len(neoscore.document.pages)             # One page now exists
1
>>> sixth_page = neoscore.document.pages[5]  # Get the sixth page
>>> len(neoscore.document.pages)             # 5 new pages are created
6
>>> # Pages can be accessed by negative indexing too
>>> assert(first_page == neoscore.document.pages[-6])
>>> assert(sixth_page == neoscore.document.pages[-1])
>>> neoscore.shutdown()

For more information on this object, see PageSupplier.

render(display_page_geometry: bool, background_brush: Brush)[source]

Render all items in the document.

This should not be called directly.

Parameters
  • display_page_geometry – Whether to include a preview of page geometry.

  • background_brush – The brush used to draw the scene background.

page_origin(index: int) Point[source]

Find the origin point of a given page number.

The origin is the top left corner of the live page area.

Parameters

index – The 0-based index of the page to locate.