Enterprise Printing: SCS, CUPS, LPR, and Print Archive
How AS/400 Printing Works
When a user runs a report or a batch job prints a document on IBM i (AS/400), the output lands in a spool queue (QSPL). A printer device on the system sends that spool data to a physical or virtual printer using the TN5250E printer session protocol.
IMTerm intercepts this flow by presenting itself as a network printer device to the AS/400. The system sends the raw SCS (SNA Character Stream) data to IMTerm, which converts it to PDF, routes it to the appropriate destination, and optionally archives it for compliance.
No changes to host applications are required. Any program that already prints on the AS/400 works with IMTerm printing on day one.
Setting Up a TN5250E Printer Session
Each printer session in IMTerm maps to one printer device on the AS/400. Device type IBM-3812-1 is the standard network printer type recognized by IBM i.
In the IMTerm admin console (Settings > Printer Sessions > Add):
- Host:
as400.corp.com(same as your terminal sessions) - Port:
449(default TN5250E; or992for TLS) - Device Type:
IBM-3812-1 - Device Name:
IMTRMPRN1(must match a device on the AS/400 or use*AUTODEV) - CCSID:
424for Hebrew,37for US English,500for International
On the AS/400 side, verify the printer device description exists:
WRKDEVD DEVD(IMTRMPRN1)
If it doesn't exist, either create it manually or set the IMTerm device name to *AUTODEV to let the system assign one automatically. For production use, fixed device names are recommended so output queues and print subscriptions work consistently.
Multiple printer sessions are supported. Create one per physical printer or output queue. Each session runs independently and can connect to a different host if needed.
SCS to PDF Conversion
When print data arrives, IMTerm's built-in SCS parser reads the stream and produces a PDF. This is entirely server-side in pure Go - no GhostScript, no Java, no third-party PDF tools.
The parser handles:
- SCS control codes:
NL(new line),FF(form feed),CR,LF,RFF(required form feed),SHF(set horizontal format),SVF(set vertical format),SCGL(set character group list) - Page geometry, line spacing, and CPI/LPI settings from the SCS stream
- ANSI highlight colors reproduced in PDF
- Multi-page jobs as single multi-page PDFs
- SCS transparency blocks (TRN) for mixed SCS/PCL data
PDF paper sizes supported: A4, A3, Letter, Legal. Default is A4. Override per printer session.
Print Routing Options
Configure how each print job is delivered in config.yaml under the printing key.
Option 1: Save as PDF (default)
printing:
output: pdf
pdf_dir: /var/lib/imterm/printjobs
Jobs are saved as IMTRMPRN1-20260628-001.pdf in the configured directory. Users access them from the IMTerm web UI under their session's print history.
Option 2: CUPS Printer
printing:
output: cups
cups_queue: lp0
IMTerm calls lp -d lp0 /tmp/imterm-print-XXXX.pdf. The CUPS queue name must exist on the server running IMTerm. Use lpstat -p to list available queues.
Option 3: LPR (network printer)
printing:
output: lpr
lpr_host: 192.168.1.20
lpr_port: 515
lpr_queue: raw
Sends directly to an LPR/LPD-compatible printer or print server. Set lpr_queue: raw when sending PDF to a printer that accepts PDF directly. Set lpr_queue: lp for standard LPD processing.
Option 4: Browser Download
printing:
output: browser
Each print job produces a PDF that the user downloads from the browser. No server-side print routing. Useful for mixed environments where each user chooses their own printer.
Per-Session Override
Override the global setting for a specific printer session by setting output in the printer session configuration. This allows some sessions to go to CUPS while others save to PDF.
Hebrew CP424 Printing
Hebrew AS/400 applications use CCSID 424 (Hebrew New) or 803 (Hebrew Old). IMTerm handles the full EBCDIC-to-UTF-8 translation inside the SCS pipeline before PDF generation.
Set the CCSID on the printer session:
printer_sessions:
- name: IMTRMPRN1
host: as400.corp.com
port: 449
device_type: IBM-3812-1
ccsid: 424
IMTerm then: 1. Decodes CP424 EBCDIC bytes to Unicode Hebrew 2. Detects RTL content via Unicode bidirectional algorithm 3. Renders Hebrew text right-to-left in the PDF 4. Handles mixed Hebrew/English (BiDi) lines correctly
The output matches what the AS/400 intends - no manual character mapping or post-processing needed. This is tested against common Israeli financial and ERP applications.
Print Preview
Before any print job is routed to a physical printer or CUPS queue, the user can open a PDF preview in a browser tab. Click the printer icon in the toolbar, then "Preview" before "Print."
This is especially useful for: - Verifying Hebrew formatting before sending to physical paper - Checking multi-page layout - Confirming the correct printer session is selected
Print Archive (Pro Feature)
Every print job is automatically indexed and stored in a searchable archive. This meets SOX, GDPR, and HIPAA document retention requirements without manual intervention.
Enable in config.yaml:
archive:
enabled: true
retention_days: 2555 # 7 years
archive_dir: /var/lib/imterm/archive
compress: true # gzip older archives
Search from the admin console (Admin > Print Archive):
- By date range
- By user
- By printer session / device name
- By content keywords (full-text search on extracted PDF text)
Download any historical job as PDF directly from the admin console. No database required - the archive is flat files organized by date and indexed with a JSON catalog.
Retention: Jobs older than retention_days are automatically deleted. The default 2,555 days is exactly 7 years. Adjust to match your regulatory requirements.
Audit trail: All archive access is logged to the audit log (IMTE4020I for archive write, IMTE4021I for archive access by admin).
Spool File Viewer
Need to view or reprint an old spool file without leaving IMTerm? The Spool File Viewer browses IBM i spool files directly from the browser.
Click the spool icon in the toolbar (or Session > View Spool Files). IMTerm connects to the AS/400 FTP service and lists files from QSYS.LIB/QSPL.LIB. Select a file and click "View as PDF" - IMTerm downloads the spool data, runs it through the SCS parser, and opens the PDF in a new browser tab.
Filter by user, output queue, or date range. Supports *SCS, *USERASCII, and Host Print Transform output types.
This replaces the need to use WRKSPLF just to view a report, and allows managers to access their own print history without a terminal session.
Full config.yaml Printing Section
printing:
# Where to send completed print jobs
# Options: pdf, cups, lpr, browser
output: pdf
# For output: pdf
pdf_dir: /var/lib/imterm/printjobs
# For output: cups
cups_queue: lp0
# For output: lpr
lpr_host: ""
lpr_port: 515
lpr_queue: lp
# Default paper size for PDF output
# Options: a4, a3, letter, legal
paper_size: a4
# Show print preview in browser before routing
preview_enabled: true
# Maximum SCS job size in MB (jobs larger than this are rejected)
max_job_size_mb: 50
archive:
enabled: true
retention_days: 2555
archive_dir: /var/lib/imterm/archive
compress: true
printer_sessions:
- name: IMTRMPRN1
host: as400.corp.com
port: 449
device_type: IBM-3812-1
ccsid: 424
output: pdf # overrides global printing.output for this session
auto_reconnect: true
reconnect_delay_sec: 30
Troubleshooting
Printer session not connecting
Symptom: Session stays in "Connecting" state.
Check:
1. Firewall: port 449 (or 992 for TLS) open from the IMTerm server to the AS/400
2. Device name: run WRKCFGSTS CFGTYPE(*DEV) CFGD(IMTRMPRN1) on the AS/400 - if the device is in VARY OFF state, vary it on or check if another session already holds it
3. *AUTODEV: if device creation fails, check the AS/400 system value QAUTOVRT allows automatic device creation
Hebrew appears garbled in PDF
Symptom: Hebrew characters print as question marks or Latin characters.
Fix: Verify the printer session CCSID matches the AS/400 output queue's CCSID. Run WRKOUTQ OUTQ(name) and check the CCSID column. Common values: 424 (Hebrew New), 803 (Hebrew Old). Update the printer session configuration to match.
Blank or mostly-blank PDF
Symptom: PDF opens but is empty or shows only page boundaries.
Cause: The spool file was produced with Host Print Transform (HPT) enabled, which converts SCS to PCL or AFP before sending. IMTerm receives already-transformed data.
Fix: On the AS/400, change the printer device's TRANSFORM(*NO) attribute to disable HPT. IMTerm expects raw SCS data. Use CHGDEVPRT DEVD(IMTRMPRN1) TRANSFORM(*NO).
See also: IMTerm Admin Guide section 8 (Printing), IMTerm-QuickStart-Linux.md