Use an instance of this class to represent any width or height or other dimension. The class is aware of the various different units that are allowed in XSL-FO dimension attributes.
The class supports a few of the common arithmetic operations that one typically needs in computing various document dimensions.
Dimensions are stored internally using values of Python's
Decimal (fixed-point) type. This type's
fixed-point arithmetic avoids many of the common
pathologies of the
float type. For
documentation on this type, see the The Python
The constructor has this calling sequence:
may be any type that is acceptable to the
argument may take any of these values:
|Picas (12 points).|
Here are the methods defined on an instance of class
Return self as a string suitable for use as an XSL-FO dimension attribute.
other is another
FoDim instance, returns their sum. If the
units are different, the result will take into
account standard unit conversions. For example:
>>> import fohelpers as h >>> print h.FoDim(3, h.UNITS_MM) + h.FoDim(6, h.UNITS_CM) 63mm
FoDim instance, returns their difference as a
Multiplies by a constant:
any type acceptable to the
decimal.Decimal() constructor. The result
>>> import decimal as d >>> print h.FoDim('2.5', h.UNITS_IN) * "1.5" 3.75in
Divides by a constant;
other is any
type acceptable to the
self with the opposite sign.
FoDim instance converted
newUnits, which takes the same
values as the
units argument of the