PageSize
Kind: class
Module/package: models
SDK: pdfdancer-client-python 2.0.0
Represents a page size specification, covering both standard and custom dimensions.
Parameters:
- name: Optional canonical name of the size (e.g. "A4", "LETTER"). Will be upper‑cased.
- width: Page width in PDF points (1/72 inch).
- height: Page height in PDF points (1/72 inch).
Notes:
- Use
PageSize.from_name()or the convenience constants (e.g.PageSize.A4) for common sizes. widthandheightmust be positive numbers and are validated in__post_init__.
Examples:
- From standard name:
size = PageSize.from_name("A4") # or PageSize.A4 - From custom dimensions:
size = PageSize(name=None, width=500.0, height=700.0) - From dict (e.g. deserialized JSON):
size = PageSize.from_dict({"width": 612, "height": 792, "name": "letter"}) - Coercion utility:
size = PageSize.coerce("A4")
size = PageSize.coerce({"width": 300, "height": 300})
Declaration
PageSize(name: str | None, width: float, height: float) -> None
Members
__init__
__init__(self, name: str | None, width: float, height: float) -> None
Initialize self. See help(type(self)) for accurate signature.
coerce
coerce(cls, value: ForwardRef('PageSize') | str | Mapping[str, Any]) -> 'PageSize'
Normalize various page size inputs into a PageSize instance.
from_dict
from_dict(cls, data: Mapping[str, Any]) -> 'PageSize'
Create a page size from a dictionary-like object.
from_dimensions
from_dimensions(cls, width: float, height: float, tolerance: float = 0.5) -> 'PageSize'
Recognize standard dimensions in portrait or rotated orientation.
from_name
from_name(cls, name: str) -> 'PageSize'
Create a page size from a known standard name.
standard_names
standard_names(cls) -> List[str]
Return a list of supported standard page size names.
to_dict
to_dict(self) -> Dict[str, Any]
Convert to dictionary for JSON serialization.