PrintSession
evolis.PrintSession manages a single print job.
It holds the print images, settings, and submits the job to the printer.
Constructor
PrintSession(connection: Connection, *args, **kwargs)The constructor automatically calls init() — detecting ribbon/RW-card type from the printer — unless you pass a specific type.
| Usage | Effect |
|---|---|
PrintSession(co) | Auto-detect ribbon from printer (slowest, most accurate) |
PrintSession(co, RibbonType.YMCKO) | Skip printer query; use YMCKO ribbon |
PrintSession(co, ribbon=RibbonType.KBLACK) | Same with keyword |
PrintSession(co, rwCard=RwCardType.MBLACK) | Use RW card mode |
Initialization Methods
| Method | Description |
|---|---|
init() -> bool | Re-initialize from printer (resets all images and settings). |
init_with_ribbon(ribbonType: RibbonType) -> bool | Initialize without querying printer; sets ribbon type manually. |
init_with_rw_card(ct: RwCardType) -> bool | Initialize for rewritable card mode. |
init_from_driver_settings() -> bool | Initialize by importing all settings from the OS driver. |
Setting Images
All image methods take a CardFace (FRONT or BACK) and either a file path or an in-memory bytearray.
Full Color Image (YMC panels)
ps.set_image(card_face: CardFace, path: str) -> bool
ps.set_image_buffer(card_face: CardFace, buffer: bytearray) -> bool- Accepts 24-bit color BMP.
- Setting a
BACKimage automatically enables duplex printing.
Black Panel Only (K panel)
ps.set_black(card_face: CardFace, path: str) -> bool
ps.set_black_buffer(card_face: CardFace, buffer: bytearray) -> bool- Image must be 1 bit per pixel (monochrome BMP).
- Uses only the K (black resin) panel.
- Controlled by
FBlackManagement/BBlackManagementsettings.
Overlay / Varnish (O panel)
ps.set_overlay(card_face: CardFace, path: str) -> bool
ps.set_overlay_buffer(card_face: CardFace, buffer: bytearray) -> bool- Image must be 1 bpp monochrome BMP (1 = varnish, 0 = no varnish).
- Controlled by
FOverlayManagement/BOverlayManagementsettings.
Second Overlay
ps.set_second_overlay(card_face: CardFace, path: str) -> bool
ps.set_second_overlay_buffer(card_face: CardFace, buffer: bytearray) -> boolUV / Fluorescent Panel
ps.set_uv(card_face: CardFace, path: str) -> bool
ps.set_uv_buffer(card_face: CardFace, buffer: bytearray) -> bool- Image must be 8 bpp grayscale BMP.
- Controlled by
FUvManagement/BUvManagementsettings.
Silver Panel (Avansia only)
ps.set_silver(card_face: CardFace, path: str) -> bool
ps.set_silver_buffer(card_face: CardFace, buffer: bytearray) -> bool- Image must be 1 bpp monochrome BMP.
Rewritable Areas
ps.set_rw_areas(card_face: CardFace, path: str) -> bool
ps.set_rw_areas_buffer(card_face: CardFace, buffer: bytearray) -> bool- Defines rewritable pixels (1 bpp; 1 = rewritable).
- Controlled by
FRwManagement/BRwManagementsettings.
Executing the Print Job
print(timeout: int = 300000) -> ReturnCode
Sends the job to the printer and waits for completion.
timeoutis in milliseconds (default 5 minutes).- Returns a
ReturnCode.ReturnCode.OKmeans success.
rc = ps.print()
if rc != evolis.ReturnCode.OK:
print("Error:", rc)print_to_file(path: str) -> ReturnCode
Generates the PRN data and writes it to a file instead of sending to the printer. Useful for testing.
Auto-Eject
By default, the printer ejects the card after printing.
ps.set_auto_eject(False) # Keep card in printer after print
ps.get_auto_eject() # -> boolSettings (SettingKey)
Print settings control how each panel is used.
Get / Set
ps.get_setting(key: SettingKey) -> str | None
ps.get_int_setting(key: SettingKey) -> int | None
ps.get_bool_setting(key: SettingKey) -> bool | None
ps.set_setting(key: SettingKey, value: str) -> bool
ps.set_int_setting(key: SettingKey, value: int) -> bool
ps.set_bool_setting(key: SettingKey, value: bool) -> boolRemove / Validate
ps.remove_setting(key: SettingKey) -> bool
ps.is_setting_valid(key: SettingKey) -> boolEnumerate
count = ps.get_setting_count()
for i in range(count):
key = ps.get_setting_key(i) # -> SettingKeyCommon settings for black printing
| SettingKey | Type | Values | Description |
|---|---|---|---|
FBlackManagement | LIST | NOBLACKPOINT, ALLBLACKPOINT, TEXTINBLACK, BMPBLACK | Front black panel mode |
BBlackManagement | LIST | same | Back black panel mode |
FOverlayManagement | LIST | NOVARNISH, FULLVARNISH, BMPVARNISH | Front overlay mode |
BOverlayManagement | LIST | same | Back overlay mode |
Duplex | LIST | NONE, HORIZONTAL | Enable duplex printing |
GRibbonType | LIST | e.g. RC_YMCKO, RM_KBLACK | Ribbon type |
Resolution | LIST | DPI300260, DPI300, DPI600300, DPI600, DPI1200300 | Print resolution |
FBlackPrinting | LIST | ON, OFF | Enable front black panel |
BBlackPrinting | LIST | ON, OFF | Enable back black panel |
See 05-setting-keys.md for the full list.
Forced Settings
Forced settings bypass the normal settings validation and are always applied.
ps.set_forced_setting(key: str, value: str) -> None
ps.get_forced_setting(key: str) -> str | None
ps.remove_forced_setting(key: str) -> bool
ps.get_forced_setting_count() -> int
ps.get_forced_setting_key(index: int) -> strExport Configuration
ps.export_config(path: str, sep: str = "=") -> boolWrites the resolved print configuration to a text file. Useful for debugging.
Error Handling
ps.get_last_error() -> ReturnCodeCall after any method that returns bool to get details.
ps.set_last_error(return_code: ReturnCode) -> NoneReserved for testing.
Static Utility
PrintSession.print_test_card(co: Connection, type: int = 0) -> bool
Prints a built-in test card.
type | Evolis printers | Avansia printers |
|---|---|---|
0 | Dual side test (St) | Test U (dual side) |
1 | Single side test (Stt) | Test X (single side) |
2 | — | Test Y (single side) |