Skip to content

Print Queue — System Flow

Visual overview of the file-based print queue: how PDFs are written by the backend and consumed by the external print client on the store server.

Legacy

This reflects the current (legacy) implementation. See Print Queue for full documentation including the planned v2 improvements.


End-to-end flow

sequenceDiagram
    participant Backend as zwerfkei (backend)
    participant LockFile as henk.lock
    participant FS as print_queue/{type}/
    participant API as GET /api/printqueue
    participant Client as Print client (store server)
    participant Printer as Physical printer

    Note over Backend,FS: Writing a PDF
    Backend->>LockFile: Create henk.lock
    Backend->>FS: Write {filename}.pdf
    Backend->>LockFile: Delete henk.lock

    Note over Client,Printer: Print client polling loop
    Client->>API: GET /api/printqueue
    alt Lock file exists
        API-->>Client: 202 Please wait
    else Queue empty
        API-->>Client: 204 No content
    else PDF available
        API->>LockFile: Check lock
        API->>FS: Read first .pdf in queue
        API->>FS: Rename → sent_{timestamp}.pdf
        API-->>Client: 200 { path, timestamp, contents: base64 }
        Client->>Printer: Print PDF
        Client->>API: DELETE /api/printqueue/{timestamp}
        API->>FS: Delete sent_{timestamp}.pdf
    end

PDF types and folders

graph LR
    Backend["zwerfkei\nbackend"]

    Backend -->|"printOutput('a4')"| A4["print_queue/a4/"]
    Backend -->|"printOutput('a5')"| A5["print_queue/a5/"]
    Backend -->|"printOutput('a3')"| A3["print_queue/a3/"]
    Backend -->|"printOutput('factuur')"| FAC["print_queue/a4_bypasstray_duplex/"]
    Backend -->|"printOutput('bypass')"| BYP["print_queue/a4_bypasstray/"]
    Backend -->|"printOutput('shipping_label')"| SL["print_queue/shipping_label_{device}/"]
    Backend -->|"printOutput('plak')"| PL["print_queue/plak/"]
    Backend -->|"printOutput('hang')"| HA["print_queue/hang/"]
    Backend -->|"printOutput('bon')"| BON["print_queue/bon/"]

    A4 --> Client["Print client\n(store server)"]
    A5 --> Client
    A3 --> Client
    FAC --> Client
    BYP --> Client
    SL --> Client
    PL --> Client
    HA --> Client
    BON --> Client

Print Queue — Full Documentation Noodkassa Flow