Skip to content

NetworkPrinter Plugin: Netzwerkdrucker direkt per IP anbinden#257

Open
Avatarsia wants to merge 14 commits intoOpenXE-org:masterfrom
Avatarsia:feature/network-printer-module
Open

NetworkPrinter Plugin: Netzwerkdrucker direkt per IP anbinden#257
Avatarsia wants to merge 14 commits intoOpenXE-org:masterfrom
Avatarsia:feature/network-printer-module

Conversation

@Avatarsia
Copy link
Copy Markdown
Contributor

Neues Drucker-Plugin das Netzwerkdrucker direkt per IP-Adresse anspricht.
Ersetzt die Abhaengigkeit von der nicht mehr hergestellten Adapterbox-Hardware
und dem Windows-Druckerspooler.

Unterstuetzte Protokolle:

  • IPP (Internet Printing Protocol) fuer Dokumentendrucker mit vollen
    Druckoptionen (Duplex, Farbe, Schacht, Format, Heftung)
  • RAW/JetDirect (Port 9100) fuer Etikettendrucker (ZPL/EPL)
  • ESC/POS ueber TCP fuer Bondrucker/Thermodrucker
  • LPR/LPD (RFC 1179) als Legacy-Fallback

Features:

  • Druckerstatus-Anzeige (Online/Offline) direkt in der Druckerverwaltung
  • SNMP-Monitoring fuer Toner/Papierstand (optional, wenn ext-snmp installiert)
  • Konfigurierbare Druckoptionen pro Drucker
  • Mehrere Profile fuer denselben physischen Drucker
  • SSRF-Schutz mit IP-Normalisierung

Kompatibilitaet:

  • PHP 7.4 bis 8.5
  • Keine externen Composer-Dependencies
  • Keine Aenderungen an bestehenden Dateien
  • Nutzt das bestehende Plugin-System in www/lib/Printer/

Getestet mit Kyocera ECOSYS M5526cdw (IPP + RAW).

Avatarsia and others added 14 commits April 7, 2026 22:06
…nting

Implements RFC 8011/8010 binary IPP protocol: IppEncoder handles
binary encoding/decoding of Print-Job and Get-Printer-Attributes
requests; IppDriver wraps it as a DriverInterface with full support
for duplex, color, tray, media, staple, orientation and copies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… settings UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e, IPP media keywords

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r null checks

- EscPosDriver.php: Added PHPDoc for constructor and all public methods
- LprDriver.php: Added PHPDoc for constructor and all public methods, @throws annotations
- IppStatus.php: Translate class doc and query() to German
- SnmpStatus.php: Translate all docs to German (class, methods, parameters)
- StatusMonitor.php: Translate class doc and all method docs to German, fix constructor PHPDoc, remove redundant variable initialization
- IppEncoder.php: Translate class doc and all public method docs to German
- IppDriver.php: Fix English comment on line 79 to German
- ConnectionTest.php: Add null check for supply['percent'] in supplies loop

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nitization, file size limit

- NetworkPrinter: port range (1-65535), blocked hosts (SSRF), loopback block
- NetworkPrinter: timeout clamped to 1-300s, file size limit 100MB
- IppEncoder: encodeAttribute truncates name/value at 65535 bytes (pack overflow)
- LprDriver: queue name sanitized (removes non-alphanumeric), rand -> random_int

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…date testConnection path

- Replace string-based blocklist in validateSettings() with IP normalization via
  gethostbyname/ip2long/filter_var to block octal, hex, dword and IPv6-mapped addresses
- Add validateSettings() call to testConnection() to close SSRF via test button
- Remove raw OS error string ($errstr) from user-facing ConnectionTest message
- Add 65535-byte truncation guard on IPP continuation attribute values in IppEncoder

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…check

The test_connection button used typ=submit which created a separate <form>
that triggered OpenXE's POST-Redirect-GET pattern, losing the POST data.

Replaced with typ=custom + renderTestButton() that performs an inline
TCP connect check during page render. Shows green/red status indicator
with response time. Points user to existing "Testseite drucken" button
for actual print testing.
New opt-in feature to combine two A5 labels onto a single A4 sheet
(label 1 on top half, label 2 on bottom half, portrait A4).

Settings (per printer, all default off):
- batch_2up: master switch to enable batching
- batch_timeout: seconds to wait for second label (default 30)
- batch_rotation: auto | none | cw | ccw (default auto)

Behavior when batch_2up is enabled:
- First label is stored in file-based queue (/tmp/np_batch_*)
- Second label within timeout: both combined on one A4 sheet
- Single label after timeout: printed alone on top half of A4
- Per-user + per-printer queue isolation

Uses existing FPDI (www/lib/pdf/fpdi.php) for PDF import, no new
dependencies. Labels are auto-scaled to fit target area while
preserving aspect ratio; rotation handles portrait/landscape mismatch.

Tested with Kyocera ECOSYS M5526cdw via IPP, A4 paper with 2x A5
adhesive labels.
Add classes/Modules/NetworkPrinter/Bootstrap.php plus a README that
documents the wrapper. The NetworkPrinter library itself stays where
it is under www/lib/Printer/NetworkPrinter/: it uses global class
names and require_once chains, external callers rely on those paths,
and the library is already pending upstream as OpenXE-org#257.

The Bootstrap exposes a 'NetworkPrinterFactory' service via the
OpenXE DI container so other modules (e.g. LexwareOffice or a
future invoice-print integration) can resolve a configured
NetworkPrinter instance without touching the require_once chain.

Zero changes to the library itself. The wrapper is purely additive
and survives an upstream merge of PR OpenXE-org#257 unchanged because it only
references paths, not symbols.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant