Document¶
- class pyrinter.Document(name: str = 'My Document', page_size: PaperSize | Tuple[float, float] = PaperSize.A4)¶
document that can be printed with Printer
- add_frame_rect(rect: Tuple[float, float, float, float] | None = None, width: float = 0.01, color: int = 0, page: int | None = None)¶
add frame rectangle to the document
- Parameters:
rect – the rectangle to draw
width – the width of the frame (inch)
color – the color of the frame
page – specific page to print on, None for the last page
- Returns:
None
- add_image(image: str | Image, rect: Tuple[int, int, int, int] | None = None, page: int | None = None)¶
- add image to the document.on windows: transparent will become white background
- Parameters:
image – the image to add, an PIL Image instance or a path to an image
rect – the rectangle to draw on (inches), None to draw on the whole page
page – the page to draw on, None for new page. Negative indexing is supported. Default None
- add_text(text: str, font: Font = Font(font_name='Arial', height=12, weight='normal'), page: int | None = None, rect: Tuple[float, float, float, float] | None = None, align: Align = Align.LEFT, color: int = 0)¶
add text to the document
- Parameters:
text – the text to print
font – the font to use
page – specific page to print on, None for new page. Negative indexing is supported. Default None
rect – the position to print on (inches)
align – align to what side of the rect
color – the color of the text (rgb)
- Returns:
None