SDK DocsPrint Session

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.

UsageEffect
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

MethodDescription
init() -> boolRe-initialize from printer (resets all images and settings).
init_with_ribbon(ribbonType: RibbonType) -> boolInitialize without querying printer; sets ribbon type manually.
init_with_rw_card(ct: RwCardType) -> boolInitialize for rewritable card mode.
init_from_driver_settings() -> boolInitialize 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 BACK image 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 / BBlackManagement settings.

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 / BOverlayManagement settings.

Second Overlay

ps.set_second_overlay(card_face: CardFace, path: str) -> bool
ps.set_second_overlay_buffer(card_face: CardFace, buffer: bytearray) -> bool

UV / 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 / BUvManagement settings.

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 / BRwManagement settings.

Executing the Print Job

print(timeout: int = 300000) -> ReturnCode

Sends the job to the printer and waits for completion.

  • timeout is in milliseconds (default 5 minutes).
  • Returns a ReturnCode. ReturnCode.OK means success.
rc = ps.print()
if rc != evolis.ReturnCode.OK:
    print("Error:", rc)

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()        # -> bool

Settings (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) -> bool

Remove / Validate

ps.remove_setting(key: SettingKey) -> bool
ps.is_setting_valid(key: SettingKey) -> bool

Enumerate

count = ps.get_setting_count()
for i in range(count):
    key = ps.get_setting_key(i)   # -> SettingKey

Common settings for black printing

SettingKeyTypeValuesDescription
FBlackManagementLISTNOBLACKPOINT, ALLBLACKPOINT, TEXTINBLACK, BMPBLACKFront black panel mode
BBlackManagementLISTsameBack black panel mode
FOverlayManagementLISTNOVARNISH, FULLVARNISH, BMPVARNISHFront overlay mode
BOverlayManagementLISTsameBack overlay mode
DuplexLISTNONE, HORIZONTALEnable duplex printing
GRibbonTypeLISTe.g. RC_YMCKO, RM_KBLACKRibbon type
ResolutionLISTDPI300260, DPI300, DPI600300, DPI600, DPI1200300Print resolution
FBlackPrintingLISTON, OFFEnable front black panel
BBlackPrintingLISTON, OFFEnable 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) -> str

Export Configuration

ps.export_config(path: str, sep: str = "=") -> bool

Writes the resolved print configuration to a text file. Useful for debugging.

Error Handling

ps.get_last_error() -> ReturnCode

Call after any method that returns bool to get details.

ps.set_last_error(return_code: ReturnCode) -> None

Reserved for testing.

Static Utility

PrintSession.print_test_card(co: Connection, type: int = 0) -> bool

Prints a built-in test card.

typeEvolis printersAvansia printers
0Dual side test (St)Test U (dual side)
1Single side test (Stt)Test X (single side)
2Test Y (single side)