classes

Classes representing pagesizes.

Classes:

BaseSize(width, height)

Base class namedtuple representing a page size, in point.

PageSize(width, height[, unit])

Represents a pagesize in point.

Size_cm(width, height)

Represents a pagesize in centimeters.

Size_inch(width, height)

Represents a pagesize in inches.

Size_mm(width, height)

Represents a pagesize in millimeters.

Size_pica(width, height)

Represents a pagesize in pica.

Size_um(width, height)

Represents a pagesize in micrometers.

namedtuple BaseSize(width, height)[source]

Bases: NamedTuple

Base class namedtuple representing a page size, in point.

Fields
  1.  width (Unit) – The page width.

  2.  height (Unit) – The page height.

static __new__(cls, width, height)[source]

Create a new BaseSize object.

Parameters
classmethod from_pt(size)[source]

Create a BaseSize object from a page size in point.

Parameters

size (Tuple[float, float]) – The size, in point, to convert from.

Return type

A subclass of BaseSize

classmethod from_size(size)[source]

Create a BaseSize object from a tuple.

Return type

BaseSize

is_landscape()[source]

Returns whether the page is in the landscape orientation.

Return type

bool

is_portrait()[source]

Returns whether the page is in the portrait orientation.

Return type

bool

is_square()[source]

Returns whether the given pagesize is square.

Return type

bool

landscape()[source]

Returns the pagesize in landscape orientation.

Return type

BaseSize

portrait()[source]

Returns the pagesize in portrait orientation.

Return type

BaseSize

to_pt()[source]

Returns the page size in point.

Return type

PageSize

namedtuple PageSize(width, height, unit=<Unit '1.000 pt': 1.000pt>)[source]

Bases: domdf_python_tools.pagesizes.classes.BaseSize

Represents a pagesize in point.

Fields
  1.  width (Unit) – The page width

  2.  height (Unit) – The page height

The pagesize can be converted to other units using the properties below.

static __new__(cls, width, height, unit=<Unit '1.000 pt': 1.000pt>)[source]

Create a new PageSize object.

Parameters
property cm

Returns the pagesize in centimeters.

Return type

Size_cm

property inch

Returns the pagesize in inches.

Return type

Size_inch

property mm

Returns the pagesize in millimeters.

Return type

Size_mm

property pc

Returns the pagesize in pica.

Return type

Size_pica

property pica

Returns the pagesize in pica.

Return type

Size_pica

property pt

Returns the pagesize in pt.

Return type

PageSize

property um

Returns the pagesize in micrometers.

Return type

Size_um

property μm

Returns the pagesize in micrometers.

Return type

Size_um

namedtuple Size_cm(width, height)[source]

Bases: domdf_python_tools.pagesizes.classes.BaseSize

Represents a pagesize in centimeters.

Fields
  1.  width (Unit) – The page width.

  2.  height (Unit) – The page height.

namedtuple Size_inch(width, height)[source]

Bases: domdf_python_tools.pagesizes.classes.BaseSize

Represents a pagesize in inches.

Fields
  1.  width (Unit) – The page width.

  2.  height (Unit) – The page height.

namedtuple Size_mm(width, height)[source]

Bases: domdf_python_tools.pagesizes.classes.BaseSize

Represents a pagesize in millimeters.

Fields
  1.  width (Unit) – The page width.

  2.  height (Unit) – The page height.

namedtuple Size_pica(width, height)[source]

Bases: domdf_python_tools.pagesizes.classes.BaseSize

Represents a pagesize in pica.

Fields
  1.  width (Unit) – The page width.

  2.  height (Unit) – The page height.

namedtuple Size_um(width, height)[source]

Bases: domdf_python_tools.pagesizes.classes.BaseSize

Represents a pagesize in micrometers.

Fields
  1.  width (Unit) – The page width.

  2.  height (Unit) – The page height.