Package psg :: Package document :: Module document :: Class page
[hide private]
[frames] | no frames]

Class page

source code

Known Subclasses:
dsc.dsc_page

Model a page in a document.

Instance Methods [hide private]
  __init__(self, document, page_size="a4", label=None)
Model a page in a document.
  w(self)
  h(self)
  add_resource(self, resource, document_level=True)
Add a resource to this page or to this page's document (the default).
  resources(self)
  canvas(self, margin=0, border=False, clip=False)
Return a canvas object for the whole page except a predefined set of margins.
  register_font(self, font, document_level=True)
This function will register a font with this page and return a font_wrapper object, see above.

Instance Variables [hide private]
  _font_wrappers
Mapping of PostScript font names to font_wrapper instances for all the fonts registered with this page
  setup
File-like buffer to hold page initialisation code.

Method Details [hide private]

__init__(self, document, page_size="a4", label=None)
(Constructor)

source code 
Model a page in a document. A page knows about its resources, either on page or on document level.
Parameters:
  • document - A psg.document instance.
  • page_size - Either a string key for the PAPERSIZES dict above a pair of numerical values indicating the page's size in pt. Defaults to 'a4'. Note that opposed to the dict, the order of the tuple's elements is (width, height)
  • label - A string label for this page (goes into the %%Page comment, defaults to a string representation of the page's ordinal, that is its one-based index within the document.)
Raises:
  • KeyError - if the page_size is not known.

w(self)

source code 
None

h(self)

source code 
None

add_resource(self, resource, document_level=True)

source code 
Add a resource to this page or to this page's document (the default).

resources(self)

source code 
None

canvas(self, margin=0, border=False, clip=False)

source code 

Return a canvas object for the whole page except a predefined set of margins.

The margin parameter may be either:
  • an integer - all four margins the same
  • a pair - ( horizontal, vertical, )
  • a 4-tuple - ( left, top, right, bottom, )

register_font(self, font, document_level=True)

source code 

This function will register a font with this page and return a font_wrapper object, see above. The boolean document_level parameter determines whether the font will be a document resource or a page resource.

The page will keep track which fonts have been registered with it and cache wrapper objects. The document_level parameter is only meaningfull for the first call to register_font() with any given font. Fonts are keyed by their PostScript name, not the font objects.

Instance Variable Details [hide private]

_font_wrappers

Mapping of PostScript font names to font_wrapper instances for all the fonts registered with this page

setup

File-like buffer to hold page initialisation code.